counterparts 0.1.0
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/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every prospective knob, in one visible place — the shape `physics/` and
|
|
3
|
+
* `recall/` use, for the same reason: a threshold hiding in a function body
|
|
4
|
+
* cannot be audited.
|
|
5
|
+
*
|
|
6
|
+
* **CAL = calibration-required** (scar §2.8, CONTRACT §4: "v1's knob set is not
|
|
7
|
+
* inherited as defaults"). The numbers below ARE v1's live §12 values, carried as
|
|
8
|
+
* the recorded starting point and nothing more — a starting point, not a v2
|
|
9
|
+
* measurement. `tools/replay` is where each one gets re-earned, and PR-A..PR-F are
|
|
10
|
+
* the bar that must pass before this channel turns on at all.
|
|
11
|
+
*
|
|
12
|
+
* **Structural** (never tunable, never ablatable): no bypass lane; prospectivity
|
|
13
|
+
* derived, never stored; the exclusions; the footnote cap; referenced-stop; the
|
|
14
|
+
* window as the firing key; observer no-advance.
|
|
15
|
+
*/
|
|
16
|
+
import type { UseTier } from "../physics/index.js";
|
|
17
|
+
import { TUNABLES as PHYSICS } from "../physics/index.js";
|
|
18
|
+
|
|
19
|
+
export interface ProspectiveTunables {
|
|
20
|
+
/** Salience below this never becomes prospective, however well dated.
|
|
21
|
+
* Salience, NOT strength: eligibility is a predicate over the event date, the
|
|
22
|
+
* encode date, salience and flags (§12 G2), and a decay exemption before
|
|
23
|
+
* arrival is exactly what G10 forbids. [v1: 0.6] CAL. */
|
|
24
|
+
SALIENCE_FLOOR: number;
|
|
25
|
+
/** Calendar days before the event the window opens. [v1: 3] CAL. */
|
|
26
|
+
LEAD_DAYS: number;
|
|
27
|
+
/** Calendar days after the event (or after month end) the window stays open —
|
|
28
|
+
* the post-window grace beat, whose warmth is open question 1. [v1: 7] CAL. */
|
|
29
|
+
GRACE_DAYS: number;
|
|
30
|
+
/** Weight a temporal cue carries into `recall/`'s cue stage, before the ramp
|
|
31
|
+
* scales it. It is ONE MORE CUE, never a channel of its own. [v1: 0.5] CAL. */
|
|
32
|
+
CUE_STRENGTH: number;
|
|
33
|
+
/** Cap on ambient fires per window — brake 2 of four. [v1: 2] CAL. */
|
|
34
|
+
FIRES_PER_WINDOW: number;
|
|
35
|
+
/** Arrivals offered to the wake horizon. [v1: 2 lines] CAL. */
|
|
36
|
+
HORIZON_ITEMS: number;
|
|
37
|
+
/** Ramp intensity on the day the window opens: a plan three days out means
|
|
38
|
+
* something, just less than the day itself. CAL, and with no v1 ancestry —
|
|
39
|
+
* v1 recorded lead DAYS, never a shape. */
|
|
40
|
+
RAMP_OPEN: number;
|
|
41
|
+
/** Ramp intensity on the last grace day. CAL, same provenance gap. */
|
|
42
|
+
RAMP_CLOSE: number;
|
|
43
|
+
/** Strength at or below which an unfired, closed window exits as FADED rather
|
|
44
|
+
* than EXPIRED (§5 G12's four named exits). Defaults to physics' prune floor:
|
|
45
|
+
* one rule, one owner. CAL by inheritance — PHI_PRUNE is itself uncalibrated. */
|
|
46
|
+
FADED_STRENGTH: number;
|
|
47
|
+
/** Bound on the in-process session-dedup set (INTERFACE-GAPS #3). */
|
|
48
|
+
MAX_SESSION_WINDOWS: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* §12 G5 / CONTRACT §5 G4: **a temporal cue alone reaches the footnote tier at
|
|
53
|
+
* most.** Not a tunable — the ceiling is the guarantee.
|
|
54
|
+
*/
|
|
55
|
+
export const TEMPORAL_MAX_TIER: UseTier = "footnoted";
|
|
56
|
+
|
|
57
|
+
export const TUNABLES: ProspectiveTunables = {
|
|
58
|
+
SALIENCE_FLOOR: 0.6,
|
|
59
|
+
LEAD_DAYS: 3,
|
|
60
|
+
GRACE_DAYS: 7,
|
|
61
|
+
CUE_STRENGTH: 0.5,
|
|
62
|
+
FIRES_PER_WINDOW: 2,
|
|
63
|
+
HORIZON_ITEMS: 2,
|
|
64
|
+
RAMP_OPEN: 0.4,
|
|
65
|
+
RAMP_CLOSE: 0.2,
|
|
66
|
+
FADED_STRENGTH: PHYSICS.PHI_PRUNE,
|
|
67
|
+
MAX_SESSION_WINDOWS: 200,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export function withTunables(overrides: Partial<ProspectiveTunables> = {}): ProspectiveTunables {
|
|
71
|
+
return { ...TUNABLES, ...overrides };
|
|
72
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows — the arithmetic of "has the remembered future arrived yet".
|
|
3
|
+
*
|
|
4
|
+
* **Precision is carried by the date's own shape, never rounded** (§12 G4): a
|
|
5
|
+
* `2026-09` stays a month for its whole life and is never quietly turned into
|
|
6
|
+
* `2026-09-01`. A month *means* early month more than the 29th, so the two
|
|
7
|
+
* precisions get different ramps rather than the same ramp on a rounded date.
|
|
8
|
+
*
|
|
9
|
+
* **The firing key IS the window** (§12 G9), which buys two properties without
|
|
10
|
+
* any extra machinery: a clock repair cannot re-arm a spent window, because the
|
|
11
|
+
* key never depended on the clock; and a reschedule opens a fresh key that owes
|
|
12
|
+
* nothing to the old one's spent budget, because a different date is a different
|
|
13
|
+
* key.
|
|
14
|
+
*
|
|
15
|
+
* **Calendar days here, lived days elsewhere** — deliberately (NOTES.md §1). The
|
|
16
|
+
* event is a calendar fact and "three days before September 4th" is not
|
|
17
|
+
* computable in lived days for a day nobody has lived yet. The once-per-lived-day
|
|
18
|
+
* brake and `last_fired_day` are lived-day integers, and they live in `index.ts`.
|
|
19
|
+
*
|
|
20
|
+
* Pure: no ambient clock read anywhere in this file. The caller supplies `at`.
|
|
21
|
+
*/
|
|
22
|
+
import type { ProspectiveTunables } from "./tunables.js";
|
|
23
|
+
|
|
24
|
+
/** As stated. `2026` / `2026-08` / `2026-08-25` — the three shapes prose carries. */
|
|
25
|
+
export type DatePrecision = "day" | "month" | "year";
|
|
26
|
+
|
|
27
|
+
/** The two precisions that can tactfully arrive. Year-only never does (§12 G3). */
|
|
28
|
+
export type WindowPrecision = "day" | "month";
|
|
29
|
+
|
|
30
|
+
export type Phase = "pending" | "arrived" | "passed";
|
|
31
|
+
|
|
32
|
+
export interface Window {
|
|
33
|
+
/** `d:2026-08-25` or `m:2026-08`. The date is IN the key, on purpose (G9). */
|
|
34
|
+
readonly key: string;
|
|
35
|
+
/** The event date exactly as stated — never widened, never narrowed. */
|
|
36
|
+
readonly eventDate: string;
|
|
37
|
+
readonly precision: WindowPrecision;
|
|
38
|
+
/** First calendar day the window is open. */
|
|
39
|
+
readonly opensOn: string;
|
|
40
|
+
/** The day the ramp peaks: the date itself, or the FIRST of a stated month. */
|
|
41
|
+
readonly peakOn: string;
|
|
42
|
+
/** Last calendar day the window is open (grace included). */
|
|
43
|
+
readonly closesOn: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const DAY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
47
|
+
const MONTH_RE = /^(\d{4})-(\d{2})$/;
|
|
48
|
+
const YEAR_RE = /^\d{4}$/;
|
|
49
|
+
const DAY_MS = 86_400_000;
|
|
50
|
+
|
|
51
|
+
function pad(n: number): string {
|
|
52
|
+
return n < 10 ? `0${n}` : `${n}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** ISO day -> epoch ms at UTC midnight. Null when the date is not a real day. */
|
|
56
|
+
function dayMs(iso: string): number | null {
|
|
57
|
+
const m = DAY_RE.exec(iso);
|
|
58
|
+
if (m === null) return null;
|
|
59
|
+
const y = Number(m[1]);
|
|
60
|
+
const mo = Number(m[2]);
|
|
61
|
+
const d = Number(m[3]);
|
|
62
|
+
if (mo < 1 || mo > 12 || d < 1 || d > 31) return null;
|
|
63
|
+
const ms = Date.UTC(y, mo - 1, d);
|
|
64
|
+
// Round-trip: rejects 2026-02-30 and friends without a calendar table.
|
|
65
|
+
return isoOf(ms) === iso ? ms : null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function isoOf(ms: number): string {
|
|
69
|
+
const t = new Date(ms);
|
|
70
|
+
return `${t.getUTCFullYear()}-${pad(t.getUTCMonth() + 1)}-${pad(t.getUTCDate())}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The precision a date STATES. Null means "not a date this module understands",
|
|
75
|
+
* which the deriver reports as `malformed-date` — a refusal with a name, never a
|
|
76
|
+
* silent skip (scar §2.4).
|
|
77
|
+
*/
|
|
78
|
+
export function precisionOf(date: string): DatePrecision | null {
|
|
79
|
+
if (DAY_RE.test(date)) return dayMs(date) === null ? null : "day";
|
|
80
|
+
const m = MONTH_RE.exec(date);
|
|
81
|
+
if (m !== null) {
|
|
82
|
+
const mo = Number(m[2]);
|
|
83
|
+
return mo >= 1 && mo <= 12 ? "month" : null;
|
|
84
|
+
}
|
|
85
|
+
return YEAR_RE.test(date) ? "year" : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function addDays(isoDay: string, n: number): string {
|
|
89
|
+
const ms = dayMs(isoDay);
|
|
90
|
+
if (ms === null) throw new Error(`addDays: not an ISO day: ${isoDay}`);
|
|
91
|
+
return isoOf(ms + n * DAY_MS);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Calendar days from `a` to `b`; negative when `b` is earlier. */
|
|
95
|
+
export function daysBetween(a: string, b: string): number {
|
|
96
|
+
const x = dayMs(a);
|
|
97
|
+
const y = dayMs(b);
|
|
98
|
+
if (x === null || y === null) throw new Error(`daysBetween: not ISO days: ${a}, ${b}`);
|
|
99
|
+
return Math.round((y - x) / DAY_MS);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** First and last day of a stated `YYYY-MM`. */
|
|
103
|
+
export function monthBounds(month: string): { first: string; last: string } | null {
|
|
104
|
+
const m = MONTH_RE.exec(month);
|
|
105
|
+
if (m === null) return null;
|
|
106
|
+
const y = Number(m[1]);
|
|
107
|
+
const mo = Number(m[2]);
|
|
108
|
+
if (mo < 1 || mo > 12) return null;
|
|
109
|
+
return { first: `${y}-${pad(mo)}-01`, last: isoOf(Date.UTC(y, mo, 0)) };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function windowKey(eventDate: string, precision: WindowPrecision): string {
|
|
113
|
+
return `${precision === "day" ? "d" : "m"}:${eventDate}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The inverse. Null for a key this module did not mint — refused, never guessed. */
|
|
117
|
+
export function parseWindowKey(key: string): { eventDate: string; precision: WindowPrecision } | null {
|
|
118
|
+
const tag = key.slice(0, 2);
|
|
119
|
+
const date = key.slice(2);
|
|
120
|
+
const want: WindowPrecision | null = tag === "d:" ? "day" : tag === "m:" ? "month" : null;
|
|
121
|
+
if (want === null) return null;
|
|
122
|
+
return precisionOf(date) === want ? { eventDate: date, precision: want } : null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The window a stated date opens. Year precision returns null on purpose — it is
|
|
127
|
+
* excluded structurally, not scored down (§12 G3).
|
|
128
|
+
*
|
|
129
|
+
* A day window peaks on the day. A MONTH window peaks on the FIRST of the month
|
|
130
|
+
* and decays across it, because that is what a stated month means; rounding it to
|
|
131
|
+
* a day would invent a precision the author never claimed.
|
|
132
|
+
*/
|
|
133
|
+
export function windowFor(
|
|
134
|
+
eventDate: string,
|
|
135
|
+
precision: DatePrecision,
|
|
136
|
+
t: ProspectiveTunables,
|
|
137
|
+
): Window | null {
|
|
138
|
+
if (precision === "year") return null;
|
|
139
|
+
if (precision === "day") {
|
|
140
|
+
if (dayMs(eventDate) === null) return null;
|
|
141
|
+
return {
|
|
142
|
+
key: windowKey(eventDate, "day"),
|
|
143
|
+
eventDate,
|
|
144
|
+
precision: "day",
|
|
145
|
+
opensOn: addDays(eventDate, -t.LEAD_DAYS),
|
|
146
|
+
peakOn: eventDate,
|
|
147
|
+
closesOn: addDays(eventDate, t.GRACE_DAYS),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const bounds = monthBounds(eventDate);
|
|
151
|
+
if (bounds === null) return null;
|
|
152
|
+
return {
|
|
153
|
+
key: windowKey(eventDate, "month"),
|
|
154
|
+
eventDate,
|
|
155
|
+
precision: "month",
|
|
156
|
+
opensOn: addDays(bounds.first, -t.LEAD_DAYS),
|
|
157
|
+
peakOn: bounds.first,
|
|
158
|
+
closesOn: addDays(bounds.last, t.GRACE_DAYS),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** ISO day keys sort lexically, so the comparisons below are the calendar order. */
|
|
163
|
+
export function phaseOf(w: Window, at: string): Phase {
|
|
164
|
+
if (at < w.opensOn) return "pending";
|
|
165
|
+
return at > w.closesOn ? "passed" : "arrived";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* How loudly the window is arriving, 0..1 — the RAMP, not a decision. It scales a
|
|
170
|
+
* cue's weight into the ordinary competition; nothing here admits anything.
|
|
171
|
+
*
|
|
172
|
+
* Rises from `RAMP_OPEN` on the opening day to 1 at the peak, then falls to
|
|
173
|
+
* `RAMP_CLOSE` on the last grace day. For a month that decline spans the whole
|
|
174
|
+
* month plus grace, which is precisely "a stated month means early month more
|
|
175
|
+
* than the 29th" expressed as arithmetic rather than as a rounded date.
|
|
176
|
+
*/
|
|
177
|
+
export function rampAt(w: Window, at: string, t: ProspectiveTunables): number {
|
|
178
|
+
if (phaseOf(w, at) !== "arrived") return 0;
|
|
179
|
+
const toPeak = daysBetween(w.opensOn, w.peakOn);
|
|
180
|
+
if (at <= w.peakOn) {
|
|
181
|
+
if (toPeak <= 0) return 1;
|
|
182
|
+
return t.RAMP_OPEN + (1 - t.RAMP_OPEN) * (daysBetween(w.opensOn, at) / toPeak);
|
|
183
|
+
}
|
|
184
|
+
const tail = daysBetween(w.peakOn, w.closesOn);
|
|
185
|
+
if (tail <= 0) return 1;
|
|
186
|
+
return 1 - (1 - t.RAMP_CLOSE) * (daysBetween(w.peakOn, at) / tail);
|
|
187
|
+
}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# `recall/` — CONTRACT
|
|
2
|
+
|
|
3
|
+
## 1. Purpose
|
|
4
|
+
|
|
5
|
+
Let the right past arrive on its own, ignorably: cues → activation → a surfacing gate →
|
|
6
|
+
bounded injection, plus the explicit ask, plus noticing afterwards whether a surfaced memory
|
|
7
|
+
was actually used.
|
|
8
|
+
|
|
9
|
+
## 2. Brain analog
|
|
10
|
+
|
|
11
|
+
Cue-driven spreading activation with a relevance gate, and behavioral-relevance tagging
|
|
12
|
+
afterwards. **Named deviations** (constitution line 12): (a) surfacing is judged **relative
|
|
13
|
+
to this turn's own background distribution**, not against an absolute threshold — *where a
|
|
14
|
+
design wants `if x > threshold`, suspect a flattened gradient*; (b) only a retrieval the
|
|
15
|
+
reply actually used reconsolidates, where in humans every retrieval does.
|
|
16
|
+
|
|
17
|
+
## 3. Keeps
|
|
18
|
+
|
|
19
|
+
- **Three tiers, ascending in intrusiveness**: an affect flag (content-free — no ids, no
|
|
20
|
+
bodies, no feeling named); footnotes (pointers with short titles, **never bodies**); and
|
|
21
|
+
rarely a surfaced gist. A quiet turn renders **the empty string**, not an empty block.
|
|
22
|
+
[v1 §9]
|
|
23
|
+
- **No generative model call on the hot path.** [v1 §9 G1] Precise v2 form, per the harvest's
|
|
24
|
+
own correction: the ambient path may consult an **embedding** model, never a generative
|
|
25
|
+
one, and must degrade to lexical-only rather than fail (Appendix A #12 — v1's "no second
|
|
26
|
+
LLM call" was true of generation and silent about embeddings). **And it consults that
|
|
27
|
+
embedding without calling anything**: the ambient turn's semantic input is COMPUTED ONE
|
|
28
|
+
TURN EARLIER, off this path entirely (open question 2, answered — see §5 G17).
|
|
29
|
+
- **Hard latency budget, silent abort, zero side effects on loss** — the pass *builds* its
|
|
30
|
+
decision and a separate step *records* it; on timeout nothing is injected, buffered,
|
|
31
|
+
logged, or spent. *A slow subconscious is worse than a quiet one.* [v1 §9 G2]
|
|
32
|
+
- **Host boilerplate is stripped before cue extraction and before embedding** — measured: an
|
|
33
|
+
image placeholder token surfaced an unrelated image-cache memory. [v1 §9 G3]
|
|
34
|
+
- **Cue matching is word-bounded and rarity-weighted**; informativeness weighting replaces
|
|
35
|
+
stop-lists — **and rarity is COUNTED, not inferred from a bounded top-K.** The pass read
|
|
36
|
+
`df` off the LENGTH of its own `PER_CUE_FETCH` result, which is `min(trueDf, K)`, so the
|
|
37
|
+
rule held on a fixture (where `trueDf` cannot reach `K`) and switched itself off as the
|
|
38
|
+
store grew: MEASURED 2026-09-04 on a 15,421-document index, `conversation` (df 574) and
|
|
39
|
+
`chat` (df 444) both drew informativeness **5.70** against a ceiling of 8.95, where their
|
|
40
|
+
true frequencies put them at 2.6 and 2.9. `Store.docFrequency` counts, in one grouped
|
|
41
|
+
query (8-36 ms cold, 2-4 ms warm for 72 tokens) — paid for several times over by asking
|
|
42
|
+
rarity FIRST and probing the index only for the tokens that became cues. [v1 §9 G4]
|
|
43
|
+
- **…and the same rule holds on the DOCUMENT side: a cue's evidence for a memory does not
|
|
44
|
+
scale with how long the memory is.** Informativeness says a token spanning the whole store
|
|
45
|
+
is evidence of nothing; a memory spanning every topic is likewise specific evidence for
|
|
46
|
+
none. Mechanized as BM25 length normalization in the token index — applied *before* the
|
|
47
|
+
index's own `ORDER BY … LIMIT`, so the candidate SET is chosen length-fairly and not only
|
|
48
|
+
re-ranked — plus a per-document ceiling at a multiple of that document's own strongest
|
|
49
|
+
cue. The length factor is CLAMPED at 1 — a long document is penalized, a short one is
|
|
50
|
+
never rewarded — so no score exceeds what it was before normalization and the inherited
|
|
51
|
+
absolute floors keep their meaning. **This is a v2 addition, not a v1 port**: v1's cue
|
|
52
|
+
channel matched curated entity aliases, where length could not accumulate, and it capped a
|
|
53
|
+
node's total alias contribution absolutely (`entityCueCap`) for the same reason the ceiling
|
|
54
|
+
exists here. MEASURED 2026-09-04 — see `tunables.ts` (`CUE_LENGTH_NORM`,
|
|
55
|
+
`CUE_TF_SATURATION`, `CUE_LENGTH_ONE_SIDED`, `CUE_DOC_CAP`) and `tools/recall-bench` for
|
|
56
|
+
the 23-cell sweep behind the values.
|
|
57
|
+
- **Ambiguous handles fire at reduced weight and train nothing** — and the training half must
|
|
58
|
+
actually be enforced, not just documented (scar §2.6: v1 documented this in three places,
|
|
59
|
+
enforced it in one, and a repo-wide grep found zero consumers). [v1 §9 G5]
|
|
60
|
+
- **Salience lowers the bar but never bypasses relevance**, via three hard gates salience
|
|
61
|
+
cannot touch: an **uncued memory is dark** whatever its salience; an **absolute floor** is
|
|
62
|
+
checked before any salience adjustment; the loud tier requires a **minimum fraction of
|
|
63
|
+
activation from cues**. [v1 §9 G7]
|
|
64
|
+
- **Ordering and admission use deliberately different keys** — salience blends into the
|
|
65
|
+
surfaced *pick* only; admission, inhibition, and the footnote tier stay pure activation,
|
|
66
|
+
preserving the footnote tier as the **recency discovery channel**. [v1 §9 G8,
|
|
67
|
+
earned-mechanism #19]
|
|
68
|
+
- **Single-channel cues are tier-capped**: *arrival makes a memory warm; only relevance makes
|
|
69
|
+
it loud.* [v1 §9 G9]
|
|
70
|
+
- **Emotion is turn-gated, and that gate is the safety property** — a high-salience wound
|
|
71
|
+
must not light up every turn. [v1 §9 G10]
|
|
72
|
+
- **The affect flag and the retrieval cue have different subject rules**: the flag is
|
|
73
|
+
subject-inclusive; the *cue* is first-person only, guarding against mood-congruent
|
|
74
|
+
overgeneralization. [v1 §9 G11]
|
|
75
|
+
- **The absolute floors are in the model's own unit: one maximally-rare cue.** A floor of
|
|
76
|
+
`4.5` means *four and a half maximally-rare cues' worth of evidence* — the same sentence on
|
|
77
|
+
a seventeen-memory store as on a fifteen-thousand-memory one (`gate.ts#floorUnit`,
|
|
78
|
+
`informativeness(1, storeSize)`). This is what the loud tier's rarity rests on, and it is a
|
|
79
|
+
v2 addition: v1's floors were absolute numbers on a normalized 0-1 cosine, and carried into
|
|
80
|
+
a SUM of `idf x evidence` they could not fire at any scale anyone measured (§7 OQ5). ACT-R's
|
|
81
|
+
retrieval threshold τ, restored to the model's units.
|
|
82
|
+
- **Per-kind floors are a MECHANISM, not a shape** — v1 measured one (person activation peaked
|
|
83
|
+
near 0.79 where craft material floored at 1.0) and v2's corpus refuses it: over 312 candidate
|
|
84
|
+
rows from 13 real prompts, p50 runs 1.21-1.45 and p90 1.93-2.79 across `fact`, `person`,
|
|
85
|
+
`self`, `skill` and `entity` — one distribution, not five, because v2's activation is
|
|
86
|
+
cue-driven and kind-agnostic. So the override table ships EMPTY (scar §2.8: measured or
|
|
87
|
+
disabled) and a kind that earns an override still gets one. The *background statistic* stays
|
|
88
|
+
global. [v1 §9 G12, re-earned 2026-09-04]
|
|
89
|
+
- **Cold start is stricter, not looser** — below a minimum store size the variance estimate is
|
|
90
|
+
meaningless, and small stores over-surface. In the same cue units, at twice the ordinary
|
|
91
|
+
floor, so "stricter" is arithmetic rather than a comment. [v1 §9 G13]
|
|
92
|
+
- **Lateral inhibition with a query-aware relaxation**, and a suppressed candidate may reclaim
|
|
93
|
+
a slot only as competition, never as un-inhibition. **An empty slot stays quiet.**
|
|
94
|
+
[v1 §9 G14–G15]
|
|
95
|
+
- **Hard caps on volume, and the tiers are disjoint** — a memory is "came to mind" *or*
|
|
96
|
+
"quietly available", never both. [v1 §9 G16]
|
|
97
|
+
- **Deliberate recall is a deeper effort with different thresholds, on purpose** — the ambient
|
|
98
|
+
seed floor is the right bar for surfacing uninvited and the wrong bar for a question someone
|
|
99
|
+
asked (measured: five on-point traces, best similarity 0.366, zero surfaced). It adds a
|
|
100
|
+
**labeled** lower-confidence tier and returns footnote-tier items as bodies. **Ranking is
|
|
101
|
+
not recording**: it trains nothing and deposits nothing. [v1 §9.1]
|
|
102
|
+
- **A candidate count must not become an undercount** — a top-K tuned for surfacing is wrong
|
|
103
|
+
for an aggregation question. [v1 §9.1 G3]
|
|
104
|
+
- **Reference resolution reads the assistant's turns only, uses no model and no file reads,
|
|
105
|
+
and its bar is precision over recall** — a false "used" pollutes learning permanently while
|
|
106
|
+
a miss merely leaves weak credit. [v1 §9.2] **Built 2026-09-14 (`reference.ts`, wired at
|
|
107
|
+
the session-ending boundary by the claude-code adapter), under the owner's rule of the same
|
|
108
|
+
day: a memory is credited when the assistant EXPANDED it through deliberate recall (`ids`
|
|
109
|
+
or `handle` on the tool call — the call is an assistant turn; ids are never parsed out of
|
|
110
|
+
prose) or QUOTED it at content level (eight consecutive words of the body, verbatim, in one
|
|
111
|
+
assistant turn; only a memory that surfaced LOUD is quotable, since a footnote showed the
|
|
112
|
+
model nothing but a title). Never for being named, surfaced, footnoted, or rendered in a
|
|
113
|
+
wake; the `surfaced` and `footnoted` use tiers stay unused by this consumer. Agreement is
|
|
114
|
+
not judged: a memory expanded and then argued with is credited. One durable row per
|
|
115
|
+
boundary, `recall.credit`, with a `reason` readers split on.**
|
|
116
|
+
- **Framing is load-bearing and part of the spec** — footnotes are pointers, and the "quietly
|
|
117
|
+
available / ignorable" phrasing is a deliberate probe question, at step 1 since 2026-09-14
|
|
118
|
+
(§7 OQ4). [v1 §9 G17]
|
|
119
|
+
- **A chapter is recallable and is LABELED, at every door.** An `epi_` row is the
|
|
120
|
+
first-person account a memory was made from, not a memory: it sits outside every sleep
|
|
121
|
+
phase (`sleep/types.ts#isJournal`) and the physics beside it is recorded, never acted on.
|
|
122
|
+
It may rightly come to mind, so **recall** filters nothing — and every result carrying
|
|
123
|
+
one says what it is: `FRAMING.journal` in front of the rendered line in both tiers,
|
|
124
|
+
`journal: true` on the deliberate row, `[journal]` in the console. Owner ruling
|
|
125
|
+
2026-09-04 (LAUNCH-STATUS §I14); a v2 addition, and a LABEL — it changes nothing about
|
|
126
|
+
what is recallable, scored or ranked, and adds no field to the decision record. **The
|
|
127
|
+
one place the label is not enough is the wake's horizon lane**, where the claim is not
|
|
128
|
+
"here is something" but "this is arriving": a chapter's date is a day already lived, so
|
|
129
|
+
it is refused outright there (`prospective/` CONTRACT §3). Label where the reader can
|
|
130
|
+
discount; filter where the frame itself would be a lie.
|
|
131
|
+
|
|
132
|
+
## 4. Drops / simplifies
|
|
133
|
+
|
|
134
|
+
- **Per-session gate state is persisted, first-class, in the operational database.**
|
|
135
|
+
**PROPOSED** — owner call at check-in. This is the harvest's most consequential single
|
|
136
|
+
finding and demands an explicit answer: in v1 the object holding "what surfaced this
|
|
137
|
+
session", the refractory countdown, and carried cues was constructed fresh every turn and
|
|
138
|
+
discarded, because the turn path is a new process per turn and nothing serialized it. So
|
|
139
|
+
**session dedup, the emotional refractory, refractory suppression of arrival cues, and
|
|
140
|
+
cross-session cue carry-over were all inert on the live path** — specified, implemented,
|
|
141
|
+
tested, unreachable. The spec's instruction is to pick one and say so; this contract
|
|
142
|
+
persists it (a few rows under the storage rescope) and marks the call. **Generalized: a
|
|
143
|
+
pure function over caller-owned state is only as real as its caller.**
|
|
144
|
+
- **The activation graph's edge arithmetic may belong in `physics/` and the traversal here** —
|
|
145
|
+
`associate/CONTRACT.md` open question 1, the module map's standing check-in question. Not
|
|
146
|
+
resolved by this contract.
|
|
147
|
+
- **v1's ~40 recall knobs are not ported as a set.** Each ships with a recorded calibration
|
|
148
|
+
against a real corpus and a fixture-bounded window, or ships disabled (scar §2.8). v1's
|
|
149
|
+
values in behavioral-spec §9 are the best surviving record of what lived use moved — the
|
|
150
|
+
starting point, not the default. **Nine knobs are no longer inherited**:
|
|
151
|
+
`CUE_LENGTH_NORM`, `CUE_TF_SATURATION`, `CUE_LENGTH_ONE_SIDED` and `CUE_DOC_CAP` were
|
|
152
|
+
measured on v2's own corpus (`tools/recall-bench`, 2026-09-04) rather than carried over;
|
|
153
|
+
`BUDGET_MS` was re-measured on day 0 of the parallel run; and the three absolute floors
|
|
154
|
+
plus `SNR_GLOBAL` were re-earned on 2026-09-04 with a **change of UNIT**, not only of value
|
|
155
|
+
— `FLOOR_GLOBAL`, `FLOOR_STRONG_BY_KIND`, `FLOOR_STRONG_DEFAULT` and `COLD_START_FLOOR` are
|
|
156
|
+
now `*_UNITS`, denominated in `informativeness(1, storeSize)`. The rename is the mechanism:
|
|
157
|
+
a re-scaled tunable that keeps its old name is how v1's numbers survived into v2 unnoticed
|
|
158
|
+
for a month, and every stale reading of the old scale is now a compile error. That is what
|
|
159
|
+
"re-earned against v2's own corpus" looks like when it actually happens.
|
|
160
|
+
- **The learned-edge type coupling is made deliberate.** In v1, learned co-activation edges
|
|
161
|
+
were written as the same type the activation pass *boosts*, so learning silently rode a
|
|
162
|
+
1.6× multiplier. **PROPOSED** — owner call at check-in, since choosing deliberately may
|
|
163
|
+
change behavior either way.
|
|
164
|
+
|
|
165
|
+
## 5. Contract
|
|
166
|
+
|
|
167
|
+
**Inputs** — the user's turn; the memory graph with typed, valenced edges; strengths from
|
|
168
|
+
`physics/`; persisted per-session gate state; the prospective horizon; the observer
|
|
169
|
+
predicate; the lived day.
|
|
170
|
+
*One row is excluded from the candidate pool by name (2026-09-18): the SELF PAGE
|
|
171
|
+
(`activate.ts#isSelfPage`). It is delivered whole at every wake, so surfacing it tells the
|
|
172
|
+
reader nothing they were not already told — and it would otherwise accrue use credit and
|
|
173
|
+
association edges for being what it always is, and, having no project scope, surface under
|
|
174
|
+
a project it was never written in. The role string is read structurally rather than
|
|
175
|
+
imported; `recall/` depends on nothing in `self/`. One line to reverse.*
|
|
176
|
+
*A SECOND is excluded the same way (2026-09-20, E1): the per-directory HANDOFF
|
|
177
|
+
(`activate.ts#isHandoff`). It is working context for one place — delivered as a pointer at
|
|
178
|
+
the wake of that directory, expandable there by id, and expiring — not an interpretation of
|
|
179
|
+
what was learned, and it carries no project scope a search could honour, so left in the pool
|
|
180
|
+
it would put one directory's unfinished business in front of another's turn. It is NOT
|
|
181
|
+
refused at `deliberate.ts#expandHandle`, because the pointer's whole shape is a line and an
|
|
182
|
+
id; what it is refused is CREDIT (`counterpart.ts#creditReferences`), so expanding one
|
|
183
|
+
reinforces nothing and can never promote.*
|
|
184
|
+
**Outputs** — a rendered injection (empty string, affect flag, footnotes, or a surfaced
|
|
185
|
+
gist); a decision record (tier counts, ids, salience — content-by-reference); reference
|
|
186
|
+
credit at the boundary; reinforcement deltas handed to `physics/`.
|
|
187
|
+
|
|
188
|
+
**Guarantees** — **[M]** mechanized · **[A]** advisory:
|
|
189
|
+
|
|
190
|
+
1. **[M]** No generative model call on the hot path, asserted by a test that enumerates call
|
|
191
|
+
sites. An embedding lookup is permitted and must degrade to lexical-only.
|
|
192
|
+
2. **[M]** A latency-budget abort has zero side effects: nothing injected, nothing buffered,
|
|
193
|
+
no telemetry, no fire budget spent.
|
|
194
|
+
3. **[M]** Build and record are separate steps.
|
|
195
|
+
4. **[M]** Surfacing is relative to this turn's background, never a fixed number.
|
|
196
|
+
5. **[M]** The three hard gates hold: uncued is dark; the absolute floor precedes any salience
|
|
197
|
+
adjustment; the loud tier requires a minimum cue fraction.
|
|
198
|
+
6. **[M]** Tiers are disjoint and capped.
|
|
199
|
+
7. **[M]** Ambiguous handles fire at reduced weight AND train nothing — both halves, with a
|
|
200
|
+
test that greps for the consumer, not the comment (scar §2.6).
|
|
201
|
+
8. **[M]** Deliberate recall trains nothing and deposits nothing.
|
|
202
|
+
9. **[M]** Confidentiality is enforced at the boundary of the ask — sensitive material returns
|
|
203
|
+
only in the owner's own session; withholding is *stated* for a direct lookup and silent in
|
|
204
|
+
a list.
|
|
205
|
+
10. **[M]** Reference credit is precision-biased, never downgrades an already-credited item,
|
|
206
|
+
and is a no-op under observer.
|
|
207
|
+
11. **[M]** Under observer, recall computes and renders normally and strengthens nothing —
|
|
208
|
+
checked first, before any other work (scar E7).
|
|
209
|
+
12. **[M]** Per-session gate state has a defined store and lifetime, and a test asserts the
|
|
210
|
+
live path reads and writes it — the exact assertion whose absence made v1's four gate
|
|
211
|
+
rules inert.
|
|
212
|
+
13. **[A]** Framing and phrasing are preferences, recorded as open probe questions.
|
|
213
|
+
14. **[M]** The per-turn surfacing decision record is content-by-reference and exists from day
|
|
214
|
+
one — it is the richest replay comparison surface (§17.3).
|
|
215
|
+
15. **[M]** That record is **durable**: the composition root appends one `recall.decision` row
|
|
216
|
+
per non-aborted turn to the store's event log, and exports the record's ordered field list
|
|
217
|
+
(`surfaceSetFields()`) as the surface set's schema — so a run's surfacing numbers are
|
|
218
|
+
recomputable from the store it leaves behind rather than from a live event ring, and a
|
|
219
|
+
human rating can be carried across a change only when that set provably matches (parallel
|
|
220
|
+
CONTRACT §5 G2/G12, replay INTERFACE-GAPS §7). Nothing is written under observer; an
|
|
221
|
+
abort writes nothing at all, which is guarantee 2 unchanged.
|
|
222
|
+
16. **[M]** The semantic channel has a **stated source on every turn**, from a closed
|
|
223
|
+
vocabulary (`none`, `lagged`, `in-line`, `stale`, `unreadable`, and the worker's four
|
|
224
|
+
named failures). Measured 2026-09-04: both live paths built their turn without a
|
|
225
|
+
vector, so `semanticUsed: false` was written on every real turn and said nothing about
|
|
226
|
+
why — "did not fire" and "was never asked" are different records (scar §2.4). The
|
|
227
|
+
source is NOT in the durable surface set (`RECALL_DECISION_FIELDS`), because moving
|
|
228
|
+
that set mid-parallel-run invalidates every carried human rating (parallel §5 G12); it
|
|
229
|
+
rides the adapter's own `adapter.recall` row, which is durable.
|
|
230
|
+
17. **[M]** The lagged semantic cue is **per-session gate state with a one-turn lifetime**,
|
|
231
|
+
on the same `gate_session` table and swept by the same `pruneGateSessions()`. It stamps
|
|
232
|
+
the session's SERVED turn count when written and is usable only while that number is
|
|
233
|
+
still the served count — i.e. on the very next turn, exactly the `carriedCues` rule.
|
|
234
|
+
What it carries is the **top-M `{id, score}` ranking**, not the vector: `Store.nearestTo`
|
|
235
|
+
measured 590-1040 ms over 13,862 stored vectors, so the scan is as unaffordable on the
|
|
236
|
+
hot path as the round trip was. A recorded race: a worker slow enough to be overtaken
|
|
237
|
+
by the next turn stamps the newer turn number, so a cue can be labelled one turn later
|
|
238
|
+
than the text it was computed from. Cheap to detect (the hits are a turn stale), not
|
|
239
|
+
worth a lock.
|
|
240
|
+
|
|
241
|
+
## 6. Scars honored
|
|
242
|
+
|
|
243
|
+
**E7** (observers surface but strengthen nothing) · **E8** (base-level decay runs on lived
|
|
244
|
+
days) · **§2.4** (footnote-flood, affect-noise, and name-smear get tripwires, not tiles) ·
|
|
245
|
+
**§2.6** (the ambiguous-alias safety half is enforced, not documented) · **§2.8** (every
|
|
246
|
+
recall threshold ships measured, or disabled) · **§2.9** (context assembly logs what it
|
|
247
|
+
showed, by id) · **§2.18** (the injection ceiling is a host capability) · **§2.20** (the
|
|
248
|
+
decision record carries ids, never bodies).
|
|
249
|
+
|
|
250
|
+
## 7. Open questions
|
|
251
|
+
|
|
252
|
+
1. **Is per-session gate state the right lifetime?** Persisting it is this contract's
|
|
253
|
+
proposal; the alternative the spec offers is honest deletion of the four rules that depend
|
|
254
|
+
on it. Either is defensible; v1's state — specified, implemented, tested, unreachable — is
|
|
255
|
+
the worst of the three.
|
|
256
|
+
2. ~~**Does the ambient path embed at all on a cold cache?**~~ **ANSWERED 2026-09-04
|
|
257
|
+
(owner ruling): no — and it does not rank one either.** v1's did, inside its own
|
|
258
|
+
latency race (`~/bansai/hooks/surface.ts:82-88`, "a cold cache calls Voyage and the
|
|
259
|
+
latency race covers it"), which is how "no second LLM call" quietly became untrue
|
|
260
|
+
there. v2 cannot even do that much: `recall.build` is a synchronous pass with budget
|
|
261
|
+
checkpoints rather than a race, so an overrun aborts the turn instead of degrading the
|
|
262
|
+
channel, and every hook is a fresh process already spending 700-1000 ms cold against
|
|
263
|
+
1200 ms. The cue is computed by the detached worker after a turn and used on the next
|
|
264
|
+
one (§5 G17). The deliberate ask is the exception and embeds in line, under its own
|
|
265
|
+
budget (`mcp/deliberate.ts`, `DELIBERATE_BUDGET_MS`).
|
|
266
|
+
3. **Does `associate/` fold in here** (traversal), with its arithmetic going to `physics/`?
|
|
267
|
+
The module map's standing check-in question; owned by `associate/`.
|
|
268
|
+
4. **Is the "quietly available / ignorable" framing actually ignorable to a model?** v1
|
|
269
|
+
shipped it as a deliberate probe question and never answered it. **Probe advanced one
|
|
270
|
+
step 2026-09-14:** step 0 (`render.ts#FOOTNOTE_HEADER_STEP_0`, the string above) ran
|
|
271
|
+
live to that date; step 1 keeps "ignorable" and adds "expand an id with recall before
|
|
272
|
+
citing one", after the model was measured asserting counts and characterizations of
|
|
273
|
+
five footnoted memories from their titles without expanding any (IMPROVEMENTS U5). The
|
|
274
|
+
measurement is `probe.ts` / `counterparts probe-oq4`: per calendar date, footnotes
|
|
275
|
+
delivered (`recall.decision`) vs. later expanded by id (`recall.credit.expandedIds`).
|
|
276
|
+
Reversible by one string; the owner rules on the reading, not this file.
|
|
277
|
+
5. ~~**The absolute floors have never fired in v2, and the loud tier needs them.**~~
|
|
278
|
+
**ANSWERED 2026-09-04. The floors are in cue units now, and the "cue-count half" was
|
|
279
|
+
never a second half — it was a broken measurement.**
|
|
280
|
+
|
|
281
|
+
The finding that closed it: `activate.ts` took a token's document frequency from the
|
|
282
|
+
LENGTH of its own `PER_CUE_FETCH` result, and a bounded top-K's length is
|
|
283
|
+
`min(trueDf, K)`. So on a 15,421-document index every word occurring in 24 or more
|
|
284
|
+
memories measured as equally rare — `conversation` (true df 574) and `chat` (444) both
|
|
285
|
+
drew informativeness **5.70** against a ceiling of 8.95 — while on a seventeen-memory
|
|
286
|
+
fixture the truncation cannot happen at all. §3 G4's "informativeness weighting replaces
|
|
287
|
+
stop-lists" was therefore *true in miniature and progressively false at scale*, which is
|
|
288
|
+
exactly the asymmetry that made a floor calibrated on the live store blind a small one.
|
|
289
|
+
Counting df instead (`store/cache.ts#docFrequency`) removes it: a hermetic
|
|
290
|
+
seventeen-memory fixture whose turn cleanly cues one memory now lands at **3.00 cue
|
|
291
|
+
units**, INSIDE the live store's per-turn range of **0.88 to 5.17**. One scale, two
|
|
292
|
+
corpora three orders of magnitude apart.
|
|
293
|
+
|
|
294
|
+
With that fixed, denominating the floors in `informativeness(1, storeSize)` — one
|
|
295
|
+
maximally-rare cue, the model's own unit — is sufficient on its own, and it is what
|
|
296
|
+
shipped: `FLOOR_GLOBAL_UNITS` 0.2, `FLOOR_STRONG_DEFAULT_UNITS` 4.5,
|
|
297
|
+
`COLD_START_FLOOR_UNITS` 0.4, `FLOOR_STRONG_BY_KIND_UNITS` empty. On the 13-prompt
|
|
298
|
+
bench, against the same store copy: loud fell from **13 of 13 turns to 3 of 13**, the
|
|
299
|
+
near-contentless turn 3 went silent, delivered per turn went 3.9 → 2.8, hub deliveries
|
|
300
|
+
stayed 0, **no id was delivered on 3 or more turns at all** (against 5 ids carrying 27 of
|
|
301
|
+
51 deliveries before), and the labeled positives went from 3 to 7 — including both
|
|
302
|
+
ambient ones, on the turn they were labeled for.
|
|
303
|
+
|
|
304
|
+
**What the two candidate mechanisms turned out to be worth**, since both were named here
|
|
305
|
+
and only one of them was ever going to ship:
|
|
306
|
+
- *Normalize activation by the turn's own cue mass* is **refuted by arithmetic**, and
|
|
307
|
+
usefully so: turn 3's top candidate takes **22%** of its turn's cue mass where turn 5's
|
|
308
|
+
takes **7%**. A thin turn CONCENTRATES, so this is the relative bar's failure again in
|
|
309
|
+
a new coat. Recorded rather than left as a lead, so nobody prototypes it.
|
|
310
|
+
- *Gate the loud tier on whether the turn carried distinctive vocabulary* (candidate b)
|
|
311
|
+
works but discriminates poorly: turn 3's cue mass is 3.67 units against 15.3-67.7 for
|
|
312
|
+
the other twelve, which silences turn 3 and nothing else; reaching one-in-four needs a
|
|
313
|
+
floor near 40 units, and mass scales with turn LENGTH (14 tokens vs 163), so that floor
|
|
314
|
+
would be gating on how much the person typed. It also fails the miniature outright — a
|
|
315
|
+
four-word hermetic turn carries 3.0 units, indistinguishable from turn 3. Not shipped,
|
|
316
|
+
and not needed: the per-candidate floor reaches the target without a turn-level gate.
|
|
317
|
+
- *Loud pacing* (candidate c) was not needed and is not shipped. It is a gate where the
|
|
318
|
+
evidence supported a gradient, and it would have made the loud tier a function of when
|
|
319
|
+
the session started rather than of what the turn said.
|
|
320
|
+
|
|
321
|
+
**A second instance of the same scar, found on the way and fixed here**:
|
|
322
|
+
`prospective.CUE_STRENGTH` (0.5) was also an absolute number on v1's scale, so a temporal
|
|
323
|
+
arrival was worth 0.23 of a maximally-rare word on a seventeen-memory store and 0.056 of
|
|
324
|
+
one on a fifteen-thousand-memory store — the calendar going quiet as the owner remembers
|
|
325
|
+
more. It is converted at the fold (`activate.ts`), which is what makes "one more cue, like
|
|
326
|
+
the user typing 'Portland'" finally true.
|