counterparts 0.2.0 → 0.3.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/README.md +87 -367
- package/docs/QUICKSTART.md +83 -1584
- package/docs/README.md +86 -0
- package/docs/module-map.md +1 -0
- package/package.json +5 -2
- package/src/adapters/claude-code/CONTRACT.md +151 -18
- package/src/adapters/claude-code/INTERFACE-GAPS.md +138 -2
- package/src/adapters/claude-code/NOTES.md +452 -0
- package/src/adapters/claude-code/bin/hook.ts +221 -49
- package/src/adapters/claude-code/bin/runner.ts +220 -101
- package/src/adapters/claude-code/config.ts +202 -279
- package/src/adapters/claude-code/doctor.ts +713 -421
- package/src/adapters/claude-code/embed-client.ts +165 -557
- package/src/adapters/claude-code/hooks.ts +409 -116
- package/src/adapters/claude-code/index.ts +7 -59
- package/src/adapters/claude-code/page-writer.ts +24 -4
- package/src/adapters/claude-code/spawn.ts +6 -7
- package/src/adapters/claude-code/transcript.ts +204 -10
- package/src/adapters/claude-code/vectors.ts +108 -24
- package/src/adapters/cli/CONTRACT.md +123 -3
- package/src/adapters/cli/INTERFACE-GAPS.md +45 -2
- package/src/adapters/cli/NOTES.md +265 -1
- package/src/adapters/cli/bin/counterparts.ts +9 -9
- package/src/adapters/cli/commands.ts +494 -436
- package/src/adapters/cli/help.ts +22 -27
- package/src/adapters/cli/index.ts +0 -2
- package/src/adapters/cli/install.ts +102 -89
- package/src/adapters/cli/removal.ts +1 -1
- package/src/adapters/cli/report.ts +25 -2
- package/src/adapters/cli/uninstall.ts +182 -34
- package/src/adapters/cli/wire.ts +232 -35
- package/src/adapters/dashboard/INTERFACE-GAPS.md +14 -2
- package/src/adapters/dashboard/activity.ts +4 -1
- package/src/adapters/dashboard/bin/dashboard.ts +1 -1
- package/src/adapters/dashboard/registries.ts +16 -1
- package/src/adapters/dashboard/resolve.ts +4 -4
- package/src/adapters/dashboard/source.ts +8 -2
- package/src/adapters/dashboard/web/flow.ts +6 -0
- package/src/adapters/dashboard/web/narrate.ts +66 -14
- package/src/adapters/dashboard/web/reveal.ts +6 -6
- package/src/adapters/dashboard/web/views.ts +12 -4
- package/src/adapters/fired.ts +20 -5
- package/src/adapters/mcp/CONTRACT.md +73 -1
- package/src/adapters/mcp/INTERFACE-GAPS.md +51 -1
- package/src/adapters/mcp/NOTES.md +389 -0
- package/src/adapters/mcp/bin/serve.ts +24 -35
- package/src/adapters/mcp/deliberate.ts +22 -0
- package/src/adapters/mcp/index.ts +26 -2
- package/src/adapters/mcp/server.ts +425 -49
- package/src/adapters/mcp/tools.ts +32 -7
- package/src/adapters/mcp/write-up.ts +454 -0
- package/src/adapters/sessions.ts +1353 -0
- package/src/core/counterpart.ts +32 -8
- package/src/core/embed/CONTRACT.md +85 -0
- package/src/core/embed/NOTES.md +93 -0
- package/src/core/embed/static.ts +622 -0
- package/src/core/encode/INTERFACE-GAPS.md +17 -0
- package/src/core/encode/NOTES.md +78 -0
- package/src/core/encode/secrets.ts +309 -9
- package/src/core/handoff/INTERFACE-GAPS.md +13 -1
- package/src/core/recall/CONTRACT.md +15 -3
- package/src/core/recall/INTERFACE-GAPS.md +94 -0
- package/src/core/recall/NOTES.md +49 -0
- package/src/core/recall/activate.ts +37 -3
- package/src/core/recall/index.ts +22 -1
- package/src/core/recall/session.ts +32 -0
- package/src/core/recall/tunables.ts +99 -2
- package/src/core/remember/CONTRACT.md +51 -7
- package/src/core/remember/INTERFACE-GAPS.md +111 -1
- package/src/core/remember/NOTES.md +221 -1
- package/src/core/remember/index.ts +28 -0
- package/src/core/remember/owes.ts +532 -0
- package/src/core/remember/owner-strike-seam.ts +34 -2
- package/src/core/remember/proposals.ts +25 -6
- package/src/core/remember/retention.ts +154 -0
- package/src/core/remember/spans.ts +53 -12
- package/src/core/remember/tunables.ts +8 -0
- package/src/core/remember/write-up-seam.ts +104 -0
- package/src/core/self/CONTRACT.md +16 -13
- package/src/core/self/INTERFACE-GAPS.md +8 -1
- package/src/core/self/NOTES.md +123 -1
- package/src/core/self/calendar.ts +81 -0
- package/src/core/self/episodes.ts +158 -36
- package/src/core/self/identity.ts +2 -2
- package/src/core/self/index.ts +88 -20
- package/src/core/self/tunables.ts +18 -46
- package/src/core/self/writer.ts +58 -9
- package/src/core/store/CONTRACT.md +16 -1
- package/src/core/store/NOTES.md +293 -0
- package/src/core/store/cache.ts +585 -27
- package/src/core/store/db.ts +97 -0
- package/src/core/store/index.ts +570 -13
- package/tools/install-loop/run.sh +52 -71
- package/src/adapters/claude-code/credentials.ts +0 -199
- package/src/adapters/claude-code/interpret-client.ts +0 -395
- package/src/adapters/cli/keys.ts +0 -503
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
* 1. **It reads and never writes.** Every store call below is a read; the
|
|
24
24
|
* caller supplies an OBSERVER store or one that is already open. Nothing
|
|
25
25
|
* here opens a database, mints a directory or touches box 3.
|
|
26
|
-
* 2. **Names and counts, never values.**
|
|
27
|
-
*
|
|
28
|
-
* never a prefix. The same rule `credentials.ts` states for itself.
|
|
26
|
+
* 2. **Names and counts, never values.** Paths, names, counts and dates —
|
|
27
|
+
* never memory text.
|
|
29
28
|
* 3. **It is on the hot path, so it is bounded.** `sessionNoticeBudgetMs`
|
|
30
29
|
* bounds the whole reading at session start, checked BETWEEN groups; what
|
|
31
30
|
* the budget cut off is reported as a finding rather than silently
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
* nobody needed).
|
|
34
33
|
*/
|
|
35
34
|
import { spawnSync } from "node:child_process";
|
|
36
|
-
import { existsSync } from "node:fs";
|
|
35
|
+
import { existsSync, statSync } from "node:fs";
|
|
37
36
|
import { homedir } from "node:os";
|
|
38
37
|
import { dirname, join } from "node:path";
|
|
39
38
|
import { fileURLToPath } from "node:url";
|
|
@@ -67,17 +66,18 @@ import {
|
|
|
67
66
|
JOURNAL_COPY_WRITTEN_EVENT,
|
|
68
67
|
} from "../../core/self/journal-file.js";
|
|
69
68
|
import {
|
|
69
|
+
dayBefore,
|
|
70
70
|
hasDayBefore,
|
|
71
71
|
lastPageWriterRun,
|
|
72
|
-
pageWriterAbout,
|
|
73
72
|
pageWriterDue,
|
|
73
|
+
pageWriterNight,
|
|
74
74
|
pageWriterStatus,
|
|
75
75
|
} from "../../core/self/writer.js";
|
|
76
76
|
import type { AskReason } from "../../core/self/episodes.js";
|
|
77
77
|
// The what-fired reading, shared with the console's `fired` command and the
|
|
78
78
|
// dashboard's health panel so the three cannot disagree about what "silent"
|
|
79
79
|
// means (constitution 16, the same rule this module already keeps for "healthy").
|
|
80
|
-
import { STATE_MEANING,
|
|
80
|
+
import { STATE_MEANING, daysBetween, firedReport } from "../fired.js";
|
|
81
81
|
// The one name the "no configuration was read" line needs, from the module that
|
|
82
82
|
// owns it — so the sentence here and the refusal it replaced name the same var.
|
|
83
83
|
import { CONFIG_ENV } from "../config-path.js";
|
|
@@ -88,10 +88,24 @@ import {
|
|
|
88
88
|
readSnapshotsDir,
|
|
89
89
|
resolveSnapshotsDir,
|
|
90
90
|
} from "../snapshots.js";
|
|
91
|
-
import {
|
|
91
|
+
import { TUNABLES, pageWriterMode, resolveEmbedder, withEmbedderDefault } from "./config.js";
|
|
92
|
+
import type { EmbedderSource } from "./config.js";
|
|
93
|
+
import { MODEL_FILE, STATIC_WEIGHTS_ENV, STATIC_WEIGHTS_PACKAGE, resolveStaticWeights } from "../../core/embed/static.js";
|
|
94
|
+
import { heldExits } from "../../core/store/index.js";
|
|
95
|
+
// Retention's own reading and its own week, so the Raw transcripts line cannot
|
|
96
|
+
// promise a different number from the job that does the deleting. READ-ONLY:
|
|
97
|
+
// `remember/index.ts` re-exports the plan and the readers, never the deleter.
|
|
98
|
+
import { SpanBuffer, TUNABLES as REMEMBER_TUNABLES, lastRetentionRun } from "../../core/remember/index.js";
|
|
99
|
+
import {
|
|
100
|
+
awaitingWriteUp,
|
|
101
|
+
progressKey,
|
|
102
|
+
readWriteUpPointer,
|
|
103
|
+
readWriteUpProgress,
|
|
104
|
+
sameScope,
|
|
105
|
+
writeUpEntries,
|
|
106
|
+
writeUpPlan,
|
|
107
|
+
} from "../sessions.js";
|
|
92
108
|
import type { AdapterConfig } from "./config.js";
|
|
93
|
-
import { CREDENTIAL_NAMES } from "./credentials.js";
|
|
94
|
-
import type { CredentialLoad } from "./credentials.js";
|
|
95
109
|
// The same vocabulary the hook's stand-down uses, so the terminal and the
|
|
96
110
|
// console cannot end up with two answers to "why did it not open".
|
|
97
111
|
import { describeFault, faultId, faultPath } from "./standdown.js";
|
|
@@ -104,7 +118,7 @@ export interface Finding {
|
|
|
104
118
|
/** Stable machine name — the `--json` key and the notice's identity. */
|
|
105
119
|
readonly key: string;
|
|
106
120
|
readonly severity: Severity;
|
|
107
|
-
/** The column heading a human reads: "
|
|
121
|
+
/** The column heading a human reads: "Config", "Clock". */
|
|
108
122
|
readonly title: string;
|
|
109
123
|
/** One line of FACTS: paths, names, counts, dates. Never memory text. */
|
|
110
124
|
readonly detail: string;
|
|
@@ -115,9 +129,9 @@ export interface Finding {
|
|
|
115
129
|
/**
|
|
116
130
|
* AN OPTIONAL FEATURE THAT WAS NEVER TURNED ON — printed `OFF`, dim, and
|
|
117
131
|
* counted apart from the ambers (new-user findings #24, owner's answer 12 of
|
|
118
|
-
* 2026-09-22). One
|
|
119
|
-
* fresh install
|
|
120
|
-
*
|
|
132
|
+
* 2026-09-22). One optional thing nobody turned on used to produce three
|
|
133
|
+
* ambers on a fresh install, and a screen where nothing is wrong should not
|
|
134
|
+
* carry three warnings.
|
|
121
135
|
*
|
|
122
136
|
* IT IS A FLAG ON AMBER, NOT A FOURTH `Severity`, and that is the whole
|
|
123
137
|
* reason the JSON keeps `severity: "amber"`: every reader that switches on a
|
|
@@ -127,8 +141,8 @@ export interface Finding {
|
|
|
127
141
|
* and how it is counted, both of which live in this file (`worstFirst`,
|
|
128
142
|
* `reportLines`, `reportJson`) and nowhere else.
|
|
129
143
|
*
|
|
130
|
-
* NEVER on a feature that WAS working and has stopped:
|
|
131
|
-
*
|
|
144
|
+
* NEVER on a feature that WAS working and has stopped: `keyHistory` tells
|
|
145
|
+
* the two apart.
|
|
132
146
|
*/
|
|
133
147
|
readonly optional?: boolean;
|
|
134
148
|
}
|
|
@@ -169,41 +183,21 @@ export interface DoctorInput {
|
|
|
169
183
|
* `not-read` (2026-09-20, finding 6) is `--dir` with no `--config` under the
|
|
170
184
|
* explicit-dir guard: the store was NAMED, so it is read, and the default
|
|
171
185
|
* configuration beside it was not opened at all — because opening it is what
|
|
172
|
-
* would reach the owner's live
|
|
186
|
+
* would reach the owner's live configuration. Everything that comes out of
|
|
173
187
|
* a configuration then says so instead of grading a file nobody read.
|
|
174
188
|
*/
|
|
175
189
|
readonly configReason: "loaded" | "absent" | "unreadable" | "not-read" | null;
|
|
190
|
+
/**
|
|
191
|
+
* The keys `loadConfig` named when it could not read the file
|
|
192
|
+
* (`LoadedConfig.unreadableKeys` — today `embedder`, `embedder.enabled`,
|
|
193
|
+
* `embedder.kind`). Printed on the Config line so a person can fix the one
|
|
194
|
+
* key without reading the loader (review of #190, MINOR 5). Absent: the
|
|
195
|
+
* reader could not name one, or the caller did not pass it.
|
|
196
|
+
*/
|
|
197
|
+
readonly configUnreadableKeys?: readonly string[];
|
|
176
198
|
readonly config: AdapterConfig;
|
|
177
199
|
/** The store this reading actually read. */
|
|
178
200
|
readonly dir: string;
|
|
179
|
-
/**
|
|
180
|
-
* The credential load to REPORT ON, and the two callers hand in different
|
|
181
|
-
* ones on purpose:
|
|
182
|
-
*
|
|
183
|
-
* - The **console** loads the file against a SCRATCH environment, so what
|
|
184
|
-
* it reports is what the FILE holds. A console that counted its own shell
|
|
185
|
-
* would read green on the owner's machine — his `~/.zshrc` exports both
|
|
186
|
-
* names — while the hook processes, which inherit neither (measured day 0),
|
|
187
|
-
* stayed blind. That is I32 reproduced inside the diagnostic.
|
|
188
|
-
* - The **hook** hands in the load it already performed against its own
|
|
189
|
-
* `process.env` — and that is ALSO a reading of the file, which is what
|
|
190
|
-
* makes the two agree. `loadCredentials` pushes a name onto `loaded` or
|
|
191
|
-
* onto `skippedPresent` only when the FILE holds a line for it
|
|
192
|
-
* (`skippedPresent` means "the file offered this and the environment had
|
|
193
|
-
* already answered it"), so a template file answers nothing whatever the
|
|
194
|
-
* environment carries, and a hook launched from a shell that exports both
|
|
195
|
-
* keys still goes red on a blank file. Asserted in `test/doctor.test.ts`,
|
|
196
|
-
* because the whole PR turns on it.
|
|
197
|
-
*/
|
|
198
|
-
readonly credentials: CredentialLoad;
|
|
199
|
-
readonly credentialsPath: string | undefined;
|
|
200
|
-
/**
|
|
201
|
-
* Names the CALLER's environment answers, when the caller is the console.
|
|
202
|
-
* Reported as one extra clause on the finding for THAT NAME when the file
|
|
203
|
-
* lacks it — "I have that key" and "the hooks have that key" are two different
|
|
204
|
-
* facts, and the gap between them is what made I32 invisible.
|
|
205
|
-
*/
|
|
206
|
-
readonly shellNames?: readonly string[];
|
|
207
201
|
/** Null when there is no store at `dir` — the store findings then say so. */
|
|
208
202
|
readonly store: Store | null;
|
|
209
203
|
/** Today, UTC, `YYYY-MM-DD` — the same spelling every `date` field uses. */
|
|
@@ -759,6 +753,22 @@ function budgetTruncatedPhases(p: Record<string, unknown>): string[] {
|
|
|
759
753
|
return out;
|
|
760
754
|
}
|
|
761
755
|
|
|
756
|
+
/** ` (embedder.kind is not one it knows)`-shaped: the keys the loader named, or
|
|
757
|
+
* nothing when it named none. */
|
|
758
|
+
function unreadableClause(keys: readonly string[] | undefined): string {
|
|
759
|
+
if (keys === undefined || keys.length === 0) return "";
|
|
760
|
+
const known = keys.map((k) =>
|
|
761
|
+
k === "embedder.kind"
|
|
762
|
+
? 'embedder.kind — it must be "static"'
|
|
763
|
+
: k === "embedder.enabled"
|
|
764
|
+
? "embedder.enabled — it must be true or false"
|
|
765
|
+
: k === "embedder"
|
|
766
|
+
? "embedder — it must be an object"
|
|
767
|
+
: k,
|
|
768
|
+
);
|
|
769
|
+
return ` (${known.join("; ")})`;
|
|
770
|
+
}
|
|
771
|
+
|
|
762
772
|
/** The config file itself: the one the hooks read, and whether it was readable. */
|
|
763
773
|
function configFindings(input: DoctorInput): Finding[] {
|
|
764
774
|
const out: Finding[] = [];
|
|
@@ -766,14 +776,14 @@ function configFindings(input: DoctorInput): Finding[] {
|
|
|
766
776
|
if (reason === "not-read") {
|
|
767
777
|
// NOT A FAULT AND NOT A GRADE. `--dir` named a store; nothing named a
|
|
768
778
|
// configuration, and reading the default one is what would open somebody's
|
|
769
|
-
// live
|
|
779
|
+
// live configuration. So the store is graded and this line says, in the
|
|
770
780
|
// words the refusal used to use, exactly what to type to grade the rest.
|
|
771
781
|
out.push(
|
|
772
782
|
finding(
|
|
773
783
|
"config",
|
|
774
784
|
"amber",
|
|
775
785
|
"Config",
|
|
776
|
-
`not read — you named a store with --dir and no configuration, so nothing here grades ${input.configPath}: no
|
|
786
|
+
`not read — you named a store with --dir and no configuration, so nothing here grades ${input.configPath}: no embedder setting, no snapshot policy, no stance`,
|
|
777
787
|
`To grade those too: counterparts doctor --config <absolute path> (or set ${CONFIG_ENV}).`,
|
|
778
788
|
{ path: input.configPath, reason },
|
|
779
789
|
),
|
|
@@ -802,11 +812,17 @@ function configFindings(input: DoctorInput): Finding[] {
|
|
|
802
812
|
"config",
|
|
803
813
|
"red",
|
|
804
814
|
"Config",
|
|
805
|
-
`${input.configPath} — ${reason === "absent" ? "no such file" :
|
|
815
|
+
`${input.configPath} — ${reason === "absent" ? "no such file" : `unreadable${unreadableClause(input.configUnreadableKeys)}, so every entry point stands down to observer`}`,
|
|
806
816
|
reason === "absent"
|
|
807
817
|
? "Run: counterparts install (or point --config at the file you meant)."
|
|
808
818
|
: "Fix the JSON, or restore it from claude-code.json.bak beside it.",
|
|
809
|
-
{
|
|
819
|
+
{
|
|
820
|
+
path: input.configPath,
|
|
821
|
+
reason,
|
|
822
|
+
...(reason === "unreadable" && (input.configUnreadableKeys ?? []).length > 0
|
|
823
|
+
? { keys: (input.configUnreadableKeys ?? []).join(",") }
|
|
824
|
+
: {}),
|
|
825
|
+
},
|
|
810
826
|
),
|
|
811
827
|
);
|
|
812
828
|
} else {
|
|
@@ -820,6 +836,23 @@ function configFindings(input: DoctorInput): Finding[] {
|
|
|
820
836
|
{ path: input.configPath, reason: reason ?? "read-by-caller", dataDir: input.config.dataDir ?? null },
|
|
821
837
|
),
|
|
822
838
|
);
|
|
839
|
+
// SETTINGS THIS BUILD NO LONGER READS (keyless, 2026-09-24) — a quiet note,
|
|
840
|
+
// GREEN, never a warning: the owner's own configuration carries
|
|
841
|
+
// `credentialsFile` from the install that wrote it, and a key nobody needs
|
|
842
|
+
// any more is not a fault. Printed under `--all`; nothing to do.
|
|
843
|
+
const retired = input.config.retired ?? [];
|
|
844
|
+
if (retired.length > 0) {
|
|
845
|
+
out.push(
|
|
846
|
+
finding(
|
|
847
|
+
"retired",
|
|
848
|
+
"green",
|
|
849
|
+
"Old settings",
|
|
850
|
+
`${retired.join("; ")} — ignored; you may remove ${retired.length === 1 ? "it" : "them"} from ${tilde(input.configPath)}`,
|
|
851
|
+
"",
|
|
852
|
+
{ count: retired.length },
|
|
853
|
+
),
|
|
854
|
+
);
|
|
855
|
+
}
|
|
823
856
|
}
|
|
824
857
|
|
|
825
858
|
// THE STORE THE HOOKS WOULD OPEN, against the one this reading opened. I31's
|
|
@@ -910,48 +943,32 @@ function memoryDetail(input: DoctorInput, n: number | null): string {
|
|
|
910
943
|
}
|
|
911
944
|
|
|
912
945
|
/**
|
|
913
|
-
* RECALL BY MEANING — the
|
|
914
|
-
*
|
|
915
|
-
* **The finding (#24, the owner's 0.2.0 trial).**
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
*
|
|
922
|
-
*
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
* THE TWO GRADES THAT ARE NOT `OFF`, and why:
|
|
927
|
-
*
|
|
928
|
-
* - **Switched ON and no key**: the feature was asked for and cannot run, so
|
|
929
|
-
* every ask pays for an `embed-failed`. Amber, with the command that fixes
|
|
930
|
-
* it.
|
|
931
|
-
* - **Switched OFF on a store that HAS embedded**: something that was running
|
|
932
|
-
* has stopped. Amber, in the words that line has always used — never `OFF`,
|
|
933
|
-
* which claims nobody ever turned it on.
|
|
946
|
+
* RECALL BY MEANING — the local table, as ONE line.
|
|
947
|
+
*
|
|
948
|
+
* **The finding (#24, the owner's 0.2.0 trial).** An optional feature nobody
|
|
949
|
+
* turned on used to produce three ambers — the embedder, its key, and the
|
|
950
|
+
* unembedded vectors — and the fix line told him to hand-edit a JSON file
|
|
951
|
+
* (#19). A person reads that as a broken install. So it is one line, and a
|
|
952
|
+
* block switched off is `OFF`: optional, nothing wrong. `vectorFindings` says
|
|
953
|
+
* nothing at all while the embedder is off (there is nothing to embed).
|
|
954
|
+
*
|
|
955
|
+
* The one grade that is not `OFF` while it is off: **switched OFF on a store
|
|
956
|
+
* that HAS embedded** — something that was running has stopped. Amber, never
|
|
957
|
+
* `OFF`, which would claim nobody ever turned it on.
|
|
934
958
|
*/
|
|
935
|
-
function embedderFindings(input: DoctorInput, history: KeyHistory): Finding[] {
|
|
959
|
+
function embedderFindings(input: DoctorInput, history: KeyHistory, source: EmbedderSource): Finding[] {
|
|
936
960
|
const enabled = input.config.embedder?.enabled === true;
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const turnOn = `Turn on:
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
961
|
+
const data = { enabled, everEmbedded: history.embedded, source };
|
|
962
|
+
// The command it names turns ANY off block on as the local table
|
|
963
|
+
// (`install.ts#resolveEmbedderBlock`).
|
|
964
|
+
const turnOn = `Turn on: ${EMBEDDER_ON_COMMAND}`;
|
|
965
|
+
// THE STORE'S OWN VERDICT FIRST (review of #190, MAJOR 4): a hold or a newer
|
|
966
|
+
// build's cache turns the channel off whatever the configuration says, and
|
|
967
|
+
// it is read DURABLY — this handle is an observer and reconciles nothing.
|
|
944
968
|
if (enabled) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
"amber",
|
|
949
|
-
RECALL_TITLE,
|
|
950
|
-
`on, but ${EMBED_KEY_ENV} is not saved${shellClause(input, EMBED_KEY_ENV, present)} — so nothing is embedded and every ask pays for the attempt`,
|
|
951
|
-
`Run: counterparts credentials set ${EMBED_KEY_ENV}`,
|
|
952
|
-
data,
|
|
953
|
-
),
|
|
954
|
-
];
|
|
969
|
+
const withdrawn = withdrawnFinding(input);
|
|
970
|
+
if (withdrawn !== null) return [withdrawn];
|
|
971
|
+
return [staticFinding(input, data)];
|
|
955
972
|
}
|
|
956
973
|
if (history.embedded) {
|
|
957
974
|
// SAYS WHAT STILL WORKS (2026-09-20, finding 1). "No vectors, no semantic
|
|
@@ -973,7 +990,7 @@ function embedderFindings(input: DoctorInput, history: KeyHistory): Finding[] {
|
|
|
973
990
|
off(
|
|
974
991
|
"embedder",
|
|
975
992
|
RECALL_TITLE,
|
|
976
|
-
|
|
993
|
+
"switched off in the configuration. Recall works on words; the local table lets it match meaning too, and nothing leaves this machine.",
|
|
977
994
|
turnOn,
|
|
978
995
|
data,
|
|
979
996
|
),
|
|
@@ -981,183 +998,246 @@ function embedderFindings(input: DoctorInput, history: KeyHistory): Finding[] {
|
|
|
981
998
|
}
|
|
982
999
|
|
|
983
1000
|
const RECALL_TITLE = "Recall by meaning";
|
|
984
|
-
const CRASH_TITLE = "Crash write-up";
|
|
985
1001
|
|
|
986
1002
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
* have that key" and "the hooks have that key" are two different facts and this
|
|
994
|
-
* is where they are told apart.
|
|
1003
|
+
* THE COMMAND THAT TURNS RECALL BY MEANING ON for a configuration that exists
|
|
1004
|
+
* (roadmap C3). `install` writes the block only when it creates the file, so an
|
|
1005
|
+
* existing one — every 0.2.0 install, the owner's included — needs `--force`
|
|
1006
|
+
* to be rewritten, and `--force` carries every other key forward
|
|
1007
|
+
* (`commands.ts#carryForward`). One sentence, printed by doctor and quoted by
|
|
1008
|
+
* QUICKSTART.
|
|
995
1009
|
*/
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1010
|
+
export const EMBEDDER_ON_COMMAND = "counterparts install --force --embedder";
|
|
1011
|
+
|
|
1012
|
+
/** Where a static table's weights came from, in words (`resolveStaticWeights`'
|
|
1013
|
+
* `source`, or the worker row's `weights`). */
|
|
1014
|
+
function weightsFrom(source: string): string {
|
|
1015
|
+
if (source === "package") return `the ${STATIC_WEIGHTS_PACKAGE} package`;
|
|
1016
|
+
if (source === "env") return STATIC_WEIGHTS_ENV;
|
|
1017
|
+
if (source === "option") return "a directory named by the caller";
|
|
1018
|
+
return source;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* A HOLD, or a cache from a newer build — the two states in which the store
|
|
1023
|
+
* itself has taken the vector channel away (cache v5). Amber, and each names
|
|
1024
|
+
* its own way out; the grade is the same whichever embedder is configured,
|
|
1025
|
+
* because in both states nothing is ranked or embedded until somebody acts.
|
|
1026
|
+
*/
|
|
1027
|
+
function withdrawnFinding(input: DoctorInput): Finding | null {
|
|
1028
|
+
let v;
|
|
1029
|
+
try {
|
|
1030
|
+
v = input.store?.embedderVerdict;
|
|
1031
|
+
} catch {
|
|
1032
|
+
return null;
|
|
1033
|
+
}
|
|
1034
|
+
if (v === undefined) return null;
|
|
1035
|
+
if (v.kind === "held") {
|
|
1036
|
+
// Named for the hold AS IT IS (re-review MINOR B). Since 2026-09-24 the
|
|
1037
|
+
// model that wrote held rows — the removed Voyage seat, in practice — can
|
|
1038
|
+
// no longer be configured, so the one exit is to drop them.
|
|
1039
|
+
const from = v.recorded ?? "an older build that did not tag them (0.2.0 or earlier)";
|
|
1040
|
+
return finding(
|
|
1041
|
+
"embedder",
|
|
1042
|
+
"amber",
|
|
1043
|
+
RECALL_TITLE,
|
|
1044
|
+
`held — the store holds ${v.rows} vectors from ${from}, and the configuration asks for ${v.configured ?? "another model"}; ` +
|
|
1045
|
+
"nothing is embedded or matched by meaning until they are dropped. Recall still matches on words",
|
|
1046
|
+
`To match by meaning again, ${heldExits(v.recorded).replace("<store>", tilde(input.dir))}.`,
|
|
1047
|
+
{ held: true, recorded: v.recorded, configured: v.configured, rows: v.rows },
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
if (v.kind === "cache-ahead") {
|
|
1051
|
+
return finding(
|
|
1052
|
+
"embedder",
|
|
1053
|
+
"amber",
|
|
1054
|
+
RECALL_TITLE,
|
|
1055
|
+
`off in this process — the store's cache was written by a newer Counterparts (cache v${v.found}; this build reads v${v.expected}). Recall still matches on words`,
|
|
1056
|
+
"Update: bun add -g counterparts@latest — then in Claude Code run /mcp → Reconnect so the server loads it.",
|
|
1057
|
+
{ cacheAhead: true, found: v.found, expected: v.expected },
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
return null;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* THE LOCAL TABLE'S LINE (review of #190, MAJOR 3).
|
|
1065
|
+
*
|
|
1066
|
+
* - What the WORKER saw wins: its newest backfill row says which embedder
|
|
1067
|
+
* ran, where its weights came from, or — `embedder-unavailable` — the code
|
|
1068
|
+
* it refused with. That row is written in the hooks' own environment, which
|
|
1069
|
+
* is not the console's (I32).
|
|
1070
|
+
* - With no row yet, this process looks for the table itself, and says that
|
|
1071
|
+
* the first boundary will confirm it.
|
|
1072
|
+
*/
|
|
1073
|
+
function staticFinding(input: DoctorInput, data: Record<string, string | number | boolean | null>): Finding {
|
|
1074
|
+
const install = `Install the table: bun add -g ${STATIC_WEIGHTS_PACKAGE} — or set ${STATIC_WEIGHTS_ENV} in the environment Claude Code starts hooks with`;
|
|
1075
|
+
const row = newestBackfill(input);
|
|
1076
|
+
if (row !== null && str(row, "reason") === "embedder-unavailable") {
|
|
1077
|
+
const code = str(row, "codes") ?? "NO_WEIGHTS";
|
|
1078
|
+
return finding(
|
|
1079
|
+
"embedder",
|
|
1080
|
+
"amber",
|
|
1081
|
+
RECALL_TITLE,
|
|
1082
|
+
`on (a local table), but the worker could not load its weights (${code}) — nothing is embedded; recall still matches on words`,
|
|
1083
|
+
code === "HASH_MISMATCH" ? `The table on disk is not the one its package declares. Reinstall it: bun add -g ${STATIC_WEIGHTS_PACKAGE}` : install,
|
|
1084
|
+
{ ...data, kind: "static", code },
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
if (row !== null && str(row, "kind") === "static" && str(row, "weights") !== null) {
|
|
1088
|
+
return finding(
|
|
1089
|
+
"embedder",
|
|
1090
|
+
"green",
|
|
1091
|
+
RECALL_TITLE,
|
|
1092
|
+
`on — a local table (${str(row, "model") ?? "static"}, weights from ${weightsFrom(String(str(row, "weights")))}); nothing leaves this machine`,
|
|
1093
|
+
"",
|
|
1094
|
+
{ ...data, kind: "static", weights: str(row, "weights") },
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
const found = resolveStaticWeights();
|
|
1098
|
+
// THE TABLE FILE, not just a folder: a `COUNTERPARTS_STATIC_WEIGHTS_DIR`
|
|
1099
|
+
// naming an empty or wrong folder is found by name and holds nothing, and a
|
|
1100
|
+
// green here would last until the first worker row said NO_WEIGHTS.
|
|
1101
|
+
if (found === null || !existsSync(join(found.dir, MODEL_FILE))) {
|
|
1102
|
+
return finding(
|
|
1103
|
+
"embedder",
|
|
1104
|
+
"amber",
|
|
1105
|
+
RECALL_TITLE,
|
|
1106
|
+
found === null
|
|
1107
|
+
? "on (a local table), but its weights were not found — nothing will be embedded; recall still matches on words"
|
|
1108
|
+
: `on (a local table), but its weights were not found in ${tilde(found.dir)} (named by ${weightsFrom(found.source)}) — nothing will be embedded; recall still matches on words`,
|
|
1109
|
+
install,
|
|
1110
|
+
{ ...data, kind: "static", weights: null },
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
return finding(
|
|
1114
|
+
"embedder",
|
|
1115
|
+
"green",
|
|
1116
|
+
RECALL_TITLE,
|
|
1117
|
+
`on — a local table (weights from ${weightsFrom(found.source)}); nothing leaves this machine (the hooks confirm it when a session ends)`,
|
|
1118
|
+
"",
|
|
1119
|
+
{ ...data, kind: "static", weights: found.source },
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/** The newest backfill row's payload, or null — one bounded read, never a throw. */
|
|
1124
|
+
function newestBackfill(input: DoctorInput): Record<string, unknown> | null {
|
|
1125
|
+
const store = input.store;
|
|
1126
|
+
if (store === null) return null;
|
|
1127
|
+
try {
|
|
1128
|
+
const read = newestRows(store, EMBED_BACKFILL_EVENT, 1, store.livedDay());
|
|
1129
|
+
const row = read.rows[0];
|
|
1130
|
+
return row === undefined ? null : payloadOf(row);
|
|
1131
|
+
} catch {
|
|
1132
|
+
return null;
|
|
1133
|
+
}
|
|
1000
1134
|
}
|
|
1001
1135
|
|
|
1002
1136
|
/**
|
|
1003
|
-
* HAS THIS STORE EVER
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1011
|
-
* The red was written for a real and serious case, so it is kept for that case
|
|
1012
|
-
* and only that one: a key that was HERE and has gone. The discriminator is the
|
|
1013
|
-
* store's own evidence, never a marker file — a marker would have to be written
|
|
1014
|
-
* by something, and the thing that would write it is the thing that is missing.
|
|
1015
|
-
*
|
|
1016
|
-
* - The interpreter ran if anything was ever interpreted. `gate.chunk` is the
|
|
1017
|
-
* crash sweep's own row and the sweep is the only interpreted write path,
|
|
1018
|
-
* so one such row ever is proof the key worked here.
|
|
1019
|
-
* - The embedder ran if any backfill ever embedded anything.
|
|
1020
|
-
*
|
|
1021
|
-
* Both are ONE bounded read each, over the whole log, and both answer "ever",
|
|
1022
|
-
* so neither can be undone by retention sweeping the window.
|
|
1023
|
-
*
|
|
1024
|
-
* **THE FALSE NEGATIVE, stated.** A key that was present and never EXERCISED —
|
|
1025
|
-
* no session ever crashed, so the sweep never ran — leaves no `gate.chunk`, and
|
|
1026
|
-
* removing it reads amber where the owner might want red. That is the direction
|
|
1027
|
-
* this errs on purpose: the amber still names the key and still says what it
|
|
1028
|
-
* would add, so nothing is hidden; the alternative errs towards telling every
|
|
1029
|
-
* new user their install is broken. Revisit if a second signal appears that
|
|
1030
|
-
* proves the key worked without the sweep having run.
|
|
1137
|
+
* HAS THIS STORE EVER EMBEDDED (2026-09-20, finding 1).
|
|
1138
|
+
*
|
|
1139
|
+
* The discriminator between "switched off, never used" (`OFF`) and "was
|
|
1140
|
+
* running and has stopped" (amber) on the Recall by meaning line. The store's
|
|
1141
|
+
* own evidence, never a marker file: any backfill that ever embedded anything,
|
|
1142
|
+
* over a bounded window of the OLDEST rows, which is where a table that worked
|
|
1143
|
+
* and was then switched off would be. (It read the Anthropic key's history
|
|
1144
|
+
* too, until that key was removed on 2026-09-24.)
|
|
1031
1145
|
*/
|
|
1032
1146
|
interface KeyHistory {
|
|
1033
|
-
readonly interpreted: boolean;
|
|
1034
1147
|
readonly embedded: boolean;
|
|
1035
1148
|
}
|
|
1036
1149
|
|
|
1037
1150
|
export function keyHistory(store: Store | null): KeyHistory {
|
|
1038
|
-
if (store === null) return {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
return {
|
|
1050
|
-
// ONE ROW. `eventLog` orders ascending and `events_name` is an index, so
|
|
1051
|
-
// "has there ever been one" is the cheapest question this file asks.
|
|
1052
|
-
interpreted: any(GATE_CHUNK_EVENT, 1, () => true),
|
|
1053
|
-
// A backfill row exists with or without a key — it records what is still
|
|
1054
|
-
// waiting — so this one has to look at the number, over a bounded window of
|
|
1055
|
-
// the OLDEST rows, which is where a key that worked and then went would be.
|
|
1056
|
-
embedded: any(EMBED_BACKFILL_EVENT, KEY_HISTORY_ROWS, (p) => (num(p, "embedded") ?? 0) > 0),
|
|
1057
|
-
};
|
|
1151
|
+
if (store === null) return { embedded: false };
|
|
1152
|
+
try {
|
|
1153
|
+
return {
|
|
1154
|
+
embedded: store
|
|
1155
|
+
.eventLog({ name: EMBED_BACKFILL_EVENT, limit: KEY_HISTORY_ROWS })
|
|
1156
|
+
.some((r) => (num(payloadOf(r), "embedded") ?? 0) > 0),
|
|
1157
|
+
};
|
|
1158
|
+
} catch {
|
|
1159
|
+
// A store that will not answer is not a store that says "never".
|
|
1160
|
+
return { embedded: false };
|
|
1161
|
+
}
|
|
1058
1162
|
}
|
|
1059
1163
|
|
|
1060
|
-
/** How many backfill rows the "has
|
|
1164
|
+
/** How many backfill rows the "has this store ever embedded" read looks at. */
|
|
1061
1165
|
const KEY_HISTORY_ROWS = 200;
|
|
1062
1166
|
|
|
1063
|
-
/** What a store with no key still does, in one sentence a new user can act on. */
|
|
1064
|
-
const WITHOUT_A_KEY =
|
|
1065
|
-
"everything you and the assistant write by hand still lands — note, session_end, the journal, " +
|
|
1066
|
-
"recall, the wake";
|
|
1067
|
-
|
|
1068
1167
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1168
|
+
* RAW TRANSCRIPTS — how long the captured conversation is kept, and what the
|
|
1169
|
+
* newest retention pass did (remember INTERFACE-GAPS §11; roadmap B3).
|
|
1170
|
+
*
|
|
1171
|
+
* The first clause is the POLICY, worded so it does not over-promise (PR #189
|
|
1172
|
+
* review m4, m5): the text lives in the store for a week after a session ends,
|
|
1173
|
+
* and each daily snapshot holds a copy of whatever was there that day, so the
|
|
1174
|
+
* last copy is gone only after the snapshots rotate past it too. Both numbers
|
|
1175
|
+
* are read — the week from `remember/`'s tunable, the snapshots from the
|
|
1176
|
+
* configuration's `keep` — never retyped.
|
|
1177
|
+
*
|
|
1178
|
+
* The rest is the newest `remember.prune` row, in sessions. Grades:
|
|
1179
|
+
*
|
|
1180
|
+
* - **green** with no row at all: a store the worker has not reached yet
|
|
1181
|
+
* has nothing to prune, and that is not a fault;
|
|
1182
|
+
* - **amber** when the newest pass could not delete something (`failed`), or
|
|
1183
|
+
* when it is a `STARTED` / `LATCH_HELD` row from a day before today — a
|
|
1184
|
+
* pass that took its latch and never wrote its result;
|
|
1185
|
+
* - **green** otherwise, `STARTED` today included (a pass is under way).
|
|
1186
|
+
*
|
|
1187
|
+
* "kept until written up" is a session that still owes its write-up (B3's
|
|
1188
|
+
* predicate); it is kept until the next session in its project writes it up.
|
|
1073
1189
|
*/
|
|
1074
|
-
function
|
|
1075
|
-
const
|
|
1076
|
-
const
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1079
|
-
const
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
|
|
1190
|
+
function retentionFindings(input: DoctorInput, store: Store): Finding[] {
|
|
1191
|
+
const TITLE = "Raw transcripts";
|
|
1192
|
+
const days = Math.round(REMEMBER_TUNABLES.RETENTION_MS / 86_400_000);
|
|
1193
|
+
const keep = keepOf(input.config.snapshots?.keep);
|
|
1194
|
+
const policy = `${String(days)} days after a session ends (up to ${String(days + keep)} counting the daily snapshots)`;
|
|
1195
|
+
const run = lastRetentionRun(store);
|
|
1196
|
+
const base = { retentionDays: days, snapshotKeep: keep };
|
|
1197
|
+
if (run === null) {
|
|
1198
|
+
return [finding("retention", "green", TITLE, `${policy} · not run yet`, "", { ...base, ran: false })];
|
|
1199
|
+
}
|
|
1083
1200
|
const data = {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1201
|
+
...base,
|
|
1202
|
+
ran: true,
|
|
1203
|
+
date: run.date,
|
|
1204
|
+
reason: run.reason,
|
|
1205
|
+
deleted: run.deleted,
|
|
1206
|
+
keptOwed: run.keptOwed,
|
|
1207
|
+
keptYoung: run.keptYoung,
|
|
1208
|
+
keptLive: run.keptLive,
|
|
1209
|
+
failed: run.failed,
|
|
1091
1210
|
};
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
// a fault, it is a feature nobody turned on, and the `OFF` line for that
|
|
1096
|
-
// feature says so in the words of the thing it buys. This line keeps the
|
|
1097
|
-
// names, because "which keys are saved" is a question with one answer and
|
|
1098
|
-
// `doctor --all` is where it lives.
|
|
1099
|
-
if (missing.includes(API_KEY_ENV) && history.interpreted) {
|
|
1100
|
-
// RED only when the key WORKED here and is now gone — the case this line
|
|
1101
|
-
// was written for, and the one case `OFF` may never swallow.
|
|
1102
|
-
out.push(
|
|
1211
|
+
const unfinished = run.reason === "STARTED" || run.reason === "LATCH_HELD";
|
|
1212
|
+
if (unfinished && run.date < input.today) {
|
|
1213
|
+
return [
|
|
1103
1214
|
finding(
|
|
1104
|
-
"
|
|
1105
|
-
"
|
|
1106
|
-
|
|
1107
|
-
`${
|
|
1108
|
-
|
|
1215
|
+
"retention",
|
|
1216
|
+
"amber",
|
|
1217
|
+
TITLE,
|
|
1218
|
+
`${policy} · the pass on ${run.date} started and did not finish, and none has run since`,
|
|
1219
|
+
"Nothing is deleted without a finished pass. It runs again when a session ends; to watch it: counterparts doctor --all",
|
|
1109
1220
|
data,
|
|
1110
1221
|
),
|
|
1111
|
-
|
|
1112
|
-
} else {
|
|
1113
|
-
out.push(finding("credentials", "green", "Credentials", `${where} ${holds}`, "", data));
|
|
1114
|
-
out.push(
|
|
1115
|
-
missing.includes(API_KEY_ENV)
|
|
1116
|
-
? // THE CRASH SWEEP, AS THE THING IT BUYS. No key has ever been used
|
|
1117
|
-
// here, which is a supported way to run — `WITHOUT_A_KEY` is the long
|
|
1118
|
-
// form of that sentence, kept on the finding rather than printed as a
|
|
1119
|
-
// warning on a screen where nothing is wrong.
|
|
1120
|
-
off(
|
|
1121
|
-
"crash-writeup",
|
|
1122
|
-
CRASH_TITLE,
|
|
1123
|
-
`optional. An Anthropic key lets a session that ended too soon get written up anyway.${shellClause(input, API_KEY_ENV, present)}`,
|
|
1124
|
-
`Turn on: counterparts credentials set ${API_KEY_ENV}`,
|
|
1125
|
-
{ ...data, without: WITHOUT_A_KEY },
|
|
1126
|
-
)
|
|
1127
|
-
: // AND A GREEN ROW WHEN IT IS ON (coordinator, 2026-09-22), mirroring
|
|
1128
|
-
// `Recall by meaning`'s. A feature that says `OFF` until you turn it
|
|
1129
|
-
// on and then says nothing at all leaves the person who just added
|
|
1130
|
-
// the key with no confirmation on the screen they were told to check
|
|
1131
|
-
// — and the factual `Credentials` line, which does carry the name,
|
|
1132
|
-
// only prints under `--all`.
|
|
1133
|
-
finding(
|
|
1134
|
-
"crash-writeup",
|
|
1135
|
-
"green",
|
|
1136
|
-
CRASH_TITLE,
|
|
1137
|
-
"on — a session that ended too soon gets written up anyway",
|
|
1138
|
-
"",
|
|
1139
|
-
data,
|
|
1140
|
-
),
|
|
1141
|
-
);
|
|
1222
|
+
];
|
|
1142
1223
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
out.push(
|
|
1224
|
+
if (unfinished) {
|
|
1225
|
+
return [finding("retention", "green", TITLE, `${policy} · a pass started today`, "", data)];
|
|
1226
|
+
}
|
|
1227
|
+
const counts = `${String(run.deleted)} pruned ${run.date} · ${String(run.keptOwed)} kept until written up · ${String(run.keptLive)} still open`;
|
|
1228
|
+
if (run.failed > 0) {
|
|
1229
|
+
return [
|
|
1150
1230
|
finding(
|
|
1151
|
-
"
|
|
1231
|
+
"retention",
|
|
1152
1232
|
"amber",
|
|
1153
|
-
|
|
1154
|
-
`${
|
|
1155
|
-
`
|
|
1156
|
-
|
|
1233
|
+
TITLE,
|
|
1234
|
+
`${policy} · ${counts} · ${String(run.failed)} could not be deleted`,
|
|
1235
|
+
`The next pass tries again. Check the folder is writable: ls -ld ${tilde(input.dir)}/spans`,
|
|
1236
|
+
data,
|
|
1157
1237
|
),
|
|
1158
|
-
|
|
1238
|
+
];
|
|
1159
1239
|
}
|
|
1160
|
-
return
|
|
1240
|
+
return [finding("retention", "green", TITLE, `${policy} · ${counts}`, "", data)];
|
|
1161
1241
|
}
|
|
1162
1242
|
|
|
1163
1243
|
/** The two clocks, and the gap that IS I32's signature. */
|
|
@@ -1232,36 +1312,23 @@ function rowFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1232
1312
|
const reason = str(p, "reason") ?? "(none)";
|
|
1233
1313
|
const detail = `newest sweep.gate ${rowDate(sweep) ?? "?"}: reason ${reason}, ran ${num(p, "ran") ?? 0} of ${num(p, "scopes") ?? 0} scopes`;
|
|
1234
1314
|
/**
|
|
1235
|
-
* THE
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
* until the next session boundary wrote a fresh row — hours, on a quiet
|
|
1240
|
-
* afternoon — with a fix line telling the reader to do the thing they had
|
|
1241
|
-
* just done. A standing amber nobody can clear is how a person learns to
|
|
1242
|
-
* read amber as decoration.
|
|
1243
|
-
*
|
|
1244
|
-
* So: the newest row says it stood down for want of a key AND the
|
|
1245
|
-
* credentials file holds one NOW. Nothing is wrong, and there is nothing to
|
|
1246
|
-
* fix, so it is GREEN and says which of the two facts it is looking at. The
|
|
1247
|
-
* credentials come from the FILE, never the environment — `credentialFindings`
|
|
1248
|
-
* keeps the same rule, and a hook process inherits no shell.
|
|
1315
|
+
* THE SWEEP NEVER INTERPRETS HERE ANY MORE (keyless, 2026-09-24): the worker
|
|
1316
|
+
* writes `not-opted-in`, and a row from an older build wrote `no-credential`
|
|
1317
|
+
* for the same keyless day — both are the ordinary state, GREEN, with the
|
|
1318
|
+
* next session writing crashed sessions up.
|
|
1249
1319
|
*/
|
|
1250
|
-
const
|
|
1251
|
-
API_KEY_ENV,
|
|
1252
|
-
);
|
|
1253
|
-
const answered = reason === "no-credential" && keyNow;
|
|
1320
|
+
const nextSession = reason === "not-opted-in" || reason === "no-credential";
|
|
1254
1321
|
out.push(
|
|
1255
1322
|
reason === "ran"
|
|
1256
1323
|
? finding("sweep", "green", "Sweep", detail, "", { reason, ran: num(p, "ran"), date: rowDate(sweep) })
|
|
1257
|
-
:
|
|
1324
|
+
: nextSession
|
|
1258
1325
|
? finding(
|
|
1259
1326
|
"sweep",
|
|
1260
1327
|
"green",
|
|
1261
1328
|
"Sweep",
|
|
1262
|
-
`${detail} — that
|
|
1329
|
+
`${detail} — next session: a session that ended unwritten is written up by the next session in its project`,
|
|
1263
1330
|
"",
|
|
1264
|
-
{ reason, ran: num(p, "ran"), date: rowDate(sweep)
|
|
1331
|
+
{ reason, ran: num(p, "ran"), date: rowDate(sweep) },
|
|
1265
1332
|
)
|
|
1266
1333
|
: finding("sweep", "amber", "Sweep", detail, "The sweep stood down; the reason names why.", {
|
|
1267
1334
|
reason,
|
|
@@ -1314,7 +1381,7 @@ function rowFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1314
1381
|
out.push(unread("backfill", "Backfill", EMBED_BACKFILL_EVENT));
|
|
1315
1382
|
} else if (newest === undefined) {
|
|
1316
1383
|
out.push(
|
|
1317
|
-
absent("backfill", "Backfill", "no adapter.embed.backfill row — nothing has been embedded here", "Read the
|
|
1384
|
+
absent("backfill", "Backfill", "no adapter.embed.backfill row — nothing has been embedded here", "Read the Recall by meaning line."),
|
|
1318
1385
|
);
|
|
1319
1386
|
} else {
|
|
1320
1387
|
const p = payloadOf(newest);
|
|
@@ -1332,8 +1399,22 @@ function rowFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1332
1399
|
(num(prior, "embedded") ?? 0) === 0 &&
|
|
1333
1400
|
(num(prior, "failed") ?? 0) > 0;
|
|
1334
1401
|
const data = { embedded, failed, remaining: num(p, "remaining"), skipped: num(p, "skipped"), codes: str(p, "codes"), date: rowDate(newest) };
|
|
1402
|
+
// NOT GREEN WHEN NOTHING COULD RUN (review of #190, MAJOR 4): a withdrawn
|
|
1403
|
+
// channel or an embedder that could not be built has `failed: 0` because it
|
|
1404
|
+
// never tried, which is the opposite of healthy.
|
|
1405
|
+
const why = str(p, "reason");
|
|
1406
|
+
const idle = why === "vectors-withdrawn" || why === "embedder-unavailable";
|
|
1335
1407
|
out.push(
|
|
1336
|
-
|
|
1408
|
+
idle
|
|
1409
|
+
? finding(
|
|
1410
|
+
"backfill",
|
|
1411
|
+
"amber",
|
|
1412
|
+
"Backfill",
|
|
1413
|
+
`${detail} — ${why === "vectors-withdrawn" ? "the store has withdrawn the vector channel" : "the embedder could not be built"}, so nothing was tried`,
|
|
1414
|
+
"Read the Recall by meaning line.",
|
|
1415
|
+
{ ...data, reason: why },
|
|
1416
|
+
)
|
|
1417
|
+
: stalledTwice
|
|
1337
1418
|
? finding("backfill", "red", "Backfill", `${detail} — and the run before it embedded nothing too`, "The backfill is head-of-line blocked; the codes name the fault (see I33).", data)
|
|
1338
1419
|
: failed > 0
|
|
1339
1420
|
? finding("backfill", "amber", "Backfill", detail, "Some chunks failed; the codes name why.", data)
|
|
@@ -1363,59 +1444,38 @@ function rowFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1363
1444
|
}
|
|
1364
1445
|
|
|
1365
1446
|
/**
|
|
1366
|
-
* WHO IS DOING THE WRITING — one week of it, in
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
*
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
*
|
|
1390
|
-
* Counting them together let the line blame the per-session allowance for
|
|
1391
|
-
* refusals it never made, which is a diagnostic naming the wrong door. The
|
|
1392
|
-
* amber hint therefore keys on the NEW reason alone; the old one is still
|
|
1393
|
-
* counted and named, because the days it recorded are still in the window.
|
|
1394
|
-
* - **The answers** (`gate.deposit`): what the session handed back.
|
|
1395
|
-
* - **The memories** (`memories.source`): how many live memories of the week
|
|
1396
|
-
* the session wrote itself, against how many were written for it later.
|
|
1397
|
-
*
|
|
1398
|
-
* AMBER on either of two comparisons, and never red — this is a balance, not a
|
|
1399
|
-
* fault, and nothing here means the machine is broken.
|
|
1400
|
-
*
|
|
1401
|
-
* The window is CALENDAR days, taken from the payload's own `date` (else the
|
|
1402
|
-
* row's wall clock), never the lived-day column: the lived clock is advanced by
|
|
1403
|
-
* the worker and has run seven lived days across fifteen calendar ones on this
|
|
1404
|
-
* very store. `sinceDay` is used only to keep the SQL cheap, and a lived day is
|
|
1405
|
-
* never longer than a calendar day, so `livedDay - 7` cannot miss a row inside
|
|
1406
|
-
* the window.
|
|
1447
|
+
* WHO IS DOING THE WRITING — one week of it, in plain counts.
|
|
1448
|
+
*
|
|
1449
|
+
* Finding 12 (2026-09-17): the crash fallback out-wrote the session 4.5 : 1
|
|
1450
|
+
* while every surface read healthy, because nobody read out how often the
|
|
1451
|
+
* session was OFFERED the pen and how much of the week it wrote. Both come out
|
|
1452
|
+
* of rows the store already keeps (constitution 11):
|
|
1453
|
+
*
|
|
1454
|
+
* - **the asks, by `outcome`** (`adapter.ask`): `asked` went out, `paced` was
|
|
1455
|
+
* refused by the pacer, `capped` by the session's allowance for the day
|
|
1456
|
+
* (`reason: session-ask-cap`; rows before 2026-09-17 say `day-chapter-cap`,
|
|
1457
|
+
* the old shared cap, and are counted apart in `data`);
|
|
1458
|
+
* - **the answers** (`gate.deposit`);
|
|
1459
|
+
* - **the memories** (`memories.source`): the week's live memories the
|
|
1460
|
+
* session wrote itself, against those the fallback sweep wrote for it.
|
|
1461
|
+
*
|
|
1462
|
+
* GREEN, with counts: cap refusals and the sweep's share are not losses, and
|
|
1463
|
+
* the one loss it could name — a session that owes a write-up (B3's
|
|
1464
|
+
* predicate) unwritten past `WRITE_UP_WAIT_DAYS` — is the `Crash write-up`
|
|
1465
|
+
* line's amber. This line carries that count as detail, or says "unknown"
|
|
1466
|
+
* when it could not be read. The session-start reading does not read the owed
|
|
1467
|
+
* sessions (it walks every scope's words), so there the line omits them.
|
|
1468
|
+
*
|
|
1469
|
+
* The window is CALENDAR days, from the payload's own `date` (else the row's
|
|
1470
|
+
* wall clock), never the lived-day column; `sinceDay` only keeps the SQL cheap.
|
|
1407
1471
|
*/
|
|
1408
1472
|
export const AUTHORSHIP_DAYS = 7;
|
|
1409
1473
|
|
|
1410
|
-
/** The cap in force. Declared `satisfies AskReason`
|
|
1411
|
-
*
|
|
1412
|
-
* zero one morning. */
|
|
1474
|
+
/** The cap in force. Declared `satisfies AskReason` so a rename in
|
|
1475
|
+
* `self/episodes.ts` fails `tsc` here instead of quietly reading zero. */
|
|
1413
1476
|
const SESSION_ASK_CAP = "session-ask-cap" satisfies AskReason;
|
|
1414
1477
|
|
|
1415
|
-
/** The
|
|
1416
|
-
* session of a lived day. Nothing writes it now and it is not in `AskReason`
|
|
1417
|
-
* any more, but the rows it wrote are still inside a seven-day window and a
|
|
1418
|
-
* count that folded them into the new cap would name the wrong door. */
|
|
1478
|
+
/** The shared day cap in force until 2026-09-17. Nothing writes it now. */
|
|
1419
1479
|
const DAY_CHAPTER_CAP = "day-chapter-cap";
|
|
1420
1480
|
|
|
1421
1481
|
/** The ceiling on one authorship read. A week of the owner's busiest recorded
|
|
@@ -1451,17 +1511,39 @@ const STORE_STARTED_META = "store.started";
|
|
|
1451
1511
|
* 2. `store.started` — `start-fresh`'s own record of the day a blank store
|
|
1452
1512
|
* took a parked one's place.
|
|
1453
1513
|
*
|
|
1454
|
-
* **Absent on every store made before 2026-09-21
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1514
|
+
* **Absent on every store made before 2026-09-21** — every store 0.1.0 made,
|
|
1515
|
+
* which is why finding #8 stayed open for them after 0.2.0 closed it for new
|
|
1516
|
+
* ones. So when neither record is there, the store's own evidence stands in
|
|
1517
|
+
* (2026-09-23), and the EARLIER of two readings wins:
|
|
1518
|
+
*
|
|
1519
|
+
* 3. **The oldest event row's `at`** — the moment a row was WRITTEN, on the
|
|
1520
|
+
* store's own provenance clock, and the smallest one (`eventLogCensus`'s
|
|
1521
|
+
* `MIN(at)`), not the first row by insertion order. Not `rowDate`: that
|
|
1522
|
+
* prefers the payload's `date` field, the day the event is ABOUT.
|
|
1523
|
+
* 4. **The database file's birth time.** A filesystem that keeps none reports
|
|
1524
|
+
* zero, or — Node's documentation allows it — the change time instead;
|
|
1525
|
+
* a birth time that is not EARLIER than the change time is therefore read
|
|
1526
|
+
* as "no answer" rather than trusted.
|
|
1527
|
+
*
|
|
1528
|
+
* **WHICH WAY THESE CAN BE WRONG, said plainly (review of #188, M2): YOUNGER.**
|
|
1529
|
+
* Each is the latest day the store could have begun, never the earliest: no
|
|
1530
|
+
* row is written before the store exists, and `install` writes no event, so a
|
|
1531
|
+
* store installed on the 3rd and first used on the 10th has its oldest row on
|
|
1532
|
+
* the 10th; a database restored from a copy is born the day it was copied.
|
|
1533
|
+
* Taking the earlier of the two answers the common case — an installed-but-idle
|
|
1534
|
+
* store, whose FILE was born on the 3rd — and leaves one: a store that was both
|
|
1535
|
+
* copied into place and idle before its first row. Its label then starts later
|
|
1536
|
+
* than the store did, and hides days on which nothing was invited — the very
|
|
1537
|
+
* silence the Authorship line exists to show. The READING is untouched either
|
|
1538
|
+
* way (`windowShown` moves only the words), which is why a label that can err
|
|
1539
|
+
* in that one case was judged worth having for every 0.1.0 store rather than
|
|
1540
|
+
* no label at all. Event pruning does not add a case: a row goes only at 90
|
|
1541
|
+
* lived days, far outside a seven-day window.
|
|
1542
|
+
*
|
|
1543
|
+
* TWO THINGS THAT LOOK LIKE SOURCES AND ARE NOT. A memory's `learned_on` — an
|
|
1544
|
+
* imported store carries dates from long before it existed. `livedDay` — the
|
|
1545
|
+
* physics clock, which the worker advances and which is 0 on a store whose
|
|
1546
|
+
* worker has never run.
|
|
1465
1547
|
*/
|
|
1466
1548
|
function storeFirstDay(store: Store): string | null {
|
|
1467
1549
|
let first: string | null = null;
|
|
@@ -1470,7 +1552,35 @@ function storeFirstDay(store: Store): string | null {
|
|
|
1470
1552
|
if (said === undefined || !/^\d{4}-\d{2}-\d{2}$/.test(said)) continue;
|
|
1471
1553
|
if (first === null || said < first) first = said;
|
|
1472
1554
|
}
|
|
1473
|
-
return first;
|
|
1555
|
+
if (first !== null) return first;
|
|
1556
|
+
const readings = [oldestEventDay(store), databaseBirthDay(store.dir)].filter(
|
|
1557
|
+
(d): d is string => d !== null,
|
|
1558
|
+
);
|
|
1559
|
+
return readings.length === 0 ? null : readings.reduce((a, b) => (b < a ? b : a));
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/** The calendar day (UTC) of the EARLIEST `at` among the store's event rows,
|
|
1563
|
+
* or null when it has none, or none that can be read. */
|
|
1564
|
+
function oldestEventDay(store: Store): string | null {
|
|
1565
|
+
try {
|
|
1566
|
+
const at = store.eventLogCensus().oldestAt;
|
|
1567
|
+
return typeof at === "number" && Number.isFinite(at) && at > 0 ? dateOf(at) : null;
|
|
1568
|
+
} catch {
|
|
1569
|
+
return null;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
/** The calendar day (UTC) the store's database file was born, or null when the
|
|
1574
|
+
* filesystem keeps no birth time — zero, or a "birth" no earlier than the last
|
|
1575
|
+
* change, which is what a filesystem without one may report instead. */
|
|
1576
|
+
function databaseBirthDay(dir: string): string | null {
|
|
1577
|
+
try {
|
|
1578
|
+
const stat = statSync(paths.operational(dir));
|
|
1579
|
+
const born = stat.birthtimeMs;
|
|
1580
|
+
return Number.isFinite(born) && born > 0 && born < stat.ctimeMs ? dateOf(born) : null;
|
|
1581
|
+
} catch {
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1474
1584
|
}
|
|
1475
1585
|
|
|
1476
1586
|
/**
|
|
@@ -1527,21 +1637,7 @@ function rowsInWindow(
|
|
|
1527
1637
|
};
|
|
1528
1638
|
}
|
|
1529
1639
|
|
|
1530
|
-
|
|
1531
|
-
* clock for "too new to grade". Null when it read none at all. */
|
|
1532
|
-
function oldestAuthorshipDate(
|
|
1533
|
-
asks: readonly EventRow[],
|
|
1534
|
-
deposits: readonly EventRow[],
|
|
1535
|
-
): string | null {
|
|
1536
|
-
let oldest: string | null = null;
|
|
1537
|
-
for (const row of [...asks, ...deposits]) {
|
|
1538
|
-
const date = rowDate(row);
|
|
1539
|
-
if (date !== null && (oldest === null || date < oldest)) oldest = date;
|
|
1540
|
-
}
|
|
1541
|
-
return oldest;
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
function authorshipFindings(input: DoctorInput, store: Store): Finding[] {
|
|
1640
|
+
function authorshipFindings(input: DoctorInput, store: Store, owedReading: OwedSource): Finding[] {
|
|
1545
1641
|
const livedDay = store.livedDay();
|
|
1546
1642
|
// Inclusive of today: seven calendar days means today and the six before it.
|
|
1547
1643
|
const from = daysBefore(input.today, AUTHORSHIP_DAYS - 1);
|
|
@@ -1596,40 +1692,30 @@ function authorshipFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1596
1692
|
const shown = windowShown(from, input.today, storeFirstDay(store));
|
|
1597
1693
|
// "of that week" is part of the same claim, and has to go with it.
|
|
1598
1694
|
const span = shown === from ? "of that week" : "in that time";
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
const cappedSplit = [
|
|
1605
|
-
cappedBySession === 0 ? "" : `${String(cappedBySession)} by a session's own allowance for the day`,
|
|
1606
|
-
cappedByDay === 0 ? "" : `${String(cappedByDay)} by the old shared day cap`,
|
|
1607
|
-
capped - cappedBySession - cappedByDay === 0
|
|
1695
|
+
const plural = (n: number, one: string, many: string): string => `${String(n)} ${n === 1 ? one : many}`;
|
|
1696
|
+
const owed = owedReading();
|
|
1697
|
+
const read = owed !== null && owed !== "failed" ? owed : null;
|
|
1698
|
+
const owedPhrase =
|
|
1699
|
+
owed === null
|
|
1608
1700
|
? ""
|
|
1609
|
-
:
|
|
1610
|
-
|
|
1701
|
+
: owed === "failed"
|
|
1702
|
+
? "; sessions awaiting a write-up: unknown (could not be read)"
|
|
1703
|
+
: owed.waiting === 0
|
|
1704
|
+
? ""
|
|
1705
|
+
: `; ${plural(owed.waiting, "session", "sessions")} awaiting a write-up` +
|
|
1706
|
+
(owed.stale === 0 ? "" : `, ${String(owed.stale)} older than ${String(WRITE_UP_WAIT_DAYS)} days`);
|
|
1611
1707
|
const detail =
|
|
1612
|
-
`${windowPhrase(shown, input.today)}:
|
|
1613
|
-
|
|
1614
|
-
`and ${String(paced)} for pacing` +
|
|
1708
|
+
`${windowPhrase(shown, input.today)}: invited to write ${plural(asked, "time", "times")}, ` +
|
|
1709
|
+
`${plural(paced, "Stop", "Stops")} paced out, ${String(capped)} over the day's allowance` +
|
|
1615
1710
|
`${unlabelled === 0 ? "" : ` (${String(unlabelled)} older rows name no outcome)`}; ` +
|
|
1616
|
-
|
|
1711
|
+
`${plural(deposits.rows.length, "deposit", "deposits")}; ` +
|
|
1617
1712
|
`${String(authored)} live ${authored === 1 ? "memory" : "memories"} ${span} ${authored === 1 ? "is" : "are"} its own, ` +
|
|
1618
|
-
`${String(fallback)}
|
|
1713
|
+
`${String(fallback)} the fallback sweep's` +
|
|
1714
|
+
owedPhrase +
|
|
1619
1715
|
`${asks.truncated || deposits.truncated ? " (counts are a floor: the event read hit its limit)" : ""}`;
|
|
1620
|
-
const fixes = [
|
|
1621
|
-
capBinds
|
|
1622
|
-
? `A session's own allowance for the day (${String(SELF_TUNABLES.MAX_ASKS_PER_SESSION)} asks) is refusing the pen more often than it offers it — sessions are running long enough to exhaust it within a day, and that number is worth a look.`
|
|
1623
|
-
: "",
|
|
1624
|
-
sweepWins
|
|
1625
|
-
? "The sweep writes what the session did not: check that sessions reach a session-end boundary in the scope they captured in, and that the Stop ask is reaching the model."
|
|
1626
|
-
: "",
|
|
1627
|
-
].filter((s) => s.length > 0);
|
|
1628
1716
|
const data = {
|
|
1629
1717
|
from,
|
|
1630
1718
|
// The window the SENTENCE names, beside the one the counts were taken over.
|
|
1631
|
-
// They differ only on a store younger than seven days, and a consumer that
|
|
1632
|
-
// wants the reading rather than the wording keeps reading `from`.
|
|
1633
1719
|
shownFrom: shown,
|
|
1634
1720
|
to: input.today,
|
|
1635
1721
|
asked,
|
|
@@ -1641,40 +1727,17 @@ function authorshipFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1641
1727
|
deposits: deposits.rows.length,
|
|
1642
1728
|
authored,
|
|
1643
1729
|
fallback,
|
|
1730
|
+
// Null when the owed sessions were not read (the session-start reading)
|
|
1731
|
+
// or could not be.
|
|
1732
|
+
owedWaiting: read?.waiting ?? null,
|
|
1733
|
+
owedStale: read?.stale ?? null,
|
|
1644
1734
|
truncated: asks.truncated || deposits.truncated,
|
|
1735
|
+
livedDay,
|
|
1645
1736
|
};
|
|
1646
|
-
//
|
|
1647
|
-
//
|
|
1648
|
-
//
|
|
1649
|
-
|
|
1650
|
-
// does not: there is nothing here to fix that waiting will not answer.
|
|
1651
|
-
//
|
|
1652
|
-
// **TWO CLOCKS, the same rule `FiredReport.young` keeps.** An earlier version
|
|
1653
|
-
// used the lived clock alone, arguing that these ambers are about how a
|
|
1654
|
-
// session behaved and so cannot predate the clock moving. That premise is
|
|
1655
|
-
// false: `store.advanceClock()` has exactly one caller, the sleep cycle, and
|
|
1656
|
-
// sessions ask and deposit at every boundary whether or not the worker ever
|
|
1657
|
-
// runs. So a store whose worker has been dead since day 1 — spawn refused, no
|
|
1658
|
-
// credential, a broken checkout — piles up a fortnight of asks and deposits
|
|
1659
|
-
// with a perfectly meaningful cap/sweep ratio and read GREEN, "too new to
|
|
1660
|
-
// grade", for ever. That is the exact store the two-clock rule exists to
|
|
1661
|
-
// protect, one finding over.
|
|
1662
|
-
const young =
|
|
1663
|
-
livedDay < YOUNG_LIVED_DAYS &&
|
|
1664
|
-
daysBetween(oldestAuthorshipDate(asks.rows, deposits.rows) ?? input.today, input.today) <
|
|
1665
|
-
YOUNG_LIVED_DAYS;
|
|
1666
|
-
return [
|
|
1667
|
-
finding(
|
|
1668
|
-
"authorship",
|
|
1669
|
-
!young && (capBinds || sweepWins) ? "amber" : "green",
|
|
1670
|
-
"Authorship",
|
|
1671
|
-
young && (capBinds || sweepWins)
|
|
1672
|
-
? `${detail} — too new to grade: this store is on lived day ${String(livedDay)}`
|
|
1673
|
-
: detail,
|
|
1674
|
-
young ? "" : fixes.join(" "),
|
|
1675
|
-
{ ...data, young, livedDay },
|
|
1676
|
-
),
|
|
1677
|
-
];
|
|
1737
|
+
// Green, always: a session waiting too long for its write-up is the one
|
|
1738
|
+
// loss this line could name, and the Crash write-up line already turns amber
|
|
1739
|
+
// on it — one loss, one amber line.
|
|
1740
|
+
return [finding("authorship", "green", "Authorship", detail, "", data)];
|
|
1678
1741
|
}
|
|
1679
1742
|
|
|
1680
1743
|
/**
|
|
@@ -1852,9 +1915,7 @@ function spawnFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
1852
1915
|
"red",
|
|
1853
1916
|
"Spawn",
|
|
1854
1917
|
`the background worker has been refused ${worst[1]} times in a row (${worst[0]})${rowClause === "" ? "" : ` — ${rowClause}`}`,
|
|
1855
|
-
|
|
1856
|
-
? `Run: counterparts credentials set ${API_KEY_ENV}`
|
|
1857
|
-
: "Read the newest adapter.spawn.refused row; its reason names the door.",
|
|
1918
|
+
"Read the newest adapter.spawn.refused row; its reason names the door.",
|
|
1858
1919
|
data,
|
|
1859
1920
|
),
|
|
1860
1921
|
];
|
|
@@ -2067,11 +2128,43 @@ function vectorFindings(input: DoctorInput, store: Store): Finding[] {
|
|
|
2067
2128
|
const skipped = store.skippedVectorIds().length;
|
|
2068
2129
|
const detail = `${unembedded} live memories with no vector, ${skipped} skipped after repeated embed failures`;
|
|
2069
2130
|
const data = { unembedded, skipped };
|
|
2131
|
+
// WITHDRAWN: the count cannot fall, so the line must not say it will
|
|
2132
|
+
// (review of #190, MAJOR 4). The Recall by meaning line names the way out.
|
|
2133
|
+
const verdict = store.embedderVerdict.kind;
|
|
2134
|
+
// AN EMBEDDER THAT COULD NOT BE BUILT is the same case (re-review MINOR C):
|
|
2135
|
+
// the count cannot fall while the weights are missing, so the line says
|
|
2136
|
+
// why instead of promising it will.
|
|
2137
|
+
const newest = newestBackfill(input);
|
|
2138
|
+
if (newest !== null && str(newest, "reason") === "embedder-unavailable") {
|
|
2139
|
+
const code = str(newest, "codes") ?? "NO_WEIGHTS";
|
|
2140
|
+
return [
|
|
2141
|
+
finding(
|
|
2142
|
+
"vectors",
|
|
2143
|
+
"amber",
|
|
2144
|
+
"Vectors",
|
|
2145
|
+
`${detail} — the embedder could not be built (${code}), so this will not fall until it can`,
|
|
2146
|
+
"Read the Recall by meaning line.",
|
|
2147
|
+
{ ...data, unavailable: code },
|
|
2148
|
+
),
|
|
2149
|
+
];
|
|
2150
|
+
}
|
|
2151
|
+
if (verdict === "held" || verdict === "cache-ahead") {
|
|
2152
|
+
return [
|
|
2153
|
+
finding(
|
|
2154
|
+
"vectors",
|
|
2155
|
+
"amber",
|
|
2156
|
+
"Vectors",
|
|
2157
|
+
`${detail} — the vector channel is withdrawn (${verdict}), so this will not fall until that is resolved`,
|
|
2158
|
+
"Read the Recall by meaning line.",
|
|
2159
|
+
{ ...data, withdrawn: verdict },
|
|
2160
|
+
),
|
|
2161
|
+
];
|
|
2162
|
+
}
|
|
2070
2163
|
if (skipped > 0) {
|
|
2071
2164
|
return [finding("vectors", "amber", "Vectors", detail, "counterparts verify --dir <store> --retry-skipped puts the skipped ids back in the rotation.", data)];
|
|
2072
2165
|
}
|
|
2073
2166
|
if (unembedded > 0) {
|
|
2074
|
-
return [finding("vectors", "amber", "Vectors", detail, "The backfill embeds up to
|
|
2167
|
+
return [finding("vectors", "amber", "Vectors", detail, "The backfill embeds up to 1,000 per boundary; this number must fall run over run.", data)];
|
|
2075
2168
|
}
|
|
2076
2169
|
return [finding("vectors", "green", "Vectors", detail, "", data)];
|
|
2077
2170
|
}
|
|
@@ -2204,8 +2297,11 @@ export function selfPageFindings(store: Store): Finding[] {
|
|
|
2204
2297
|
*/
|
|
2205
2298
|
export function pageWriterFindings(store: Store, config: AdapterConfig): Finding[] {
|
|
2206
2299
|
const mode = pageWriterMode(config);
|
|
2207
|
-
|
|
2208
|
-
|
|
2300
|
+
// THE MECHANISM'S OWN NIGHT, not one this line derives (PR #189 review, M2):
|
|
2301
|
+
// the local calendar day, held back east of UTC to a provenance date that has
|
|
2302
|
+
// closed — the one function `Self`, host mode and this line all read, so the
|
|
2303
|
+
// claim's local `on` is never compared with a UTC `today`.
|
|
2304
|
+
const { today, about } = pageWriterNight(store);
|
|
2209
2305
|
const last = lastPageWriterRun(store);
|
|
2210
2306
|
const page = readSelfPage(store);
|
|
2211
2307
|
const data = {
|
|
@@ -2253,7 +2349,7 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2253
2349
|
// NEVER RUN. On a store with no yesterday that is the correct state and
|
|
2254
2350
|
// says so; on one that has lived a day it is still green, because the
|
|
2255
2351
|
// mechanism runs at the NEXT session start and has not been given a turn.
|
|
2256
|
-
const young = !hasDayBefore(store,
|
|
2352
|
+
const young = !hasDayBefore(store, dayBefore(about, -1));
|
|
2257
2353
|
return [
|
|
2258
2354
|
finding(
|
|
2259
2355
|
"page-writer",
|
|
@@ -2278,6 +2374,7 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2278
2374
|
const owed = pageWriterDue(store, {
|
|
2279
2375
|
mode,
|
|
2280
2376
|
today,
|
|
2377
|
+
about,
|
|
2281
2378
|
observer: store.observer,
|
|
2282
2379
|
asksPerDay: SELF_TUNABLES.PAGE_WRITER_ASKS_PER_DAY,
|
|
2283
2380
|
});
|
|
@@ -2590,6 +2687,15 @@ export interface HostReading {
|
|
|
2590
2687
|
readonly mcpFile: string;
|
|
2591
2688
|
/** The MCP file exists but could not be read or parsed. */
|
|
2592
2689
|
readonly mcpUnreadable: boolean;
|
|
2690
|
+
/**
|
|
2691
|
+
* Whether a `claude` executable is on the PATH the caller would run
|
|
2692
|
+
* `counterparts connect` with (the go-public Phase C walk, 2026-09-23).
|
|
2693
|
+
* `false` only when a PATH was there to search and held none; absent or null
|
|
2694
|
+
* is "not looked", and the fix line stays `counterparts connect`.
|
|
2695
|
+
*/
|
|
2696
|
+
readonly claudeOnPath?: boolean | null;
|
|
2697
|
+
/** The exact `claude mcp add …` line `connect` prints when it cannot run it. */
|
|
2698
|
+
readonly mcpAddLine?: string;
|
|
2593
2699
|
}
|
|
2594
2700
|
|
|
2595
2701
|
function hostFindings(reading: HostReading): Finding[] {
|
|
@@ -2660,15 +2766,27 @@ function hostFindings(reading: HostReading): Finding[] {
|
|
|
2660
2766
|
`replaces the ${stale.length === 1 ? "stale entry" : "stale entries"} with the path this install actually has`,
|
|
2661
2767
|
);
|
|
2662
2768
|
}
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2769
|
+
// `connect` REGISTERS THE MEMORY TOOLS BY RUNNING `claude mcp add` — so with
|
|
2770
|
+
// no `claude` on the PATH, "Run: counterparts connect" names the very command
|
|
2771
|
+
// that just failed to register them (go-public Phase C walk, 2026-09-23). In
|
|
2772
|
+
// that one case the fix is the line `connect` itself prints: run it wherever
|
|
2773
|
+
// `claude` works. The hooks half, if it is owed, is still `connect`'s.
|
|
2774
|
+
const cannotRegister =
|
|
2775
|
+
!reading.mcp && !reading.mcpUnreadable && reading.claudeOnPath === false && reading.mcpAddLine !== undefined;
|
|
2776
|
+
if (!reading.mcp && !reading.mcpUnreadable && !cannotRegister) does.push("registers the memory tools");
|
|
2777
|
+
const byHand = cannotRegister
|
|
2778
|
+
? `\`claude\` is not on this PATH, so \`counterparts connect\` cannot register the memory tools: run this where \`claude\` works — ${reading.mcpAddLine ?? ""} — then restart Claude Code.`
|
|
2779
|
+
: "";
|
|
2780
|
+
const fixes = [
|
|
2781
|
+
...(does.length === 0
|
|
2666
2782
|
? []
|
|
2667
2783
|
: [
|
|
2668
2784
|
`Run: counterparts connect — it backs up ~/.claude/settings.json, ${
|
|
2669
2785
|
does.length === 1 ? does[0] : `${does.slice(0, -1).join(", ")} and ${does[does.length - 1] ?? ""}`
|
|
2670
|
-
}
|
|
2671
|
-
]
|
|
2786
|
+
}.${cannotRegister ? "" : " Then restart Claude Code."}`,
|
|
2787
|
+
]),
|
|
2788
|
+
...(byHand.length === 0 ? [] : [byHand]),
|
|
2789
|
+
];
|
|
2672
2790
|
// STALE FIRST. "GREEN while nothing fires" is the one outcome this line was
|
|
2673
2791
|
// added to prevent, and a block pointing at a deleted checkout is exactly
|
|
2674
2792
|
// that: it matches, it is installed, and every session start fails silently.
|
|
@@ -2754,7 +2872,7 @@ export function summaryLine(t: Record<Lowercase<GradeWord>, number>): string {
|
|
|
2754
2872
|
* THE READING. Pure over its input, worst first, and never a write.
|
|
2755
2873
|
*
|
|
2756
2874
|
* Groups run cheapest-and-most-diagnostic first, and the budget is checked
|
|
2757
|
-
* BETWEEN them: the config
|
|
2875
|
+
* BETWEEN them: the config and the counters are answered before
|
|
2758
2876
|
* anything walks the event log, so a reading that runs out of time still carries
|
|
2759
2877
|
* I32's own signature.
|
|
2760
2878
|
*/
|
|
@@ -2762,22 +2880,20 @@ export function doctorFindings(input: DoctorInput): Finding[] {
|
|
|
2762
2880
|
const now = input.now ?? ((): number => Date.now());
|
|
2763
2881
|
const deadline = input.budgetMs === undefined ? null : now() + input.budgetMs;
|
|
2764
2882
|
const unread = input.configReason === "not-read";
|
|
2765
|
-
//
|
|
2766
|
-
// has ever
|
|
2767
|
-
//
|
|
2768
|
-
//
|
|
2769
|
-
|
|
2770
|
-
//
|
|
2771
|
-
//
|
|
2772
|
-
//
|
|
2773
|
-
//
|
|
2774
|
-
const
|
|
2883
|
+
// ONE BOUNDED READ, before anything else touches the store: whether this
|
|
2884
|
+
// store has ever embedded decides `OFF` from amber on the Recall line
|
|
2885
|
+
// (finding 1, finding #24). Not when no configuration was read: the Config
|
|
2886
|
+
// line above has already said so.
|
|
2887
|
+
const history = unread ? { embedded: false } : keyHistory(input.store);
|
|
2888
|
+
// THE EMBEDDER THE HOOKS WILL ACTUALLY RUN (config.ts#resolveEmbedder): an
|
|
2889
|
+
// absent block is the local table. Resolved HERE, so the lines agree with
|
|
2890
|
+
// the hooks whether or not the caller already applied the default — and not
|
|
2891
|
+
// at all when no configuration was read.
|
|
2892
|
+
const embedderSource = unread ? "explicit" : resolveEmbedder(input.config).source;
|
|
2893
|
+
if (!unread) input = { ...input, config: withEmbedderDefault(input.config) };
|
|
2775
2894
|
const out: Finding[] = [
|
|
2776
2895
|
...configFindings(input),
|
|
2777
|
-
|
|
2778
|
-
// meaning first, because it is the one a person is most likely to want.
|
|
2779
|
-
...(unread ? [] : embedderFindings(input, history)),
|
|
2780
|
-
...(unread ? [] : credentialFindings(input, history)),
|
|
2896
|
+
...(unread ? [] : embedderFindings(input, history, embedderSource)),
|
|
2781
2897
|
// Already READ by the caller (the git calls are its own bounded business),
|
|
2782
2898
|
// so this costs nothing here and is answered before any store read.
|
|
2783
2899
|
...(input.checkout === undefined ? [] : checkoutFindings(input.checkout)),
|
|
@@ -2791,11 +2907,20 @@ export function doctorFindings(input: DoctorInput): Finding[] {
|
|
|
2791
2907
|
const store = input.store;
|
|
2792
2908
|
if (store === null) return worstFirst(out);
|
|
2793
2909
|
|
|
2910
|
+
// The sessions awaiting a write-up: read at most once, and only outside the
|
|
2911
|
+
// session-start reading (it walks every scope's captured words).
|
|
2912
|
+
const owedAllowed = !unread && input.budgetMs === undefined;
|
|
2913
|
+
let owedCache: { value: OwedReading | "failed" } | null = null;
|
|
2914
|
+
const owedReading: OwedSource = () => {
|
|
2915
|
+
if (!owedAllowed) return null;
|
|
2916
|
+
owedCache ??= { value: readOwed(store) };
|
|
2917
|
+
return owedCache.value;
|
|
2918
|
+
};
|
|
2794
2919
|
const groups: (readonly [string, () => Finding[]])[] = [
|
|
2795
2920
|
["spawn", () => spawnFindings(input, store)],
|
|
2796
2921
|
["clock", () => clockFindings(input, store)],
|
|
2797
2922
|
["rows", () => rowFindings(input, store)],
|
|
2798
|
-
["authorship", () => authorshipFindings(input, store)],
|
|
2923
|
+
["authorship", () => authorshipFindings(input, store, owedReading)],
|
|
2799
2924
|
["journal", () => journalFindings(store)],
|
|
2800
2925
|
["vectors", () => vectorFindings(input, store)],
|
|
2801
2926
|
// The snapshot policy lives in the configuration, so with none read this
|
|
@@ -2803,8 +2928,16 @@ export function doctorFindings(input: DoctorInput): Finding[] {
|
|
|
2803
2928
|
...(unread ? [] : [["snapshot", (): Finding[] => snapshotFindings(input, store)] as const]),
|
|
2804
2929
|
["self-page", () => selfPageFindings(store)],
|
|
2805
2930
|
["page-writer", () => pageWriterFindings(store, input.config)],
|
|
2931
|
+
// C2's one line. Not in the session-start reading: it is never red, which
|
|
2932
|
+
// is all that notice prints, and it reads every scope's captured words.
|
|
2933
|
+
...(unread || input.budgetMs !== undefined
|
|
2934
|
+
? []
|
|
2935
|
+
: [["crash-write-up", (): Finding[] => crashWriteUpFindings(input, store, owedReading)] as const]),
|
|
2806
2936
|
// F6: silent unless a copy failure is standing. Two bounded event reads.
|
|
2807
2937
|
["journal-copy", () => journalCopyFindings(store)],
|
|
2938
|
+
// B3's week: one bounded read of the newest `remember.prune` row. Folds into
|
|
2939
|
+
// `Background` while green.
|
|
2940
|
+
["retention", () => retentionFindings(input, store)],
|
|
2808
2941
|
// LAST, and deliberately: it is the widest read here — the whole event log,
|
|
2809
2942
|
// plus a pass over the ids for the table probes — so when the console's
|
|
2810
2943
|
// reading is cut short this is the group that goes, and the `Budget` finding
|
|
@@ -2837,6 +2970,165 @@ export function doctorFindings(input: DoctorInput): Finding[] {
|
|
|
2837
2970
|
|
|
2838
2971
|
// ── rendering ───────────────────────────────────────────────────────────────
|
|
2839
2972
|
|
|
2973
|
+
/** How long a session may wait for its write-up before this line turns amber. */
|
|
2974
|
+
export const WRITE_UP_WAIT_DAYS = 3;
|
|
2975
|
+
|
|
2976
|
+
/**
|
|
2977
|
+
* CRASH WRITE-UP (roadmap C2, owner 2026-09-23) — who writes up a session that
|
|
2978
|
+
* ended before it was written up, and how many are waiting.
|
|
2979
|
+
*
|
|
2980
|
+
* `next session` (green): the next session that starts in that project is
|
|
2981
|
+
* handed the words. It is the only route since 2026-09-24, when the opt-in
|
|
2982
|
+
* API sweep was removed with its key. The count is B3's (`remember/owes.ts`, through
|
|
2983
|
+
* `sessions.ts#awaitingWriteUp`), over every project in the store, minus what
|
|
2984
|
+
* the registry holds running; AMBER only when one has waited past
|
|
2985
|
+
* `WRITE_UP_WAIT_DAYS` — a project never reopened is never written up, and this
|
|
2986
|
+
* is where that shows. Never red: nothing is lost while a session waits, which
|
|
2987
|
+
* is what the wait is for.
|
|
2988
|
+
*/
|
|
2989
|
+
/** The sessions awaiting a write-up, read once per reading and shared by the
|
|
2990
|
+
* `Crash write-up` and `Authorship` lines. */
|
|
2991
|
+
interface OwedReading {
|
|
2992
|
+
readonly spans: SpanBuffer;
|
|
2993
|
+
readonly plan: ReturnType<typeof writeUpPlan>;
|
|
2994
|
+
readonly now: number;
|
|
2995
|
+
/** Sessions awaiting a write-up (B3's count, `sessions.ts#awaitingWriteUp`). */
|
|
2996
|
+
readonly waiting: number;
|
|
2997
|
+
/** ...of which have waited past `WRITE_UP_WAIT_DAYS`. */
|
|
2998
|
+
readonly stale: number;
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
/** `failed` when it cannot be read. It reads every scope's captured words, so
|
|
3002
|
+
* the budgeted session-start reading never calls it. */
|
|
3003
|
+
function readOwed(store: Store): OwedReading | "failed" {
|
|
3004
|
+
try {
|
|
3005
|
+
const now = store.now();
|
|
3006
|
+
// READ-ONLY by construction: an observer buffer writes nothing, and it
|
|
3007
|
+
// is B3's own reader (`planRetention`) that opens the files.
|
|
3008
|
+
const spans = new SpanBuffer({ dir: store.dir, observer: true, now: () => now });
|
|
3009
|
+
const plan = writeUpPlan({
|
|
3010
|
+
store,
|
|
3011
|
+
spans,
|
|
3012
|
+
firstAsk: {
|
|
3013
|
+
turns: SELF_TUNABLES.FIRST_ASK_TURNS,
|
|
3014
|
+
textBytes: SELF_TUNABLES.FIRST_ASK_TEXT_BYTES,
|
|
3015
|
+
},
|
|
3016
|
+
});
|
|
3017
|
+
// The same eligibility the pointer uses.
|
|
3018
|
+
const owed = awaitingWriteUp(plan, store.dir, now);
|
|
3019
|
+
const stale = owed.filter((h) => now - h.clockFrom >= WRITE_UP_WAIT_DAYS * 86_400_000).length;
|
|
3020
|
+
return { spans, plan, now, waiting: owed.length, stale };
|
|
3021
|
+
} catch {
|
|
3022
|
+
return "failed";
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
/** The shared owed reading as a line asks for it: `null` when this reading
|
|
3027
|
+
* does not take it (the budgeted session-start reading). */
|
|
3028
|
+
type OwedSource = () => OwedReading | "failed" | null;
|
|
3029
|
+
|
|
3030
|
+
function crashWriteUpFindings(input: DoctorInput, store: Store, owedReading: OwedSource): Finding[] {
|
|
3031
|
+
const who = "next session";
|
|
3032
|
+
let waiting: number | null = null;
|
|
3033
|
+
let stale = 0;
|
|
3034
|
+
/** Sessions FINISHED in one project and waiting on words they left in
|
|
3035
|
+
* another (the door's `written-up-here`), stale ones first. */
|
|
3036
|
+
const shares: { session: string; here: string; elsewhere: string[]; stale: boolean }[] = [];
|
|
3037
|
+
try {
|
|
3038
|
+
const reading = owedReading();
|
|
3039
|
+
if (reading === null || reading === "failed") throw new Error("owed reading unavailable");
|
|
3040
|
+
const { spans, plan, now } = reading;
|
|
3041
|
+
waiting = reading.waiting;
|
|
3042
|
+
stale = reading.stale;
|
|
3043
|
+
const progress = readWriteUpProgress(store);
|
|
3044
|
+
for (const [key, p] of Object.entries(progress)) {
|
|
3045
|
+
if (p.waiting !== true) continue;
|
|
3046
|
+
const bar = key.indexOf("|");
|
|
3047
|
+
const session = key.slice(0, bar);
|
|
3048
|
+
const here = key.slice(bar + 1);
|
|
3049
|
+
const h = plan.find((x) => x.session === session);
|
|
3050
|
+
if (h === undefined || !h.owes) continue;
|
|
3051
|
+
const elsewhere = h.scopes.filter(
|
|
3052
|
+
(scope) =>
|
|
3053
|
+
!sameScope(scope, here) &&
|
|
3054
|
+
progress[progressKey(session, scope)]?.waiting !== true &&
|
|
3055
|
+
writeUpEntries(spans, { session, scopes: [scope] }).length > 0,
|
|
3056
|
+
);
|
|
3057
|
+
if (elsewhere.length === 0) continue;
|
|
3058
|
+
shares.push({ session, here, elsewhere, stale: now - h.clockFrom >= WRITE_UP_WAIT_DAYS * 86_400_000 });
|
|
3059
|
+
}
|
|
3060
|
+
shares.sort((a, b) => Number(b.stale) - Number(a.stale));
|
|
3061
|
+
} catch {
|
|
3062
|
+
waiting = null;
|
|
3063
|
+
}
|
|
3064
|
+
const count =
|
|
3065
|
+
waiting === null
|
|
3066
|
+
? " (could not count the sessions waiting)"
|
|
3067
|
+
: waiting === 0
|
|
3068
|
+
? ""
|
|
3069
|
+
: ` — ${String(waiting)} session${waiting === 1 ? "" : "s"} awaiting a write-up` +
|
|
3070
|
+
(stale === 0 ? "" : `, ${String(stale)} older than ${String(WRITE_UP_WAIT_DAYS)} days`);
|
|
3071
|
+
const pointer = readWriteUpPointer(store);
|
|
3072
|
+
const data = {
|
|
3073
|
+
mode: "next-session",
|
|
3074
|
+
waiting,
|
|
3075
|
+
stale,
|
|
3076
|
+
pointer: pointer?.outcome ?? null,
|
|
3077
|
+
pointerDate: pointer?.date ?? null,
|
|
3078
|
+
};
|
|
3079
|
+
// THE POINTER IS NOT GETTING OUT (PR #192 review, MAJOR 1 and m4): opening a
|
|
3080
|
+
// session there would only defer again, so the advice says why and by how much.
|
|
3081
|
+
if (pointer !== null && pointer.outcome === "deferred" && (waiting ?? 0) > 0) {
|
|
3082
|
+
const short = Math.max(0, pointer.need - pointer.room);
|
|
3083
|
+
const why =
|
|
3084
|
+
pointer.reason === "host-cap"
|
|
3085
|
+
? `the pointer did not fit on ${pointer.date}: it needs ${String(pointer.need)} bytes and the wake left ${String(Math.max(0, pointer.room))} under the host's 10,000-character cap (${String(short)} short)`
|
|
3086
|
+
: `the pointer could not be recorded on ${pointer.date} (${pointer.reason ?? "unknown"})`;
|
|
3087
|
+
return [
|
|
3088
|
+
finding(
|
|
3089
|
+
"crash-write-up",
|
|
3090
|
+
"amber",
|
|
3091
|
+
"Crash write-up",
|
|
3092
|
+
`${who}${count} — ${why}`,
|
|
3093
|
+
pointer.reason === "host-cap"
|
|
3094
|
+
? `The wake is too full: lower "injectionBudgetBytes" in ${tilde(input.configPath)} by ${String(short)} or more.`
|
|
3095
|
+
: "The session registry under the store could not be written; read the Store line.",
|
|
3096
|
+
data,
|
|
3097
|
+
),
|
|
3098
|
+
];
|
|
3099
|
+
}
|
|
3100
|
+
// A SHARE WAITING ON ANOTHER PROJECT (re-review, m-C): name the project, and
|
|
3101
|
+
// say the session is finished here — opening a session HERE does nothing.
|
|
3102
|
+
const share = shares.find((x) => x.stale);
|
|
3103
|
+
if (share !== undefined) {
|
|
3104
|
+
const where = share.elsewhere.map((x) => tilde(x)).join(", ");
|
|
3105
|
+
return [
|
|
3106
|
+
finding(
|
|
3107
|
+
"crash-write-up",
|
|
3108
|
+
"amber",
|
|
3109
|
+
"Crash write-up",
|
|
3110
|
+
`${who}${count} — session ${share.session} is finished in ${tilde(share.here)} and waiting on words it left in ${where}` +
|
|
3111
|
+
(shares.length > 1 ? ` (${String(shares.length)} such sessions)` : ""),
|
|
3112
|
+
`Open a session in ${where}: its start points at the rest. A directory set off never will, and there is no command yet to close a session by hand.`,
|
|
3113
|
+
{ ...data, sharesWaiting: shares.length },
|
|
3114
|
+
),
|
|
3115
|
+
];
|
|
3116
|
+
}
|
|
3117
|
+
if (stale > 0) {
|
|
3118
|
+
return [
|
|
3119
|
+
finding(
|
|
3120
|
+
"crash-write-up",
|
|
3121
|
+
"amber",
|
|
3122
|
+
"Crash write-up",
|
|
3123
|
+
`${who}${count}`,
|
|
3124
|
+
"Open a session in the project each one ended in: its start points at the oldest. A project never reopened is never written up.",
|
|
3125
|
+
data,
|
|
3126
|
+
),
|
|
3127
|
+
];
|
|
3128
|
+
}
|
|
3129
|
+
return [finding("crash-write-up", "green", "Crash write-up", `${who}${count}`, "", data)];
|
|
3130
|
+
}
|
|
3131
|
+
|
|
2840
3132
|
/**
|
|
2841
3133
|
* The two columns every doctor line lays out in — `ui.ts` holds the same pair
|
|
2842
3134
|
* and `test/ui.test.ts` holds the two files to each other.
|