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,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* implicit-harvest.ts — evolution p1b (Phase 1b): `ar corrections harvest-implicit`.
|
|
3
|
+
*
|
|
4
|
+
* Capture density is the measured ceiling (p1a: 35.3% capture recall, every
|
|
5
|
+
* miss was hook-no-fire coverage — the human corrected, the hook never ran).
|
|
6
|
+
* Implicit signals raise events/week ~10x over the explicit human_correction
|
|
7
|
+
* channel: most real corrections in a transcript never take the imperative
|
|
8
|
+
* shape check.ts's structured form requires ("No, that's wrong" / "还是不对,
|
|
9
|
+
* 用 X" / repeating the same instruction a second time because the first was
|
|
10
|
+
* ignored). This module mines those THREE conservative, high-precision
|
|
11
|
+
* patterns over USER turns only:
|
|
12
|
+
*
|
|
13
|
+
* (a) negation opener — a turn that OPENS with a negation/correction marker
|
|
14
|
+
* ("no,", "不对", "not that", "i said", "停", ...) followed by ≥4 more
|
|
15
|
+
* words of actual re-instruction. The re-instruction (opener stripped)
|
|
16
|
+
* is the candidate rule.
|
|
17
|
+
* (b) again-marker — a turn containing a recurrence marker ("again", "还是",
|
|
18
|
+
* "第二次", "怎么又") AND a minimal imperative-ish verb ("use", "don't",
|
|
19
|
+
* "应该", "改成", ...). The sentence carrying the verb is the candidate
|
|
20
|
+
* rule (the recurrence marker is corroborating evidence, not the rule
|
|
21
|
+
* text itself).
|
|
22
|
+
* (c) repeat-instruction — two ≥6-word user turns in the SAME session whose
|
|
23
|
+
* token-Jaccard similarity is ≥0.6 (the human said essentially the same
|
|
24
|
+
* thing twice because the first time didn't land). The SECOND
|
|
25
|
+
* occurrence is the candidate rule.
|
|
26
|
+
*
|
|
27
|
+
* Fix round 3 (orchestrator decision, data-driven — real 48-day window):
|
|
28
|
+
* signal (b) again-marker was measured at 0 true positives / 2 false
|
|
29
|
+
* positives over that window, both from the SAME structural mechanism
|
|
30
|
+
* (voice-dictation run-on monologues where "again" is an ordinary temporal
|
|
31
|
+
* adverb, not a recurrence report — see the AGAIN_MARKER gating comment
|
|
32
|
+
* below for why fix round 1's "same sentence" proximity fix doesn't rescue
|
|
33
|
+
* this population). The only genuine true positive across the window came
|
|
34
|
+
* from signal (a) negation-opener. DEFAULT is now **signal (a) ONLY**;
|
|
35
|
+
* signals (b) and (c) both live behind the same `experimentalSignals` opt-in
|
|
36
|
+
* — neither deleted, both structurally available for a caller who wants
|
|
37
|
+
* them (see ImplicitHarvestOptions.experimentalSignals' doc comment).
|
|
38
|
+
*
|
|
39
|
+
* Everything this produces is PROVISIONAL by construction and carries a hard
|
|
40
|
+
* humility contract, enforced structurally (not by convention):
|
|
41
|
+
* - severity is ALWAYS "p1" — literally never derived, never "p0". Because
|
|
42
|
+
* writeCorrection only auto-detects severity when the caller omits it
|
|
43
|
+
* (`correction.severity ?? detectSeverity(...)`), setting it explicitly
|
|
44
|
+
* here means detectSeverity is never even consulted for these records —
|
|
45
|
+
* an implicit record can never enter session_start's P0 section
|
|
46
|
+
* (readP0Corrections filters on severity==="p0") no matter how strong the
|
|
47
|
+
* underlying language looks. See implicit-harvest.test.mjs's watch-tier
|
|
48
|
+
* isolation test.
|
|
49
|
+
* - weight 0.3 / confidence "low" / provenance {source:"transcript-implicit",
|
|
50
|
+
* mode:"observed"} / tags ["implicit"] — every downstream KPI/ranking
|
|
51
|
+
* surface (rankCorrections, getCorrectionKPIs, heed-tiers.ts) reads only
|
|
52
|
+
* severity/weight/proof_confidence/recency/proof_count/outcome-ledger
|
|
53
|
+
* events, NEVER provenance.source — so these records fall exactly where
|
|
54
|
+
* an ordinary low-authority p1 correction would, no special-casing either
|
|
55
|
+
* direction (verified, not assumed — see the same isolation test).
|
|
56
|
+
*
|
|
57
|
+
* REUSE, not a second walker: `scanTranscripts` (day-bucketed line scan,
|
|
58
|
+
* per-file F1 project resolution, mtime-fallback ambiguity handling) and
|
|
59
|
+
* `resolveDayRange` (--date XOR --backfill --since/--until) are p1a's own
|
|
60
|
+
* exported machinery (packages/core/src/tools-logic/transcript-audit.ts),
|
|
61
|
+
* unmodified. This module only adds a DIFFERENT extraction shape over the
|
|
62
|
+
* same day-bucketed lines — ordered user/assistant turn pairing instead of
|
|
63
|
+
* one concatenated blob — built from the SAME exported per-record filters
|
|
64
|
+
* (isBoilerplateRecord/isSystemText/textFromContent,
|
|
65
|
+
* packages/core/src/helpers/transcript-project.ts) transcript-audit.ts's own
|
|
66
|
+
* extractDayText uses internally. That shape difference is required because
|
|
67
|
+
* signals (a)/(b) need the immediately-preceding assistant sentence and
|
|
68
|
+
* signal (c) needs ORDERED, DISCRETE messages to pair — a single flattened
|
|
69
|
+
* string can supply neither.
|
|
70
|
+
*
|
|
71
|
+
* Storage is exclusively through the canonical `writeCorrection` path
|
|
72
|
+
* (packages/core/src/storage/corrections.ts) — never a hand-rolled file
|
|
73
|
+
* write — so on-write consolidation (token-identical rule merge), atomic
|
|
74
|
+
* write, and materialized-index regeneration are shared with every other
|
|
75
|
+
* correction producer. `writeCorrection`'s ONLY gate was previously the fused
|
|
76
|
+
* hard-noise + actionable-imperative-shape + soft-acknowledgment gate
|
|
77
|
+
* (`isLikelyRealCorrection`) with no seam to run the hard-noise floor alone —
|
|
78
|
+
* see `WriteCorrectionOptions.skipActionableGate`'s doc comment in
|
|
79
|
+
* corrections.ts for why a seam (not a fork, not a refactor of the
|
|
80
|
+
* precision-tuned gate internals) was the minimal fix, and why running the
|
|
81
|
+
* FULL gate on implicit candidates would have rejected almost every
|
|
82
|
+
* negation-opener candidate as a "pure acknowledgment" (the exact Loop-7
|
|
83
|
+
* failure the actionable-scan rescue exists to prevent, replayed from the
|
|
84
|
+
* opposite side once that rescue is skipped).
|
|
85
|
+
*/
|
|
86
|
+
export interface ImplicitHarvestOptions {
|
|
87
|
+
/** Single harvest day, YYYY-MM-DD. Mutually exclusive with since/until. */
|
|
88
|
+
date?: string;
|
|
89
|
+
/** Backfill range start (inclusive), YYYY-MM-DD. Requires --backfill semantics upstream. */
|
|
90
|
+
since?: string;
|
|
91
|
+
/** Backfill range end (inclusive), YYYY-MM-DD. Defaults to today (local-TZ) when since is set. */
|
|
92
|
+
until?: string;
|
|
93
|
+
/** Restrict to one project slug (or alias — resolved the same way every other CLI --project is). */
|
|
94
|
+
project?: string;
|
|
95
|
+
/** Override the Claude Code transcript directory (default: same dir transcript-reader.ts / transcript-audit.ts use). */
|
|
96
|
+
claudeDir?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Explicit opt-in to actually write corrections. Default false — dry-run is
|
|
99
|
+
* the DEFAULT per the brief's own flag contract, never the opposite.
|
|
100
|
+
*/
|
|
101
|
+
write?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Fix round 2 (post-review): signal (c) repeat-instruction was DROPPED
|
|
104
|
+
* from the shipped default after measuring precision on the real 14-day
|
|
105
|
+
* window (2026-09-03..2026-09-17) — own-judgment review of every
|
|
106
|
+
* would_write candidate found 2 of 3 repeat-instruction hits were false
|
|
107
|
+
* positives from TWO distinct, structurally-recurring mechanisms, neither
|
|
108
|
+
* specific to this one sample:
|
|
109
|
+
* 1. Iterative document dictation — a human drafting a report (or any
|
|
110
|
+
* long-form text) interactively naturally repeats/re-pastes their own
|
|
111
|
+
* prior paragraph verbatim as they build it up turn by turn. This is
|
|
112
|
+
* indistinguishable from "the correction didn't land" by Jaccard
|
|
113
|
+
* similarity alone — the CONTENT is identical, but the human is not
|
|
114
|
+
* re-issuing an ignored instruction to the ASSISTANT.
|
|
115
|
+
* 2. A pasted/echoed terminal artifact (a shell-prompt fragment,
|
|
116
|
+
* "❯...", duplicated by an accidental double-paste or terminal echo)
|
|
117
|
+
* clearing the ≥6-word/Jaccard≥0.6 bar on pure noise.
|
|
118
|
+
* Per the brief's own pre-authorized policy ("precision over recall is the
|
|
119
|
+
* first constraint... progressively DROP whole signal families... until
|
|
120
|
+
* the surviving default clears 70%"): dropping (c) raised the window's
|
|
121
|
+
* measured precision from 2/4 (50%, below the 60% floor) to 1/1 (100%,
|
|
122
|
+
* the negation-opener hit — a genuine business-scope
|
|
123
|
+
* correction). Kept recoverable (not deleted) behind this explicit
|
|
124
|
+
* opt-in — trivial to keep, and the mechanism has a real, if narrower,
|
|
125
|
+
* use case (an exact-duplicate resend IS sometimes a genuine ignored
|
|
126
|
+
* correction, as candidate 2 in that same sample showed).
|
|
127
|
+
*
|
|
128
|
+
* Fix round 3 (orchestrator decision, data-driven, judge-confirmed): over a
|
|
129
|
+
* SEPARATE, longer real window (48 days), signal (b) again-marker
|
|
130
|
+
* contributed 0 true positives and 2 false positives — both from ONE
|
|
131
|
+
* structural mechanism: voice-dictation run-on monologues where "again" is
|
|
132
|
+
* an ordinary temporal adverb ("we talked about this again last week...")
|
|
133
|
+
* and an unrelated MINIMAL_VERB match happens to fall in the same
|
|
134
|
+
* unpunctuated blob. This is not incidental to one sample — the owner is a
|
|
135
|
+
* heavy voice-dictation user, so this input shape recurs structurally.
|
|
136
|
+
* The only genuine true positive over the SAME 48-day window came from
|
|
137
|
+
* signal (a) negation-opener. Per the identical "drop the family instead of
|
|
138
|
+
* re-patching the regex a third time" policy already applied to (c): signal
|
|
139
|
+
* (b) now ALSO requires `experimentalSignals: true` — not deleted, not
|
|
140
|
+
* regex-patched again (a same-sentence proximity fix cannot rescue this
|
|
141
|
+
* population; a dictation monologue with no terminal punctuation IS one
|
|
142
|
+
* sentence by `splitSentences()`'s own contract, so "same sentence" and
|
|
143
|
+
* "same turn" collapse to the same test for exactly this population). CLI
|
|
144
|
+
* flag/option name unchanged (`experimentalSignals` / `--experimental-
|
|
145
|
+
* signals`) — it now gates BOTH non-default signals (b) and (c), not (c)
|
|
146
|
+
* alone. Default false; DEFAULT harvest is signal (a) ONLY.
|
|
147
|
+
*/
|
|
148
|
+
experimentalSignals?: boolean;
|
|
149
|
+
}
|
|
150
|
+
export type ImplicitHarvestSignal = "negation" | "again" | "repeat";
|
|
151
|
+
export type ImplicitHarvestOutcome = "written" | "merged" | "gated" | "capped" | "would_write";
|
|
152
|
+
export interface ImplicitHarvestCandidate {
|
|
153
|
+
date: string;
|
|
154
|
+
project: string;
|
|
155
|
+
/** Transcript basename (session id) this candidate was mined from. */
|
|
156
|
+
session: string;
|
|
157
|
+
signal: ImplicitHarvestSignal;
|
|
158
|
+
/** ≤200 chars, trimmed — the corrective content that would become CorrectionRecord.rule. */
|
|
159
|
+
rule: string;
|
|
160
|
+
/** ≤150 chars, trimmed — the preceding assistant sentence (may be empty). */
|
|
161
|
+
context: string;
|
|
162
|
+
outcome: ImplicitHarvestOutcome;
|
|
163
|
+
reason?: string;
|
|
164
|
+
correction_id?: string;
|
|
165
|
+
}
|
|
166
|
+
export interface ImplicitHarvestDaySummary {
|
|
167
|
+
date: string;
|
|
168
|
+
sessions_scanned: number;
|
|
169
|
+
/** RAW detection counts per signal type, BEFORE the per-session cap or any gate. */
|
|
170
|
+
candidates_by_signal: Record<ImplicitHarvestSignal, number>;
|
|
171
|
+
/** Candidates dropped purely for exceeding the 5/session cap (never gate-checked). */
|
|
172
|
+
capped: number;
|
|
173
|
+
/** Candidates that failed the hard-noise gate (dropHardNoise) — logged to _rejected.jsonl, reason "implicit-gate". */
|
|
174
|
+
gated_out: number;
|
|
175
|
+
/** Brand-new correction files written this run. */
|
|
176
|
+
written: number;
|
|
177
|
+
/** Candidates folded into an existing active correction (on-write consolidation). */
|
|
178
|
+
dedup_merged: number;
|
|
179
|
+
/** Session basenames whose resolved project could not be determined ("auto") — never harvested. */
|
|
180
|
+
unresolved_project_sessions: string[];
|
|
181
|
+
/** Every raw candidate detected this day, in chronological (session, turn) order. */
|
|
182
|
+
candidates: ImplicitHarvestCandidate[];
|
|
183
|
+
}
|
|
184
|
+
export interface ImplicitHarvestResult {
|
|
185
|
+
dry_run: boolean;
|
|
186
|
+
claude_dir: string;
|
|
187
|
+
days: ImplicitHarvestDaySummary[];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* `ar corrections harvest-implicit` — see this file's header doc.
|
|
191
|
+
*
|
|
192
|
+
* Dry-run by DEFAULT (`options.write` must be explicitly true to touch disk)
|
|
193
|
+
* — matches the brief's flag contract exactly, not the opposite.
|
|
194
|
+
*/
|
|
195
|
+
export declare function runImplicitHarvest(options: ImplicitHarvestOptions): Promise<ImplicitHarvestResult>;
|
|
196
|
+
//# sourceMappingURL=implicit-harvest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implicit-harvest.d.ts","sourceRoot":"","sources":["../../src/tools-logic/implicit-harvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AA0BH,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,IAAI,CAAC,EAAE,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