agent-recall-core 3.4.50 → 3.5.2
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/README.md +559 -330
- package/dist/embeddings/config.d.ts.map +1 -1
- package/dist/embeddings/config.js +17 -4
- package/dist/embeddings/config.js.map +1 -1
- package/dist/helpers/alignment-patterns.d.ts +46 -0
- package/dist/helpers/alignment-patterns.d.ts.map +1 -1
- package/dist/helpers/alignment-patterns.js +103 -2
- package/dist/helpers/alignment-patterns.js.map +1 -1
- package/dist/helpers/journal-files.d.ts +12 -6
- package/dist/helpers/journal-files.d.ts.map +1 -1
- package/dist/helpers/journal-files.js +13 -7
- package/dist/helpers/journal-files.js.map +1 -1
- 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 +28 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -6
- 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/prompts/consolidation-prompt.js +14 -14
- 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/retrieval/candidates.d.ts +17 -0
- package/dist/retrieval/candidates.d.ts.map +1 -1
- package/dist/retrieval/candidates.js +4 -2
- package/dist/retrieval/candidates.js.map +1 -1
- package/dist/retrieval/contradiction.d.ts +42 -0
- package/dist/retrieval/contradiction.d.ts.map +1 -1
- package/dist/retrieval/contradiction.js +126 -7
- package/dist/retrieval/contradiction.js.map +1 -1
- package/dist/retrieval/lexical-index.d.ts +150 -0
- package/dist/retrieval/lexical-index.d.ts.map +1 -0
- package/dist/retrieval/lexical-index.js +514 -0
- package/dist/retrieval/lexical-index.js.map +1 -0
- package/dist/retrieval/query-memory.d.ts +17 -7
- package/dist/retrieval/query-memory.d.ts.map +1 -1
- package/dist/retrieval/query-memory.js +274 -68
- package/dist/retrieval/query-memory.js.map +1 -1
- package/dist/storage/classification.d.ts.map +1 -1
- package/dist/storage/classification.js +4 -1
- package/dist/storage/classification.js.map +1 -1
- package/dist/storage/content-guard.d.ts +26 -0
- package/dist/storage/content-guard.d.ts.map +1 -1
- package/dist/storage/content-guard.js +450 -48
- package/dist/storage/content-guard.js.map +1 -1
- package/dist/storage/corrections.d.ts +140 -2
- package/dist/storage/corrections.d.ts.map +1 -1
- package/dist/storage/corrections.js +144 -70
- package/dist/storage/corrections.js.map +1 -1
- package/dist/storage/cwd-allowlist.d.ts +28 -2
- package/dist/storage/cwd-allowlist.d.ts.map +1 -1
- package/dist/storage/cwd-allowlist.js +61 -13
- package/dist/storage/cwd-allowlist.js.map +1 -1
- package/dist/storage/filelock.d.ts +26 -8
- package/dist/storage/filelock.d.ts.map +1 -1
- package/dist/storage/filelock.js +202 -26
- package/dist/storage/filelock.js.map +1 -1
- package/dist/storage/fs-utils.d.ts +51 -0
- package/dist/storage/fs-utils.d.ts.map +1 -1
- package/dist/storage/fs-utils.js +123 -2
- package/dist/storage/fs-utils.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/storage/memory-protocol.js +55 -55
- package/dist/storage/paths.d.ts.map +1 -1
- package/dist/storage/paths.js +7 -2
- package/dist/storage/paths.js.map +1 -1
- package/dist/storage/project.d.ts.map +1 -1
- package/dist/storage/project.js +9 -2
- package/dist/storage/project.js.map +1 -1
- package/dist/storage/store-manifest.js +57 -57
- package/dist/supabase/embedding.d.ts.map +1 -1
- package/dist/supabase/embedding.js +7 -0
- package/dist/supabase/embedding.js.map +1 -1
- package/dist/supabase/sync.d.ts +1 -1
- package/dist/supabase/sync.d.ts.map +1 -1
- package/dist/supabase/sync.js +88 -28
- 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/bootstrap.d.ts.map +1 -1
- package/dist/tools-logic/bootstrap.js +4 -2
- package/dist/tools-logic/bootstrap.js.map +1 -1
- 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/check.d.ts +7 -0
- package/dist/tools-logic/check.d.ts.map +1 -1
- package/dist/tools-logic/check.js +54 -44
- package/dist/tools-logic/check.js.map +1 -1
- package/dist/tools-logic/dream-admission.js +29 -29
- 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/recall-backend.d.ts.map +1 -1
- package/dist/tools-logic/recall-backend.js +3 -1
- package/dist/tools-logic/recall-backend.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 +63 -0
- package/dist/tools-logic/smart-recall.d.ts.map +1 -1
- package/dist/tools-logic/smart-recall.js +213 -31
- package/dist/tools-logic/smart-recall.js.map +1 -1
- package/dist/tools-logic/smart-remember-vector.d.ts +3 -1
- package/dist/tools-logic/smart-remember-vector.d.ts.map +1 -1
- package/dist/tools-logic/smart-remember-vector.js +3 -1
- package/dist/tools-logic/smart-remember-vector.js.map +1 -1
- package/dist/tools-logic/smart-remember.d.ts.map +1 -1
- package/dist/tools-logic/smart-remember.js +6 -2
- package/dist/tools-logic/smart-remember.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 +17 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +31 -3
- package/dist/types.js.map +1 -1
- package/dist/vector/embedding.d.ts +20 -1
- package/dist/vector/embedding.d.ts.map +1 -1
- package/dist/vector/embedding.js +27 -1
- package/dist/vector/embedding.js.map +1 -1
- package/dist/vector/local-vector-backend.d.ts +4 -1
- package/dist/vector/local-vector-backend.d.ts.map +1 -1
- package/dist/vector/local-vector-backend.js +7 -3
- package/dist/vector/local-vector-backend.js.map +1 -1
- package/package.json +59 -59
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* retrieval/activation.ts — evolution p3: ACT-R declarative memory
|
|
3
|
+
* activation, `A_i = B_i + Σ_j W_j·S_ji`.
|
|
4
|
+
*
|
|
5
|
+
* `B_i` (base activation: recency/frequency) ALREADY EXISTS as the per-tier
|
|
6
|
+
* scores every caller already computes — journal Ebbinghaus `S=2`
|
|
7
|
+
* (smart-recall.ts's MATH.md §b), palace salience/IDF, insight
|
|
8
|
+
* confirmation-count, rankCorrections' severity/proof_confidence/recency/
|
|
9
|
+
* proof composite (corrections.ts). This module does NOT re-derive any of
|
|
10
|
+
* those — it reads Phase 2's `association/edges.json`
|
|
11
|
+
* (`tools-logic/association.ts`, schema `assoc-edges/v1`) and computes ONLY
|
|
12
|
+
* the associative bonus `Σ_j W_j·S_ji`, `W_j = 1/|context|` (uniform),
|
|
13
|
+
* `S_ji = weight · exp(-days(asOfDay − last_seen)/S_DECAY)`.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IT IS: a cognitive-model bonus wired into TWO existing ranking
|
|
16
|
+
* pipelines, both flag-gated on `AGENT_RECALL_ACTIVATION=1` (default OFF —
|
|
17
|
+
* see `activationEnabled()`), following the exact template
|
|
18
|
+
* `retrieval/semantic-leg.ts` (fix7) already established for an opt-in leg:
|
|
19
|
+
* flag off ⇒ zero file read, zero behavior change, byte-identical output.
|
|
20
|
+
* (a) session_start correction ordering (`activationTieBreak`) — a
|
|
21
|
+
* TIE-BREAK applied strictly AFTER rankCorrections' own severity and
|
|
22
|
+
* proof_confidence keys; never reorders across a severity/confidence
|
|
23
|
+
* boundary, and the P0-always-survive budget logic downstream
|
|
24
|
+
* (session-start.ts's `applyCorrectionBudget`) is untouched — this
|
|
25
|
+
* function only reorders, never drops.
|
|
26
|
+
* (b) smart_recall post-RRF re-rank (`applyActivationRerank`) — a
|
|
27
|
+
* multiplicative boost on the fused top-K, `final_score = fused_score
|
|
28
|
+
* · (1 + ACT_ALPHA · normalized_activation)`.
|
|
29
|
+
*
|
|
30
|
+
* DIMENSIONAL-COHERENCE CHALLENGE (resolved, not silently mixed): (a) never
|
|
31
|
+
* combines activation with `B_i` numerically — it only compares
|
|
32
|
+
* `activationBonus` values against EACH OTHER to break a tie, so no
|
|
33
|
+
* cross-scale summation ever happens. (b) DOES mix scales (`fused_score` is
|
|
34
|
+
* an RRF-derived value on the `1/(60+r)` scale documented in MATH.md §b;
|
|
35
|
+
* `S_ji` is `weight · exp(...)`, an unrelated integer-ish scale) — see
|
|
36
|
+
* `applyActivationRerank`'s own doc comment for the explicit squashing
|
|
37
|
+
* normalization (`x/(x+1)`) that resolves this rather than adding the two
|
|
38
|
+
* incompatible scales directly (the exact class of bug smart-recall.ts's
|
|
39
|
+
* own header calls "Fix 1: incompatible scales").
|
|
40
|
+
*
|
|
41
|
+
* HAND-TUNED (documented per MATH.md convention, see packages/core/src/
|
|
42
|
+
* MATH.md §c — added alongside this module):
|
|
43
|
+
* - `S_DECAY = 30` days — chosen by feel (a month-ish co-activation
|
|
44
|
+
* memory), NOT fit to any recall/forget outcome data.
|
|
45
|
+
* - `ACT_ALPHA = 0.2` — chosen so the multiplicative boost can move a
|
|
46
|
+
* tied item by up to ×1.2 without ever vaulting a genuinely stronger
|
|
47
|
+
* fused_score item the way an uncapped multiplier could (same class of
|
|
48
|
+
* defect the hot-window boost's removal fixed, MATH.md §b) — not fit to
|
|
49
|
+
* a labeled relevance set.
|
|
50
|
+
*
|
|
51
|
+
* DEGRADATION CONTRACT (never throws, matches semantic-leg.ts's contract):
|
|
52
|
+
* missing/corrupt/wrong-shape `edges.json` → `loadAssocGraph` returns
|
|
53
|
+
* `null`; every consumer here treats `null` as "no signal", producing
|
|
54
|
+
* IDENTICAL results to today plus a diagnosable reason
|
|
55
|
+
* (`ActivationLegNote`, same shape family as `SemanticLegNote`).
|
|
56
|
+
*
|
|
57
|
+
* HOPFIELD — explicitly deferred (see this module's header once more, and
|
|
58
|
+
* the evolution p3 worker report): `palace/hopfield.ts` is a dense
|
|
59
|
+
* associative-memory primitive (attractor dynamics over a FULL similarity
|
|
60
|
+
* matrix). The `assoc-edges/v1` graph this module reads is SPARSE by
|
|
61
|
+
* construction (an edge exists only between corrections that were actually
|
|
62
|
+
* co-cited — most correction pairs in a real store have no edge at all).
|
|
63
|
+
* Feeding a sparse, mostly-zero adjacency into Hopfield's softmax-over-all-
|
|
64
|
+
* patterns update would spend its energy attending to a near-uniform
|
|
65
|
+
* distribution over non-edges, which is not the density Hopfield's
|
|
66
|
+
* exponential storage-capacity argument (Ramsauer et al. 2020) assumes.
|
|
67
|
+
* The linear ACT-R sum used here is the correct primitive for a sparse
|
|
68
|
+
* co-activation graph; Hopfield stays a documented, not-wired-in primitive.
|
|
69
|
+
*/
|
|
70
|
+
import * as fs from "node:fs";
|
|
71
|
+
import { assocNodeId, defaultEdgesPathFor, isAssocEdgesFile, } from "../tools-logic/association.js";
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Flag
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/** Opt-in env var. Default OFF — every integration point below must check
|
|
76
|
+
* this BEFORE reading any file (constraint: flag-off is byte-identical). */
|
|
77
|
+
export const ACTIVATION_FLAG_ENV = "AGENT_RECALL_ACTIVATION";
|
|
78
|
+
export function activationEnabled() {
|
|
79
|
+
return process.env[ACTIVATION_FLAG_ENV] === "1";
|
|
80
|
+
}
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// HAND-TUNED constants (see this file's header + MATH.md §c)
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
/** Decay half-life-ish constant (days) for S_ji = weight·exp(-days/S_DECAY). HAND-TUNED. */
|
|
85
|
+
export const S_DECAY = 30;
|
|
86
|
+
/** Multiplicative boost strength for the smart-recall integration point (2b). HAND-TUNED. */
|
|
87
|
+
export const ACT_ALPHA = 0.2;
|
|
88
|
+
/** How many of the fused/re-sorted top results the smart-recall integration re-ranks. */
|
|
89
|
+
const ACTIVATION_RERANK_K = 10;
|
|
90
|
+
/** Pure: turns an already-parsed, already-validated edges file into the
|
|
91
|
+
* adjacency structure the math functions below consume. No fs access. */
|
|
92
|
+
export function adjacencyFromEdgesFile(file) {
|
|
93
|
+
const adjacency = new Map();
|
|
94
|
+
for (const edge of file.edges) {
|
|
95
|
+
if (!adjacency.has(edge.a))
|
|
96
|
+
adjacency.set(edge.a, new Map());
|
|
97
|
+
if (!adjacency.has(edge.b))
|
|
98
|
+
adjacency.set(edge.b, new Map());
|
|
99
|
+
adjacency.get(edge.a).set(edge.b, edge);
|
|
100
|
+
adjacency.get(edge.b).set(edge.a, edge);
|
|
101
|
+
}
|
|
102
|
+
return { adjacency, edgeCount: file.edges.length };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Load the S_ji graph from `<storeRoot>/association/edges.json` (or an
|
|
106
|
+
* explicit path override — mirrors `readAssocEdgesFile`'s own signature).
|
|
107
|
+
* Missing file, unreadable file, unparseable JSON, or wrong-shape content
|
|
108
|
+
* all degrade to `null` — NEVER throws. Deliberately does NOT reuse
|
|
109
|
+
* `readAssocEdgesFile` (which collapses "missing" and "corrupt" into a
|
|
110
|
+
* silently-empty-but-valid file) because this function's degradation
|
|
111
|
+
* contract needs to tell "no graph at all" (null — callers report a
|
|
112
|
+
* diagnosable reason) apart from "a real, validly-empty graph" (an
|
|
113
|
+
* AssocGraph with 0 edges — a legitimate, if unusual, state after `ar assoc
|
|
114
|
+
* rebuild` runs against a store with zero cited events yet).
|
|
115
|
+
*/
|
|
116
|
+
export function loadAssocGraph(storeRoot, explicitPath) {
|
|
117
|
+
const p = explicitPath ?? defaultEdgesPathFor(storeRoot);
|
|
118
|
+
if (!fs.existsSync(p))
|
|
119
|
+
return null;
|
|
120
|
+
let raw;
|
|
121
|
+
try {
|
|
122
|
+
raw = fs.readFileSync(p, "utf-8");
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
let parsed;
|
|
128
|
+
try {
|
|
129
|
+
parsed = JSON.parse(raw);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (!isAssocEdgesFile(parsed))
|
|
135
|
+
return null;
|
|
136
|
+
return adjacencyFromEdgesFile(parsed);
|
|
137
|
+
}
|
|
138
|
+
/** Local-calendar-day string for "now" (matches session-start.ts's own "sv"
|
|
139
|
+
* locale convention for local-day bucketing — see e.g. its retrieved-outcome
|
|
140
|
+
* 1/day dedup guard). */
|
|
141
|
+
export function todayDayString() {
|
|
142
|
+
return new Date().toLocaleDateString("sv");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Whole-day difference between two `YYYY-MM-DD` strings, parsed as UTC
|
|
146
|
+
* midnight (so the result never drifts with the calling process's local
|
|
147
|
+
* timezone — load-bearing for the eval script's determinism requirement).
|
|
148
|
+
* Returns `null` on either unparseable string (degrade, never throw).
|
|
149
|
+
*/
|
|
150
|
+
function daysBetweenDayStrings(fromDay, toDay) {
|
|
151
|
+
const from = Date.parse(`${fromDay}T00:00:00Z`);
|
|
152
|
+
const to = Date.parse(`${toDay}T00:00:00Z`);
|
|
153
|
+
if (Number.isNaN(from) || Number.isNaN(to))
|
|
154
|
+
return null;
|
|
155
|
+
return Math.round((to - from) / 86_400_000);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* S_ji = weight · exp(-days(asOfDay − last_seen) / S_DECAY). HAND-TUNED
|
|
159
|
+
* S_DECAY (see this file's header). `days` is clamped at 0 (an edge whose
|
|
160
|
+
* `last_seen` is AFTER `asOfDay` — should never happen given the temporal
|
|
161
|
+
* split's own invariant, but this is a pure function with no knowledge of
|
|
162
|
+
* its caller's discipline, so it degrades to "no decay yet" rather than
|
|
163
|
+
* producing a >1 multiplier via a negative exponent). Malformed dates
|
|
164
|
+
* degrade to 0 (never throw).
|
|
165
|
+
*/
|
|
166
|
+
export function assocStrength(edge, asOfDay) {
|
|
167
|
+
const days = daysBetweenDayStrings(edge.last_seen, asOfDay);
|
|
168
|
+
if (days === null)
|
|
169
|
+
return 0;
|
|
170
|
+
return edge.weight * Math.exp(-Math.max(0, days) / S_DECAY);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* activationBonus(i) = Σ_j (1/|context|)·S_ji, summed over context items j
|
|
174
|
+
* that have an edge to i (context items without an edge to i contribute 0).
|
|
175
|
+
* `graph === null` (no graph loaded) or an empty context both degrade to 0
|
|
176
|
+
* — never throws, matches the module's degradation contract.
|
|
177
|
+
*/
|
|
178
|
+
export function activationBonus(candidateNodeId, contextNodeIds, graph, asOfDay) {
|
|
179
|
+
if (!graph || contextNodeIds.length === 0)
|
|
180
|
+
return 0;
|
|
181
|
+
const neighbors = graph.adjacency.get(candidateNodeId);
|
|
182
|
+
if (!neighbors)
|
|
183
|
+
return 0;
|
|
184
|
+
const w = 1 / contextNodeIds.length;
|
|
185
|
+
let sum = 0;
|
|
186
|
+
for (const j of contextNodeIds) {
|
|
187
|
+
if (j === candidateNodeId)
|
|
188
|
+
continue; // no self-loops in this graph by construction
|
|
189
|
+
const edge = neighbors.get(j);
|
|
190
|
+
if (!edge)
|
|
191
|
+
continue;
|
|
192
|
+
sum += w * assocStrength(edge, asOfDay);
|
|
193
|
+
}
|
|
194
|
+
return sum;
|
|
195
|
+
}
|
|
196
|
+
function effectiveConf(r) {
|
|
197
|
+
return r.proof_confidence ?? r.weight ?? 0;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Reorders `ranked` (already `rankCorrections()`'s output — severity ≫
|
|
201
|
+
* proof_confidence ≫ recency ≫ proof_count, corrections.ts) using
|
|
202
|
+
* activation as a TIE-BREAK strictly AFTER severity and proof_confidence:
|
|
203
|
+
* items are first partitioned into contiguous groups sharing the SAME
|
|
204
|
+
* (severity, effective proof_confidence) — rankCorrections' two
|
|
205
|
+
* highest-weighted keys — and activation only reorders WITHIN a group,
|
|
206
|
+
* never across one. `rankCorrections`' own recency/proof_count ordering
|
|
207
|
+
* survives as the STABLE fallback: with no graph (or zero bonus for every
|
|
208
|
+
* candidate) a group's relative order is preserved exactly.
|
|
209
|
+
*
|
|
210
|
+
* GREEDY, per the brief: `context` starts empty and grows by one node id
|
|
211
|
+
* per pick (within AND across tie-classes, in output order) — so the 2nd
|
|
212
|
+
* pick's activation score already "sees" the 1st pick, etc. This is a
|
|
213
|
+
* simple, deterministic sequential process, not a global optimization.
|
|
214
|
+
*
|
|
215
|
+
* Does NOT check `activationEnabled()` itself (testable in isolation) —
|
|
216
|
+
* callers (session-start.ts) must short-circuit before ever loading a graph
|
|
217
|
+
* or calling this function, so flag-off has zero file reads (constraint 1).
|
|
218
|
+
*/
|
|
219
|
+
export function activationTieBreak(ranked, opts) {
|
|
220
|
+
const { project, graph, asOfDay } = opts;
|
|
221
|
+
const result = [];
|
|
222
|
+
const context = [];
|
|
223
|
+
let i = 0;
|
|
224
|
+
while (i < ranked.length) {
|
|
225
|
+
let j = i;
|
|
226
|
+
while (j + 1 < ranked.length &&
|
|
227
|
+
ranked[j + 1].severity === ranked[i].severity &&
|
|
228
|
+
effectiveConf(ranked[j + 1]) === effectiveConf(ranked[i])) {
|
|
229
|
+
j++;
|
|
230
|
+
}
|
|
231
|
+
// Tie-class is ranked[i..j] — greedily reorder within it.
|
|
232
|
+
const pool = ranked.slice(i, j + 1).map((r) => r); // shallow copy, original relative order preserved as pool order
|
|
233
|
+
while (pool.length > 0) {
|
|
234
|
+
let bestPos = 0;
|
|
235
|
+
let bestScore = -Infinity;
|
|
236
|
+
for (let k = 0; k < pool.length; k++) {
|
|
237
|
+
const nodeId = assocNodeId(project, pool[k].id);
|
|
238
|
+
const score = activationBonus(nodeId, context, graph, asOfDay);
|
|
239
|
+
if (score > bestScore) {
|
|
240
|
+
bestScore = score;
|
|
241
|
+
bestPos = k; // first (= earliest original position) strictly-greater score wins ties
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const [chosen] = pool.splice(bestPos, 1);
|
|
245
|
+
result.push(chosen);
|
|
246
|
+
context.push(assocNodeId(project, chosen.id));
|
|
247
|
+
}
|
|
248
|
+
i = j + 1;
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Post-RRF (+ post-Beta-feedback-multiplier) re-rank of the fused top-K
|
|
254
|
+
* (K=10). Mutates `results` IN PLACE over its first `min(K, results.length)`
|
|
255
|
+
* entries only — items beyond K are left untouched.
|
|
256
|
+
*
|
|
257
|
+
* `final_score = fused_score · (1 + ACT_ALPHA · normalized_activation)`.
|
|
258
|
+
*
|
|
259
|
+
* NORMALIZATION (dimensional-coherence CHALLENGE, resolved — see this file's
|
|
260
|
+
* header): `fused_score` lives on the RRF scale (`1/(60+r)`, MATH.md §b);
|
|
261
|
+
* raw `activationBonus` lives on the `weight·exp(-days/30)` scale (roughly:
|
|
262
|
+
* an integer session-count, decayed) — summing these directly would repeat
|
|
263
|
+
* exactly the "Fix 1: incompatible scales" defect smart-recall.ts's own
|
|
264
|
+
* header documents for the pre-RRF linear-fusion bug. Instead the raw bonus
|
|
265
|
+
* is squashed through `x/(x+1)` into `[0,1)` BEFORE being used as a
|
|
266
|
+
* dimensionless multiplier — bounded regardless of how large a raw edge
|
|
267
|
+
* weight gets, needs no corpus-wide "max possible" scan (keeps this
|
|
268
|
+
* deterministic and simple, per the brief), and is 0 exactly when the raw
|
|
269
|
+
* bonus is 0 (zero signal ⇒ multiplier ⇒ ×1, an exact no-op).
|
|
270
|
+
*
|
|
271
|
+
* Context = the top-3 node ids BY FUSED SCORE (i.e. `results[0..2]` as they
|
|
272
|
+
* stand when this function is called — the SAME top-K, not the greedy
|
|
273
|
+
* growing context `activationTieBreak` uses for session_start; the brief
|
|
274
|
+
* specifies this context for smart_recall independently of 2a's).
|
|
275
|
+
*
|
|
276
|
+
* Degradation: no graph, or zero bonus for every top-K item → `results` is
|
|
277
|
+
* left COMPLETELY UNTOUCHED (not just "same order" — no mutation at all)
|
|
278
|
+
* and the returned note has `used: false` with a reason.
|
|
279
|
+
*/
|
|
280
|
+
export function applyActivationRerank(results, project, opts) {
|
|
281
|
+
const asOfDay = opts.asOfDay ?? todayDayString();
|
|
282
|
+
const graph = opts.graph !== undefined ? opts.graph : loadAssocGraph(opts.storeRoot);
|
|
283
|
+
if (!graph) {
|
|
284
|
+
return { enabled: true, used: false, reason: "no association graph (run `ar assoc rebuild`)" };
|
|
285
|
+
}
|
|
286
|
+
const k = Math.min(ACTIVATION_RERANK_K, results.length);
|
|
287
|
+
if (k === 0) {
|
|
288
|
+
return { enabled: true, used: false, reason: "no candidates" };
|
|
289
|
+
}
|
|
290
|
+
const top = results.slice(0, k);
|
|
291
|
+
const contextSize = Math.min(3, top.length);
|
|
292
|
+
const context = top.slice(0, contextSize).map((it) => assocNodeId(project, it.id));
|
|
293
|
+
let anyBonus = false;
|
|
294
|
+
const rescored = top.map((it, idx) => {
|
|
295
|
+
const nodeId = assocNodeId(project, it.id);
|
|
296
|
+
const bonus = activationBonus(nodeId, context, graph, asOfDay);
|
|
297
|
+
if (bonus > 0)
|
|
298
|
+
anyBonus = true;
|
|
299
|
+
const normalized = bonus / (bonus + 1); // squash — see doc comment above
|
|
300
|
+
return { it, idx, finalScore: it.score * (1 + ACT_ALPHA * normalized) };
|
|
301
|
+
});
|
|
302
|
+
if (!anyBonus) {
|
|
303
|
+
return { enabled: true, used: false, reason: "no edges among top candidates" };
|
|
304
|
+
}
|
|
305
|
+
rescored.sort((a, b) => b.finalScore - a.finalScore || a.idx - b.idx);
|
|
306
|
+
for (let pos = 0; pos < k; pos++) {
|
|
307
|
+
const { it, finalScore } = rescored[pos];
|
|
308
|
+
it.score = finalScore;
|
|
309
|
+
results[pos] = it;
|
|
310
|
+
}
|
|
311
|
+
return { enabled: true, used: true, reason: "activation-boosted top candidates" };
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../../src/retrieval/activation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAE9E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K,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;QACjC,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzC,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mCAAmC,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -218,6 +218,23 @@ export interface ReadTierCandidatesOpts {
|
|
|
218
218
|
* (resurrect.ts Source 2, smart-recall.ts's archiveSearch fallback).
|
|
219
219
|
*/
|
|
220
220
|
includeRawArchive?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* journal tier only (perf/lexical-index, 2026-10-16). When true, SKIPS the
|
|
223
|
+
* live and rollup-archive halves entirely and returns ONLY what
|
|
224
|
+
* `includeRawArchive` opted into — for callers that consume exclusively
|
|
225
|
+
* `sourceKind: "journal-archive-raw"` candidates (query-memory.ts's
|
|
226
|
+
* `queryArchiveFallback`, which previously paid a full live-journal
|
|
227
|
+
* read-and-trust-tag pass per low-confidence query only to `.filter()`
|
|
228
|
+
* every live/rollup candidate straight back out — ~0.8 s/query at 10k
|
|
229
|
+
* entries, the 2026-10-15 scale eval's p95 driver). Output is IDENTICAL
|
|
230
|
+
* to `readTierCandidates("journal", p, {includeRawArchive: true, ...})
|
|
231
|
+
* .filter((c) => c.sourceKind === "journal-archive-raw")` by construction
|
|
232
|
+
* (the raw half below is untouched; the skipped halves never produce
|
|
233
|
+
* raw-archive candidates) — pinned by lexical-index.test.mjs. A narrowing
|
|
234
|
+
* (subset) flag only: it can never ADD surface area, so the raw tier's
|
|
235
|
+
* opt-in safety property above is unchanged.
|
|
236
|
+
*/
|
|
237
|
+
rawArchiveOnly?: boolean;
|
|
221
238
|
/**
|
|
222
239
|
* palace-room tier only. When set, restricts to a single room slug
|
|
223
240
|
* (matches `palaceSearch`'s `input.room` filter). Omit to read every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/retrieval/candidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAUH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,wBAAwB,GACxB,qBAAqB,GACrB,aAAa,GACb,aAAa,CAAC;AAElB;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,oMAAoM;IACpM,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,IAAI,EAAE,UAAU,CAAC;IACjB,oIAAoI;IACpI,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,gJAAgJ;IAChJ,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,UAAU,EAAE,mBAAmB,CAAC;IAChC;;;;;;;;;OASG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,oBAAoB,C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G;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,sBAA2B,GAChC,aAAa,EAAE,CAYjB;AAmXD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,sBAA2B,GAChC,eAAe,EAAE,CAGnB"}
|
|
@@ -130,7 +130,9 @@ function readJournalCandidates(project, opts) {
|
|
|
130
130
|
// Deliberately called with includeArchive=false here — see the rollup-
|
|
131
131
|
// archive half below for why archive/ is scanned independently rather
|
|
132
132
|
// than via listJournalFiles(project, true).
|
|
133
|
-
|
|
133
|
+
// rawArchiveOnly (2026-10-16): a raw-archive-only caller skips this half
|
|
134
|
+
// (and the rollup half below) — see ReadTierCandidatesOpts.rawArchiveOnly.
|
|
135
|
+
const entries = opts.rawArchiveOnly ? [] : listJournalFiles(project, false);
|
|
134
136
|
for (const entry of entries) {
|
|
135
137
|
const sourcePath = path.join(entry.dir, entry.file);
|
|
136
138
|
const content = safeReadFile(sourcePath);
|
|
@@ -161,7 +163,7 @@ function readJournalCandidates(project, opts) {
|
|
|
161
163
|
// independently here, matching journal-search.ts's broader (no-date-match)
|
|
162
164
|
// filter, is what makes this reader an honest superset of BOTH existing
|
|
163
165
|
// scanners rather than silently inheriting the narrower one's gap.
|
|
164
|
-
if (opts.includeRollupArchive) {
|
|
166
|
+
if (opts.includeRollupArchive && !opts.rawArchiveOnly) {
|
|
165
167
|
const archiveDir = path.join(primaryDir, "archive");
|
|
166
168
|
let archiveFiles = [];
|
|
167
169
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.js","sourceRoot":"","sources":["../../src/retrieval/candidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;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,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -268,6 +268,48 @@ export interface ContradictionResult {
|
|
|
268
268
|
* pattern, ported verbatim from the plain extractor's callers).
|
|
269
269
|
*/
|
|
270
270
|
export declare function extractHighPrecisionVersionTokens(text: string): Map<string, string>;
|
|
271
|
+
/**
|
|
272
|
+
* 3.5.2 (2026-10-16) — marker-less `NUMBER unit per unit` rate-fact
|
|
273
|
+
* extractor, the grammar extension the 2026-10-15 rigorous eval's §7 item 2
|
|
274
|
+
* called for. Adversarial T5a proved the gap: "API rate limit set to 100
|
|
275
|
+
* requests per minute" vs "raised to 500 requests per minute" carries no
|
|
276
|
+
* `v/@/version` marker, so `extractHighPrecisionVersionTokens` extracts
|
|
277
|
+
* nothing, the stale fact gets no `supersededBy` annotation, and (under the
|
|
278
|
+
* hybrid leg, whose semantic votes carry no recency signal) the superseded
|
|
279
|
+
* 100-limit deterministically outranked its own replacement.
|
|
280
|
+
*
|
|
281
|
+
* PRECISION ANCHOR — why this is NOT the removed kv/status/bare-number
|
|
282
|
+
* grammar coming back (W5a salvage HIGH-1/HIGH-2; STEP 4b): the full
|
|
283
|
+
* `<number> <unit-word> per <unit-word>` frame is required, making the match
|
|
284
|
+
* self-describing the same way the mandatory version marker is:
|
|
285
|
+
* - a bare count ("30 days", "3 files", "two pages") has no `per` → no token;
|
|
286
|
+
* - "$5 per user" (number directly before `per`, no unit word between) → no
|
|
287
|
+
* token — the unit word is mandatory;
|
|
288
|
+
* - IPs / dot-dates / dotted step numbers ("10.0.0.1", "08.15.2026",
|
|
289
|
+
* "step 1.2.3") never present a whitespace-separated `N unit per unit`
|
|
290
|
+
* frame, and the `(?<![\d.])` lookbehind stops a dotted run's tail
|
|
291
|
+
* digits from posing as the number;
|
|
292
|
+
* - the TWO-word key (`unit-per-unit`, e.g. `request-per-minute`) gives
|
|
293
|
+
* the topical protection the removed one-word kv keys ("priority",
|
|
294
|
+
* "env") never had.
|
|
295
|
+
* Residual risk, accepted and documented like the version branch's own
|
|
296
|
+
* 4-component-semver note: two topically-DIFFERENT facts that share an
|
|
297
|
+
* identical rate frame ("ingested 100 records per day" vs "exported 500
|
|
298
|
+
* records per day") can still collide when both match the same query within
|
|
299
|
+
* one tier's top candidates AND carry different dates. The blast radius is
|
|
300
|
+
* the bounded relative cap (see query-memory.ts's `applySupersessionCap`) —
|
|
301
|
+
* both items are still returned and annotated, never dropped — not the
|
|
302
|
+
* global ×0.5 inversion class STEP 4a removed.
|
|
303
|
+
*
|
|
304
|
+
* Values are numeric-normalized (`String(Number(...))`: "500" === "500.0")
|
|
305
|
+
* and keys unit-normalized (see `normalizeRateUnit`). Same Map semantics as
|
|
306
|
+
* the version extractor: a later mention of the same key within ONE text
|
|
307
|
+
* overwrites the earlier one.
|
|
308
|
+
*
|
|
309
|
+
* EXPORTED for direct unit-testing (the `extractHighPrecisionVersionTokens`
|
|
310
|
+
* precedent) and for any future `conflict-scan.ts`-style consumer.
|
|
311
|
+
*/
|
|
312
|
+
export declare function extractRateFactTokens(text: string): Map<string, string>;
|
|
271
313
|
/**
|
|
272
314
|
* Pairwise contradiction scan over one tier's candidate list. O(n²) — the
|
|
273
315
|
* caller (query-memory.ts) is expected to run this AFTER tokenize+score
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contradiction.d.ts","sourceRoot":"","sources":["../../src/retrieval/contradiction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiMG;AAcH;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,IAAI,EAAE,MAAM,C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;;;;;;GAwCG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAcvE;AA2BD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,mBAAmB,CAmCpF"}
|
|
@@ -222,13 +222,26 @@
|
|
|
222
222
|
*/
|
|
223
223
|
function grammarConflict(a, b) {
|
|
224
224
|
const av = extractHighPrecisionVersionTokens(a.text);
|
|
225
|
-
if (av.size
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
if (av.size > 0) {
|
|
226
|
+
const bv = extractHighPrecisionVersionTokens(b.text);
|
|
227
|
+
for (const [key, val] of av) {
|
|
228
|
+
const bval = bv.get(key);
|
|
229
|
+
if (bval && bval !== val)
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// 3.5.2 (2026-10-16, adversarial T5a — see extractRateFactTokens below):
|
|
234
|
+
// marker-less `NUMBER unit per unit` rate facts join the grammar as a
|
|
235
|
+
// SECOND, independently-anchored branch. Same comparison discipline as the
|
|
236
|
+
// version branch: shared fact-key + differing value → conflict.
|
|
237
|
+
const ar = extractRateFactTokens(a.text);
|
|
238
|
+
if (ar.size > 0) {
|
|
239
|
+
const br = extractRateFactTokens(b.text);
|
|
240
|
+
for (const [key, val] of ar) {
|
|
241
|
+
const bval = br.get(key);
|
|
242
|
+
if (bval && bval !== val)
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
232
245
|
}
|
|
233
246
|
return false;
|
|
234
247
|
}
|
|
@@ -275,6 +288,112 @@ export function extractHighPrecisionVersionTokens(text) {
|
|
|
275
288
|
}
|
|
276
289
|
return result;
|
|
277
290
|
}
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
// 3.5.2 rate-fact grammar (2026-10-16, adversarial T5a,
|
|
293
|
+
// reports/2026-10-15-rigorous-eval.md Finding 2 / §7 item 2)
|
|
294
|
+
// ---------------------------------------------------------------------------
|
|
295
|
+
/**
|
|
296
|
+
* 3.5.2 UNIT NORMALIZATION for `extractRateFactTokens` — maps common
|
|
297
|
+
* abbreviations onto their full word and strips a plural `s`, so
|
|
298
|
+
* "50 req per min" and "75 requests per minute" produce the SAME fact-key.
|
|
299
|
+
* Deliberately tiny: only the unambiguous time/request abbreviations that
|
|
300
|
+
* appear in ordinary rate-limit prose. Plural stripping is length-gated
|
|
301
|
+
* (≥4 chars, not `ss`-final) so short abbreviations that END in `s` by
|
|
302
|
+
* construction ("rps", "ms", "qps") are never mangled into non-words.
|
|
303
|
+
*/
|
|
304
|
+
const RATE_UNIT_ALIASES = {
|
|
305
|
+
min: "minute",
|
|
306
|
+
mins: "minute",
|
|
307
|
+
sec: "second",
|
|
308
|
+
secs: "second",
|
|
309
|
+
hr: "hour",
|
|
310
|
+
hrs: "hour",
|
|
311
|
+
req: "request",
|
|
312
|
+
reqs: "request",
|
|
313
|
+
};
|
|
314
|
+
function normalizeRateUnit(word) {
|
|
315
|
+
const w = word.toLowerCase();
|
|
316
|
+
const aliased = RATE_UNIT_ALIASES[w];
|
|
317
|
+
if (aliased)
|
|
318
|
+
return aliased;
|
|
319
|
+
if (w.length >= 4 && w.endsWith("s") && !w.endsWith("ss"))
|
|
320
|
+
return w.slice(0, -1);
|
|
321
|
+
return w;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* MEDIUM-1 (review fix, 2026-10-16, reports/2026-10-16-review-correctness.md)
|
|
325
|
+
* — GENERIC-FREQUENCY DENYLIST for the COUNTED-NOUN position. "ran 5 times
|
|
326
|
+
* per day" vs "retried 3 times per day" produced a cross-topic supersession:
|
|
327
|
+
* `time-per-<period>` is the single most common `N unit per unit` frame in
|
|
328
|
+
* ordinary narrative prose and carries near-zero topical signal — W5a
|
|
329
|
+
* HIGH-2's generic one-word key recurring in two-word form for exactly this
|
|
330
|
+
* unit family. Genuine rate-limit facts name the RESOURCE noun ("requests",
|
|
331
|
+
* "jobs", "records"); "N times per day" is almost always narrative.
|
|
332
|
+
* Checked POST-normalization ("times" → "time", "occurrences" →
|
|
333
|
+
* "occurrence"), counted-noun position only — the `per <period>` side is
|
|
334
|
+
* untouched. Deliberately tiny, like RATE_UNIT_ALIASES: extend it only with
|
|
335
|
+
* units that are generic FREQUENCY words, never resource nouns.
|
|
336
|
+
* Scalar-noun generalization (ports/timeouts/etc.) is a separate, later
|
|
337
|
+
* branch — see the review's "Brief questions answered" section.
|
|
338
|
+
*/
|
|
339
|
+
const RATE_UNIT_DENYLIST = new Set(["time", "occurrence"]);
|
|
340
|
+
/**
|
|
341
|
+
* 3.5.2 (2026-10-16) — marker-less `NUMBER unit per unit` rate-fact
|
|
342
|
+
* extractor, the grammar extension the 2026-10-15 rigorous eval's §7 item 2
|
|
343
|
+
* called for. Adversarial T5a proved the gap: "API rate limit set to 100
|
|
344
|
+
* requests per minute" vs "raised to 500 requests per minute" carries no
|
|
345
|
+
* `v/@/version` marker, so `extractHighPrecisionVersionTokens` extracts
|
|
346
|
+
* nothing, the stale fact gets no `supersededBy` annotation, and (under the
|
|
347
|
+
* hybrid leg, whose semantic votes carry no recency signal) the superseded
|
|
348
|
+
* 100-limit deterministically outranked its own replacement.
|
|
349
|
+
*
|
|
350
|
+
* PRECISION ANCHOR — why this is NOT the removed kv/status/bare-number
|
|
351
|
+
* grammar coming back (W5a salvage HIGH-1/HIGH-2; STEP 4b): the full
|
|
352
|
+
* `<number> <unit-word> per <unit-word>` frame is required, making the match
|
|
353
|
+
* self-describing the same way the mandatory version marker is:
|
|
354
|
+
* - a bare count ("30 days", "3 files", "two pages") has no `per` → no token;
|
|
355
|
+
* - "$5 per user" (number directly before `per`, no unit word between) → no
|
|
356
|
+
* token — the unit word is mandatory;
|
|
357
|
+
* - IPs / dot-dates / dotted step numbers ("10.0.0.1", "08.15.2026",
|
|
358
|
+
* "step 1.2.3") never present a whitespace-separated `N unit per unit`
|
|
359
|
+
* frame, and the `(?<![\d.])` lookbehind stops a dotted run's tail
|
|
360
|
+
* digits from posing as the number;
|
|
361
|
+
* - the TWO-word key (`unit-per-unit`, e.g. `request-per-minute`) gives
|
|
362
|
+
* the topical protection the removed one-word kv keys ("priority",
|
|
363
|
+
* "env") never had.
|
|
364
|
+
* Residual risk, accepted and documented like the version branch's own
|
|
365
|
+
* 4-component-semver note: two topically-DIFFERENT facts that share an
|
|
366
|
+
* identical rate frame ("ingested 100 records per day" vs "exported 500
|
|
367
|
+
* records per day") can still collide when both match the same query within
|
|
368
|
+
* one tier's top candidates AND carry different dates. The blast radius is
|
|
369
|
+
* the bounded relative cap (see query-memory.ts's `applySupersessionCap`) —
|
|
370
|
+
* both items are still returned and annotated, never dropped — not the
|
|
371
|
+
* global ×0.5 inversion class STEP 4a removed.
|
|
372
|
+
*
|
|
373
|
+
* Values are numeric-normalized (`String(Number(...))`: "500" === "500.0")
|
|
374
|
+
* and keys unit-normalized (see `normalizeRateUnit`). Same Map semantics as
|
|
375
|
+
* the version extractor: a later mention of the same key within ONE text
|
|
376
|
+
* overwrites the earlier one.
|
|
377
|
+
*
|
|
378
|
+
* EXPORTED for direct unit-testing (the `extractHighPrecisionVersionTokens`
|
|
379
|
+
* precedent) and for any future `conflict-scan.ts`-style consumer.
|
|
380
|
+
*/
|
|
381
|
+
export function extractRateFactTokens(text) {
|
|
382
|
+
const result = new Map();
|
|
383
|
+
const pattern = /(?<![\d.])(\d+(?:\.\d+)?)\s+([a-z][a-z-]{0,30})\s+per\s+([a-z][a-z-]{0,30})\b/gi;
|
|
384
|
+
let m;
|
|
385
|
+
while ((m = pattern.exec(text)) !== null) {
|
|
386
|
+
const unit = normalizeRateUnit(m[2]);
|
|
387
|
+
// MEDIUM-1 review fix — see RATE_UNIT_DENYLIST above: a generic
|
|
388
|
+
// frequency word in the counted-noun position is narrative, not a fact.
|
|
389
|
+
if (RATE_UNIT_DENYLIST.has(unit))
|
|
390
|
+
continue;
|
|
391
|
+
const value = String(Number(m[1]));
|
|
392
|
+
const key = `${unit}-per-${normalizeRateUnit(m[3])}`;
|
|
393
|
+
result.set(key, value);
|
|
394
|
+
}
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
278
397
|
function resolveDirection(a, b) {
|
|
279
398
|
if (a.date && b.date) {
|
|
280
399
|
const da = Date.parse(a.date);
|