agent-recall-core 3.4.50 → 3.4.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/transcript-project.d.ts +69 -0
- package/dist/helpers/transcript-project.d.ts.map +1 -0
- package/dist/helpers/transcript-project.js +212 -0
- package/dist/helpers/transcript-project.js.map +1 -0
- package/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/dist/palace/awareness.d.ts +6 -0
- package/dist/palace/awareness.d.ts.map +1 -1
- package/dist/palace/awareness.js +10 -4
- package/dist/palace/awareness.js.map +1 -1
- package/dist/retrieval/activation.d.ts +202 -0
- package/dist/retrieval/activation.d.ts.map +1 -0
- package/dist/retrieval/activation.js +313 -0
- package/dist/retrieval/activation.js.map +1 -0
- package/dist/storage/corrections.d.ts +140 -2
- package/dist/storage/corrections.d.ts.map +1 -1
- package/dist/storage/corrections.js +97 -4
- package/dist/storage/corrections.js.map +1 -1
- package/dist/storage/heed-tiers.d.ts +206 -0
- package/dist/storage/heed-tiers.d.ts.map +1 -0
- package/dist/storage/heed-tiers.js +318 -0
- package/dist/storage/heed-tiers.js.map +1 -0
- package/dist/supabase/sync.d.ts +1 -1
- package/dist/supabase/sync.d.ts.map +1 -1
- package/dist/supabase/sync.js +47 -11
- package/dist/supabase/sync.js.map +1 -1
- package/dist/tools-logic/association.d.ts +260 -0
- package/dist/tools-logic/association.d.ts.map +1 -0
- package/dist/tools-logic/association.js +502 -0
- package/dist/tools-logic/association.js.map +1 -0
- package/dist/tools-logic/check-action.d.ts.map +1 -1
- package/dist/tools-logic/check-action.js +14 -0
- package/dist/tools-logic/check-action.js.map +1 -1
- package/dist/tools-logic/implicit-harvest.d.ts +196 -0
- package/dist/tools-logic/implicit-harvest.d.ts.map +1 -0
- package/dist/tools-logic/implicit-harvest.js +675 -0
- package/dist/tools-logic/implicit-harvest.js.map +1 -0
- package/dist/tools-logic/insight-promotion.d.ts.map +1 -1
- package/dist/tools-logic/insight-promotion.js +53 -1
- package/dist/tools-logic/insight-promotion.js.map +1 -1
- package/dist/tools-logic/retier.d.ts +274 -0
- package/dist/tools-logic/retier.d.ts.map +1 -0
- package/dist/tools-logic/retier.js +511 -0
- package/dist/tools-logic/retier.js.map +1 -0
- package/dist/tools-logic/session-end.d.ts +35 -0
- package/dist/tools-logic/session-end.d.ts.map +1 -1
- package/dist/tools-logic/session-end.js +26 -7
- package/dist/tools-logic/session-end.js.map +1 -1
- package/dist/tools-logic/session-start.d.ts +11 -0
- package/dist/tools-logic/session-start.d.ts.map +1 -1
- package/dist/tools-logic/session-start.js +34 -4
- package/dist/tools-logic/session-start.js.map +1 -1
- package/dist/tools-logic/smart-recall.d.ts +11 -0
- package/dist/tools-logic/smart-recall.d.ts.map +1 -1
- package/dist/tools-logic/smart-recall.js +11 -0
- package/dist/tools-logic/smart-recall.js.map +1 -1
- package/dist/tools-logic/transcript-audit.d.ts +128 -0
- package/dist/tools-logic/transcript-audit.d.ts.map +1 -0
- package/dist/tools-logic/transcript-audit.js +428 -0
- package/dist/tools-logic/transcript-audit.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implicit-harvest.js","sourceRoot":"","sources":["../../src/tools-logic/implicit-harvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,eAAe,EAEf,aAAa,EACb,cAAc,GAEf,MAAM,2BAA2B,CAAC;AACnC,OA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O,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC;QACnD,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,UAAU,GAAgC,EAAE,CAAC;IACnD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,UAAU,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insight-promotion.d.ts","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAWrG;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,SAAS,SAAmC,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"insight-promotion.d.ts","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAWrG;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,SAAS,SAAmC,GAAG,OAAO,CAAC,eAAe,CAAC,CA2GrH"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Import chain: imports only from awareness.js and insights-index.js.
|
|
8
8
|
* Does NOT import awareness-update.ts (would create circular dependency).
|
|
9
9
|
*/
|
|
10
|
-
import { addInsight, readAwarenessState } from "../palace/awareness.js";
|
|
10
|
+
import { addInsight, readAwarenessState, readAwarenessArchive, AWARENESS_TOP_INSIGHTS_CAP } from "../palace/awareness.js";
|
|
11
11
|
import { readInsightsIndex } from "../palace/insights-index.js";
|
|
12
12
|
import { tokenizeWords, NON_ASCII_RE } from "../helpers/tokenize.js";
|
|
13
13
|
/**
|
|
@@ -51,11 +51,63 @@ export async function promoteConfirmedInsights(threshold = PROMOTION_CONFIRMATIO
|
|
|
51
51
|
const state = readAwarenessState();
|
|
52
52
|
// Build set of existing awareness titles (lowercased) for dedup check
|
|
53
53
|
const existingTitles = new Set((state?.topInsights ?? []).map((i) => i.title.toLowerCase()));
|
|
54
|
+
// Saturation churn guard (fix12 hygiene, 2026-09-12; churn first observed
|
|
55
|
+
// during the fix3 backfill): against a SATURATED awareness (cap reached,
|
|
56
|
+
// every slot outranking the candidate) addInsight resurrects the candidate
|
|
57
|
+
// from the archive, bumps its confirmations +1, then immediately demotes it
|
|
58
|
+
// back — so every session_end/`ar awareness rollup` re-attempted the same
|
|
59
|
+
// doomed promotion forever: two archive writes + a state write per candidate
|
|
60
|
+
// per run, and an ARTIFICIAL +1 confirmations escalator on the archived
|
|
61
|
+
// entry with no new real confirmation behind it (the insights-index entry
|
|
62
|
+
// is unchanged between runs).
|
|
63
|
+
//
|
|
64
|
+
// Guard — skip ONLY a provably doomed round-trip, i.e. when BOTH hold:
|
|
65
|
+
// (a) no new information: the archived twin already carries >= the
|
|
66
|
+
// candidate's confirmed_count (the archive has absorbed everything
|
|
67
|
+
// the index can attest), AND
|
|
68
|
+
// (b) no survival chance: the resurrected twin (archived + 1 — addInsight
|
|
69
|
+
// bumps on resurrection) still cannot outrank the CURRENT weakest
|
|
70
|
+
// top-insights slot (strict inequality required to survive: on a tie
|
|
71
|
+
// the just-pushed candidate sorts last among equals and is the one
|
|
72
|
+
// popped back to the archive).
|
|
73
|
+
// Condition (b) is the fix12 review MEDIUM-1 fix: without it, an archived
|
|
74
|
+
// twin whose count the pre-fix escalator had inflated (e.g. 50) blocked an
|
|
75
|
+
// ORGANIC promotion that would have displaced a weak slot and STAYED.
|
|
76
|
+
// When confirmed_count grows past the archived count, (a) fails and the
|
|
77
|
+
// attempt proceeds — churn stays bounded by real confirmations. When the
|
|
78
|
+
// twin can win the cap fight, (b) fails and the promotion goes through
|
|
79
|
+
// (resurrect-displace-stay, zero churn). Non-saturated awareness never hits
|
|
80
|
+
// the guard (a resurrected candidate simply stays).
|
|
81
|
+
//
|
|
82
|
+
// NOTE deliberately NOT changed here (owner-taste, flagged in the fix12
|
|
83
|
+
// report): whether a saturated top-20 should ever be displaced by a
|
|
84
|
+
// lower-confirmation candidate, and whether archived insights should
|
|
85
|
+
// re-enter spontaneously when slots free up — this guard only removes the
|
|
86
|
+
// wasted write cycles and the artificial counter inflation.
|
|
87
|
+
const saturated = (state?.topInsights?.length ?? 0) >= AWARENESS_TOP_INSIGHTS_CAP;
|
|
88
|
+
const archive = saturated ? readAwarenessArchive() : [];
|
|
89
|
+
const weakestTopConfirmations = saturated
|
|
90
|
+
? Math.min(...state.topInsights.map((i) => i.confirmations ?? 0))
|
|
91
|
+
: -Infinity;
|
|
54
92
|
const promoted = [];
|
|
55
93
|
const skipped = [];
|
|
56
94
|
for (const insight of index.insights) {
|
|
57
95
|
if (insight.confirmed_count < threshold)
|
|
58
96
|
continue;
|
|
97
|
+
if (saturated) {
|
|
98
|
+
let archivedConfirmations = -1;
|
|
99
|
+
for (const a of archive) {
|
|
100
|
+
if (titlePresentInAwareness(insight.title, [a.title.toLowerCase()])) {
|
|
101
|
+
archivedConfirmations = Math.max(archivedConfirmations, a.confirmations ?? 0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const noNewInformation = archivedConfirmations >= insight.confirmed_count;
|
|
105
|
+
const cannotSurviveCap = archivedConfirmations + 1 <= weakestTopConfirmations;
|
|
106
|
+
if (archivedConfirmations >= 0 && noNewInformation && cannotSurviveCap) {
|
|
107
|
+
skipped.push(insight.title);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
59
111
|
// Title-similarity dedup: exact match first, then word overlap.
|
|
60
112
|
// CJK-aware (fix #3, 2026-09-11): the pre-fix grammar was
|
|
61
113
|
// `titleLower.split(/\s+/)` + `w.length > 3` — an unspaced CJK title
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insight-promotion.js","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"insight-promotion.js","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC1H,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAOrE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa,EAAE,mBAAqC;IAC1F,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,E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,CAAC,CAAC;QAEH,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,EAAE,CAAC;YAC5B,+FAA+F;YAC/F,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7B,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,2BAA2B;YAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* retier.ts — evolution p4 (Phase 4): the soft-constraint ladder,
|
|
3
|
+
* `ar corrections retier`.
|
|
4
|
+
*
|
|
5
|
+
* WHY: `severity` (p0/p1) is a binary, capture-time, NEVER-revisited label —
|
|
6
|
+
* once a rule is p0 it stays hard-enforced forever even if its evidence
|
|
7
|
+
* (heeded/recurred/retrieved) never shows up again. "Rules must die unless
|
|
8
|
+
* data renews them": this module adds a THREE-tier ladder — gate (hard
|
|
9
|
+
* enforcement) / nudge (advisory) / watch (background) — computed FRESH
|
|
10
|
+
* from each record's own evidence, plus an automatic, reversible one-step
|
|
11
|
+
* DEMOTION when that evidence goes stale. Nothing here ever deletes,
|
|
12
|
+
* retracts, or archives a record — see CONSTRAINTS below.
|
|
13
|
+
*
|
|
14
|
+
* ---------------------------------------------------------------------------
|
|
15
|
+
* tierOf — HAND-TUNED v1 formula (every constant named + justified; not fit
|
|
16
|
+
* to any labeled outcome set, same "chosen by feel" status as activation.ts's
|
|
17
|
+
* S_DECAY/ACT_ALPHA)
|
|
18
|
+
* ---------------------------------------------------------------------------
|
|
19
|
+
* gate: severity p0 AND proof_confidence ≥ GATE_MIN_PROOF_CONFIDENCE (0.7)
|
|
20
|
+
* AND retrieved within GATE_RETRIEVED_WITHIN_DAYS (30d) of asOfDay.
|
|
21
|
+
* nudge: (severity p0 that did NOT meet gate) — OR —
|
|
22
|
+
* (severity p1 AND proof_confidence ≥ NUDGE_P1_MIN_PROOF_CONFIDENCE
|
|
23
|
+
* (0.6) AND retrieved within NUDGE_RETRIEVED_WITHIN_DAYS (60d)).
|
|
24
|
+
* watch: everything else.
|
|
25
|
+
*
|
|
26
|
+
* `proof_confidence` is read directly off the record (it is already the
|
|
27
|
+
* Beta posterior `(heeded+1)/(heeded+recurred+2)` when outcomes exist, and
|
|
28
|
+
* already falls back to `weight` when they don't — see corrections.ts's
|
|
29
|
+
* `applyCorrectionDefaults`/`recordOutcome`). `proofConfidenceOf` below adds
|
|
30
|
+
* ONE more defensive fallback layer (mirroring `decayClassOf`/
|
|
31
|
+
* `effectiveConfidenceOf`'s established defensive posture in corrections.ts)
|
|
32
|
+
* for a raw/un-defaulted record a caller hands in directly (e.g. a truth-
|
|
33
|
+
* table test fixture) rather than one that went through `readCorrections()`.
|
|
34
|
+
*
|
|
35
|
+
* COLD-START (stated explicitly, per the brief): a fresh record that has
|
|
36
|
+
* NEVER been retrieved (`last_retrieved` absent) fails BOTH the gate's and
|
|
37
|
+
* the nudge-p1-branch's retrieval-recency clause regardless of its
|
|
38
|
+
* `proof_confidence` (which for a truly fresh record is `weight`'s prior —
|
|
39
|
+
* ≈1.0 for p0, ≈0.7 for p1 — NOT literally 0.5; the brief's "prior≈0.5"
|
|
40
|
+
* describes the SHAPE of the argument, not a required literal value, and
|
|
41
|
+
* the derivation below holds for ANY confidence value, 0.5 included, since
|
|
42
|
+
* the p0-nudge branch never even reads confidence). Mechanically:
|
|
43
|
+
* - a fresh P0 record: gate fails (retrieval clause) → falls to the
|
|
44
|
+
* UNCONDITIONAL "severity p0 not meeting gate" nudge branch → **nudge**.
|
|
45
|
+
* - a fresh P1 record: gate fails (wrong severity) → nudge's p1 branch
|
|
46
|
+
* ALSO fails (retrieval clause) → **watch**.
|
|
47
|
+
* This is not a special case coded separately — it is what the formula
|
|
48
|
+
* above already produces for any record with `last_retrieved` absent; it is
|
|
49
|
+
* called out here (and pinned by a truth-table test row) because it is the
|
|
50
|
+
* single most consequential behavior an operator needs to know before
|
|
51
|
+
* trusting the ladder on a corpus with many never-yet-retrieved corrections.
|
|
52
|
+
*
|
|
53
|
+
* ---------------------------------------------------------------------------
|
|
54
|
+
* demotionOf — automatic, one-step-down triggers (pure)
|
|
55
|
+
* ---------------------------------------------------------------------------
|
|
56
|
+
* Fires independently of (and can pull a record BELOW) the raw `tierOf`
|
|
57
|
+
* result — this is what keeps a P0 record that is technically "not meeting
|
|
58
|
+
* gate" (and would therefore sit at "nudge" forever per the formula above,
|
|
59
|
+
* regardless of HOW stale it gets — the p0-nudge branch has no recency
|
|
60
|
+
* clause of its own) from getting stuck at nudge indefinitely once it goes
|
|
61
|
+
* genuinely dormant.
|
|
62
|
+
* - `not_violated_plateau`: `not_violated_count ≥ DEMOTE_NOT_VIOLATED_MIN`
|
|
63
|
+
* (3) AND `heeded_count === 0 && recurrence_count === 0`. DOCUMENTED
|
|
64
|
+
* APPROXIMATION: the brief's literal spec is "zero heeded/recurred IN
|
|
65
|
+
* THE LAST 60 DAYS", but `recordOutcome` (storage/corrections.ts)
|
|
66
|
+
* stamps `last_outcome` for heeded, recurred, AND not_violated alike —
|
|
67
|
+
* one shared timestamp, no per-kind history — so a record-only pure
|
|
68
|
+
* function (no ledger read) cannot distinguish "heeded happened but was
|
|
69
|
+
* >60d ago" from "heeded never happened". This checks lifetime-zero
|
|
70
|
+
* instead, which is a STRICT SUBSET of the windowed check (every record
|
|
71
|
+
* lifetime-zero-heeded/recurred is trivially also windowed-zero; a
|
|
72
|
+
* record with e.g. `heeded_count:1` whose one heeded event happened
|
|
73
|
+
* 400 days ago would satisfy the brief's literal windowed spec but is
|
|
74
|
+
* SKIPPED here). Flagged, not silently narrowed: a ledger-precision
|
|
75
|
+
* windowed version would need `readOutcomeEventsByCorrection`, which is
|
|
76
|
+
* a different function's job, not this pure per-record one's.
|
|
77
|
+
* - `retrieval_stale_90d`: no retrieval touch within
|
|
78
|
+
* `DEMOTE_RETRIEVAL_STALE_DAYS` (90) of `asOfDay`. Anchor is
|
|
79
|
+
* `last_retrieved ?? date` (record creation date) — mirrors
|
|
80
|
+
* `isStaleCorrection`'s existing `last_retrieved ?? last_outcome ?? date`
|
|
81
|
+
* touch-anchor convention in corrections.ts, narrowed to retrieval-only
|
|
82
|
+
* (not outcome) because the brief names "no RETRIEVED event"
|
|
83
|
+
* specifically. Falling back to `date` (never `last_outcome`) means a
|
|
84
|
+
* record created 5 days ago with zero retrievals does NOT yet trigger
|
|
85
|
+
* this — there has not been a 90-day WINDOW in which retrieval could
|
|
86
|
+
* have happened, so there is nothing to call "stale" yet. `currentTier
|
|
87
|
+
* === "watch"` short-circuits to `[]` — watch is the floor; there is no
|
|
88
|
+
* lower tier to step down to, so computing triggers for it is a no-op
|
|
89
|
+
* it can skip announcing.
|
|
90
|
+
*
|
|
91
|
+
* ---------------------------------------------------------------------------
|
|
92
|
+
* archiveCandidates / promoteToGateCandidates — PROPOSALS ONLY
|
|
93
|
+
* ---------------------------------------------------------------------------
|
|
94
|
+
* Both are pure REPORTS, read by `--dry-run` (and always computed, never
|
|
95
|
+
* gated behind the flag — `--write` just additionally persists tiers).
|
|
96
|
+
* Neither list is ever applied, retracted, or archived by this module or by
|
|
97
|
+
* `--write` — there is no `--apply-proposals` flag anywhere in this file.
|
|
98
|
+
* `archiveCandidates`: watch-tier records with no retrieval/outcome/
|
|
99
|
+
* prediction touch of ANY kind in `ARCHIVE_STALE_DAYS` (180) days — a human
|
|
100
|
+
* decides whether "dormant this long" means retract, keep watching, or
|
|
101
|
+
* something else; this module has no opinion past surfacing the list.
|
|
102
|
+
* `promoteToGateCandidates`: records where the RAW formula (`tierOf`) says
|
|
103
|
+
* "gate", NO demotion trigger fires for that same record (`demotionOf`
|
|
104
|
+
* re-checked internally — see FIX note on the function itself: a raw-gate
|
|
105
|
+
* record whose `not_violated_plateau`/`retrieval_stale_90d` trigger is
|
|
106
|
+
* active is NOT a candidate, because `--write` would persist it one step
|
|
107
|
+
* BELOW gate, not at gate — see `final_tier` below), and the record's
|
|
108
|
+
* LAST-PERSISTED `tier` field disagrees (absent, or a lower tier — this can
|
|
109
|
+
* happen legitimately: a record demoted for staleness gets freshly
|
|
110
|
+
* retrieved again and its raw formula recovers to "gate" before the next
|
|
111
|
+
* `--write` run catches up). `--write` persists `final_tier` — `tierOf`'s
|
|
112
|
+
* raw result stepped down once if `demotionOf` fired, exactly like every
|
|
113
|
+
* other tier — so a promotion INTO gate is not held back by anything
|
|
114
|
+
* OTHER than that same demotion check (only DEMOTION out of a tier is a
|
|
115
|
+
* separate, escalation-style path; there is no analogous "promotion
|
|
116
|
+
* approval" write-gate here). Inside `runRetier`, this list is additionally
|
|
117
|
+
* computed against each record's tier AS OF the end of this call (the tier
|
|
118
|
+
* `--write` just persisted this run, if any — never the pre-write snapshot;
|
|
119
|
+
* see the `writtenTierThisRun` remap in `runRetier`), so a record `--write`
|
|
120
|
+
* already promoted to gate THIS call is never simultaneously reported as
|
|
121
|
+
* "still pending". What "OWNER-GATED" (the brief's own words for this list)
|
|
122
|
+
* means concretely in v1: this list is the visibility mechanism — a human
|
|
123
|
+
* reviewing `--dry-run` output sees exactly which records are ABOUT TO
|
|
124
|
+
* become (or already are, pending the next --write) gate-tier BEFORE
|
|
125
|
+
* trusting anything downstream to key off `tier==="gate"` automatically. If
|
|
126
|
+
* a future phase wants `--write` to hold gate promotions for explicit human
|
|
127
|
+
* sign-off (a real write-time gate), that is a NEW, separate flag on top of
|
|
128
|
+
* this reporting list, not a silent change to what `--write` does today.
|
|
129
|
+
*
|
|
130
|
+
* ---------------------------------------------------------------------------
|
|
131
|
+
* CHALLENGE resolution — stored `tier` vs. `tierOf()` (read contract)
|
|
132
|
+
* ---------------------------------------------------------------------------
|
|
133
|
+
* DECIDED: the stored `CorrectionRecord.tier` field is a WRITE-TIME CACHE,
|
|
134
|
+
* never truth. `tierOf(record, asOfDay)` is the ONE source of truth for
|
|
135
|
+
* "what tier is this record right now" — see the field's own doc comment in
|
|
136
|
+
* storage/corrections.ts. This module's own `promoteToGateCandidates` is the
|
|
137
|
+
* proof this is load-bearing, not decorative: it exists BECAUSE the cached
|
|
138
|
+
* field can legitimately disagree with a fresh computation. The
|
|
139
|
+
* session_start rendering tag (goal 3) recomputes fresh at render time for
|
|
140
|
+
* the same reason — it never reads `record.tier`. Storing nothing at all
|
|
141
|
+
* (compute-on-every-read, everywhere) was the alternative considered and
|
|
142
|
+
* REJECTED: `--dry-run`'s whole value proposition is showing "stored vs.
|
|
143
|
+
* computed" drift (the CLI table's `current` column) and idempotency proof
|
|
144
|
+
* needs SOMETHING durable to compare a second `--write` run against; a
|
|
145
|
+
* cache with a documented, enforced "never trust me without recomputing"
|
|
146
|
+
* contract gets both without inventing a second source of truth for any
|
|
147
|
+
* consumer that matters (there is exactly one: `promoteToGateCandidates`,
|
|
148
|
+
* and it already treats the field as a stale-vs-fresh SIGNAL, never as an
|
|
149
|
+
* answer on its own).
|
|
150
|
+
*
|
|
151
|
+
* ---------------------------------------------------------------------------
|
|
152
|
+
* Determinism / store-root handling
|
|
153
|
+
* ---------------------------------------------------------------------------
|
|
154
|
+
* `runRetier` is deterministic given the same `asOfDay` and unchanged
|
|
155
|
+
* on-disk inputs (project slugs sorted, no wall-clock read once `asOfDay`
|
|
156
|
+
* is fixed). Unlike `association.ts`'s `--store` (which deliberately never
|
|
157
|
+
* mutates the process-global root because it does its OWN raw fs
|
|
158
|
+
* reads/writes), `runRetier`'s `--write` path MUST reuse corrections.ts's
|
|
159
|
+
* locked, atomic, index-regenerating write machinery (`setCorrectionTier`)
|
|
160
|
+
* — the brief's own "sanctioned record-write path under the project lock"
|
|
161
|
+
* requirement — and that machinery is hard-wired to `getRoot()` throughout.
|
|
162
|
+
* Reimplementing lock+atomic-write+index-regen here to avoid a root swap
|
|
163
|
+
* would duplicate exactly the mechanism the brief says to reuse. So this
|
|
164
|
+
* module swaps `setRoot()` for the duration of one `runRetier()` call (only
|
|
165
|
+
* when `storeRoot` is explicitly passed) and restores the PRIOR root in a
|
|
166
|
+
* `finally`, even on throw — see `withStoreRoot` below. This is the SAME
|
|
167
|
+
* mechanism the CLI's pre-existing global `--root` flag already uses
|
|
168
|
+
* (types.ts's `setRoot`), just scoped to one call instead of the whole
|
|
169
|
+
* process lifetime.
|
|
170
|
+
*/
|
|
171
|
+
import { type CorrectionRecord, type CorrectionTier } from "../storage/corrections.js";
|
|
172
|
+
export declare const GATE_MIN_PROOF_CONFIDENCE = 0.7;
|
|
173
|
+
export declare const GATE_RETRIEVED_WITHIN_DAYS = 30;
|
|
174
|
+
export declare const NUDGE_P1_MIN_PROOF_CONFIDENCE = 0.6;
|
|
175
|
+
export declare const NUDGE_RETRIEVED_WITHIN_DAYS = 60;
|
|
176
|
+
export declare const DEMOTE_NOT_VIOLATED_MIN = 3;
|
|
177
|
+
export declare const DEMOTE_RETRIEVAL_STALE_DAYS = 90;
|
|
178
|
+
export declare const ARCHIVE_STALE_DAYS = 180;
|
|
179
|
+
/**
|
|
180
|
+
* The soft-constraint ladder — HAND-TUNED v1 formula. See this file's header
|
|
181
|
+
* for the full derivation, every constant's name/value, and the cold-start
|
|
182
|
+
* worked example. Pure: no I/O, no wall-clock read (asOfDay is the caller's
|
|
183
|
+
* "now").
|
|
184
|
+
*/
|
|
185
|
+
export declare function tierOf(record: Pick<CorrectionRecord, "severity" | "proof_confidence" | "weight" | "last_retrieved">, asOfDay: string): CorrectionTier;
|
|
186
|
+
/** One step down the ladder (gate→nudge→watch→watch — watch is the floor). */
|
|
187
|
+
export declare function stepDownTier(tier: CorrectionTier): CorrectionTier;
|
|
188
|
+
/**
|
|
189
|
+
* One-step-down trigger list for `record` at `currentTier`/`asOfDay`. Pure —
|
|
190
|
+
* returns the trigger NAMES that fired (empty = no demotion). See this
|
|
191
|
+
* file's header for the exact rationale of each trigger, including the
|
|
192
|
+
* documented not_violated windowing approximation.
|
|
193
|
+
*/
|
|
194
|
+
export declare function demotionOf(record: Pick<CorrectionRecord, "not_violated_count" | "heeded_count" | "recurrence_count" | "last_retrieved" | "date">, currentTier: CorrectionTier, asOfDay: string): string[];
|
|
195
|
+
export interface ArchiveCandidate {
|
|
196
|
+
project: string;
|
|
197
|
+
id: string;
|
|
198
|
+
rule: string;
|
|
199
|
+
/** Most recent touch of ANY kind (retrieved/outcome/predicted), or null if truly never touched. */
|
|
200
|
+
last_touch: string | null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* watch-tier records with no retrieval/outcome/prediction touch of ANY kind
|
|
204
|
+
* in `ARCHIVE_STALE_DAYS` days. PROPOSAL LIST ONLY — see this file's header.
|
|
205
|
+
* `tierOf` is recomputed here (never reads `record.tier`) per the CHALLENGE
|
|
206
|
+
* resolution above.
|
|
207
|
+
*/
|
|
208
|
+
export declare function archiveCandidates(records: readonly CorrectionRecord[], asOfDay: string): ArchiveCandidate[];
|
|
209
|
+
export interface PromoteToGateCandidate {
|
|
210
|
+
project: string;
|
|
211
|
+
id: string;
|
|
212
|
+
rule: string;
|
|
213
|
+
severity: "p0" | "p1";
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Records where the RAW formula (`tierOf`) says "gate" but the record's
|
|
217
|
+
* last-PERSISTED `tier` field disagrees (absent, or a lower tier). PROPOSAL
|
|
218
|
+
* LIST ONLY (visibility, not a write-gate) — see this file's header.
|
|
219
|
+
*/
|
|
220
|
+
export declare function promoteToGateCandidates(records: readonly CorrectionRecord[], asOfDay: string): PromoteToGateCandidate[];
|
|
221
|
+
export interface RetierOptions {
|
|
222
|
+
/** Storage root override. Defaults to core's getRoot() (AGENT_RECALL_ROOT / setRoot() / ~/.agent-recall). */
|
|
223
|
+
storeRoot?: string;
|
|
224
|
+
/** "as of" day (YYYY-MM-DD) for every recency comparison. Defaults to today (local calendar day). */
|
|
225
|
+
asOfDay?: string;
|
|
226
|
+
/** Persist the computed tier via setCorrectionTier(). Default false (dry-run — computes and reports, writes nothing). */
|
|
227
|
+
write?: boolean;
|
|
228
|
+
}
|
|
229
|
+
export interface RetierRow {
|
|
230
|
+
project: string;
|
|
231
|
+
id: string;
|
|
232
|
+
severity: "p0" | "p1";
|
|
233
|
+
rule: string;
|
|
234
|
+
/** The record's last-persisted `tier` field, or null if never retiered. */
|
|
235
|
+
stored_tier: CorrectionTier | null;
|
|
236
|
+
/** Raw tierOf() output, before any demotion adjustment. */
|
|
237
|
+
computed_tier: CorrectionTier;
|
|
238
|
+
/** computed_tier, stepped down once if any demotion trigger fired — what --write persists (or would persist). */
|
|
239
|
+
final_tier: CorrectionTier;
|
|
240
|
+
/** Demotion trigger names that fired (empty = none). */
|
|
241
|
+
triggers: string[];
|
|
242
|
+
/** final_tier !== stored_tier. */
|
|
243
|
+
changed: boolean;
|
|
244
|
+
}
|
|
245
|
+
export interface RetierResult {
|
|
246
|
+
as_of: string;
|
|
247
|
+
store_root: string;
|
|
248
|
+
dry_run: boolean;
|
|
249
|
+
projects_scanned: number;
|
|
250
|
+
rows: RetierRow[];
|
|
251
|
+
/** Counts by final_tier — always sums to rows.length. */
|
|
252
|
+
tier_distribution: Record<CorrectionTier, number>;
|
|
253
|
+
/** rows where a demotion trigger fired. */
|
|
254
|
+
demoted: RetierRow[];
|
|
255
|
+
promote_to_gate_candidates: PromoteToGateCandidate[];
|
|
256
|
+
archive_candidates: ArchiveCandidate[];
|
|
257
|
+
/** Records actually persisted this run (always 0 when dry_run is true). */
|
|
258
|
+
written: number;
|
|
259
|
+
/** Per-record write failures (lock contention) — see setCorrectionTier. */
|
|
260
|
+
write_errors: number;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Cross-project retier run. Dry-run by default (computes and reports,
|
|
264
|
+
* writes nothing); pass `{ write: true }` to persist via `setCorrectionTier`
|
|
265
|
+
* — see this file's header for the exact write semantics (demotion always
|
|
266
|
+
* applied; promotion into "gate" is the raw formula, not held back;
|
|
267
|
+
* archive/promote-to-gate lists are NEVER applied here regardless of
|
|
268
|
+
* `write`). Idempotent given unchanged inputs and the same `asOfDay`: a
|
|
269
|
+
* second `{ write: true }` run persists zero records (both this function's
|
|
270
|
+
* own `changed` pre-filter AND `setCorrectionTier`'s independent fresh-read
|
|
271
|
+
* check guard this).
|
|
272
|
+
*/
|
|
273
|
+
export declare function runRetier(opts?: RetierOptions): Promise<RetierResult>;
|
|
274
|
+
//# sourceMappingURL=retier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retier.d.ts","sourceRoot":"","sources":["../../src/tools-logic/retier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyKG;AAMH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAOnC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AA4EtC;;;;;GAKG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,kBAAkB,GAAG,QAAQ,GAAG,gBAAgB,CAAC,EAC7F,OAAO,EAAE,MAAM,GACd,cAAc,CAmBhB;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG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