@agfpd/iapeer-memory 0.1.1 → 0.1.3
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/package.json +3 -3
- package/src/binary.ts +6 -2
- package/src/commands/init.ts +63 -11
- package/src/commands/install-binary.ts +2 -1
- package/src/commands/status.ts +3 -1
- package/src/commands/uninstall.ts +19 -3
- package/src/commands/update.ts +44 -2
- package/src/commands/verify.ts +117 -41
- package/src/paths.ts +3 -0
- package/src/signing.ts +168 -0
- package/src/templates/roles-en.ts +123 -108
- package/src/templates/roles-ru.ts +112 -101
- package/src/watcher.ts +228 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agfpd/iapeer-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "iapeer-memory — peer memory for the iapeer ecosystem: vault, memoryd (index/search/MCP-http), layer-5 context fragments, role doctrines. The package IS the system; the claude/codex plugins are thin session sockets (docs/10-distribution.md, ADR-009).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"release": "npm version patch --workspaces-update=false && npm run release:finish",
|
|
21
21
|
"release:minor": "npm version minor --workspaces-update=false && npm run release:finish",
|
|
22
22
|
"release:major": "npm version major --workspaces-update=false && npm run release:finish",
|
|
23
|
-
"release:finish": "V=$(bun -e 'console.log(JSON.parse(require(\"fs\").readFileSync(\"package.json\",\"utf-8\")).version)') && git -C .. commit -m \"$V\" && git -C .. tag \"v$V\" && (cd ../core && npm publish) && npm publish && git push --follow-tags",
|
|
23
|
+
"release:finish": "V=$(bun -e 'console.log(JSON.parse(require(\"fs\").readFileSync(\"package.json\",\"utf-8\")).version)') && git -C .. commit -m \"$V\" && git -C .. tag -a \"v$V\" -m \"$V\" && (cd ../core && npm publish) && npm publish && git push --follow-tags",
|
|
24
24
|
"prepublishOnly": "test -z \"$(git status --porcelain)\" || (echo 'release: working tree is dirty — commit or stash before release' >&2 && exit 1)"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agfpd/iapeer-memory-core": "0.1.
|
|
30
|
+
"@agfpd/iapeer-memory-core": "0.1.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/bun": "^1.2.0",
|
package/src/binary.ts
CHANGED
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
|
|
24
24
|
import fs from "node:fs";
|
|
25
25
|
import path from "node:path";
|
|
26
|
+
import { signInstalledBinary, type SigningOutcome } from "./signing.js";
|
|
26
27
|
|
|
27
28
|
export function isCompiledRuntime(): boolean {
|
|
28
29
|
return import.meta.url.includes("/$bunfs/");
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export type InstallBinaryOutcome =
|
|
32
|
-
| { action: "compiled"; outPath: string; bytes: number }
|
|
33
|
+
| { action: "compiled"; outPath: string; bytes: number; signing: SigningOutcome }
|
|
33
34
|
| { action: "skipped-compiled"; outPath: string }
|
|
34
35
|
| { action: "failed"; outPath: string; detail: string };
|
|
35
36
|
|
|
@@ -65,7 +66,10 @@ export function installBinary(opts: { outPath: string }): InstallBinaryOutcome {
|
|
|
65
66
|
|
|
66
67
|
fs.chmodSync(tmp, 0o755);
|
|
67
68
|
fs.renameSync(tmp, outPath); // atomic swap — safe over a running binary on macOS
|
|
68
|
-
|
|
69
|
+
// Stable-identity re-sign on EVERY compile path (TCC grants survive
|
|
70
|
+
// updates — contract with iapeer, see signing.ts). Soft-fail by design.
|
|
71
|
+
const signing = signInstalledBinary(outPath);
|
|
72
|
+
return { action: "compiled", outPath, bytes: fs.statSync(outPath).size, signing };
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
export function removeBinary(outPath: string): "removed" | "absent" {
|
package/src/commands/init.ts
CHANGED
|
@@ -41,7 +41,15 @@ import {
|
|
|
41
41
|
ROLE_NAMES,
|
|
42
42
|
} from "../templates/index.js";
|
|
43
43
|
import { packageVersion } from "../version.js";
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
dreamTimerMessage,
|
|
46
|
+
patchWakePolicyEphemeral,
|
|
47
|
+
registerTimer,
|
|
48
|
+
registerWatcher,
|
|
49
|
+
sweepTimerMessage,
|
|
50
|
+
writeLauncherScript,
|
|
51
|
+
writeStaleCheckScript,
|
|
52
|
+
} from "../watcher.js";
|
|
45
53
|
|
|
46
54
|
type InitFlags = {
|
|
47
55
|
vault?: string;
|
|
@@ -241,7 +249,9 @@ export async function cmdInit(argv: string[]): Promise<number> {
|
|
|
241
249
|
step(
|
|
242
250
|
"binary",
|
|
243
251
|
bin.action === "compiled"
|
|
244
|
-
? `${bin.outPath} (${Math.round(bin.bytes / 1024 / 1024)}MB
|
|
252
|
+
? `${bin.outPath} (${Math.round(bin.bytes / 1024 / 1024)}MB; signing: ${bin.signing.state}` +
|
|
253
|
+
`${bin.signing.state === "signed-new-identity" ? " — the one install-time keychain event" : ""}` +
|
|
254
|
+
`${bin.signing.state === "failed-soft" ? ` — ${bin.signing.detail}` : ""})`
|
|
245
255
|
: bin.action === "skipped-compiled"
|
|
246
256
|
? `kept existing ${bin.outPath} (running from the installed binary)`
|
|
247
257
|
: `compile failed — ${bin.detail}`,
|
|
@@ -291,17 +301,26 @@ export async function cmdInit(argv: string[]): Promise<number> {
|
|
|
291
301
|
roleEntries.push({ role, peerCwd, template });
|
|
292
302
|
}
|
|
293
303
|
writeRolesManifest({ rolesManifestPath: paths.rolesManifestPath, roles: roleEntries });
|
|
304
|
+
// The copywriter is the inverted pipeline's first receiver — an
|
|
305
|
+
// EPHEMERAL worker (clean window per delivery, ADR-015): patch one key
|
|
306
|
+
// into its core-owned profile, no-clobber.
|
|
307
|
+
const cwEntry = roleEntries.find((r) => r.role === "copywriter");
|
|
308
|
+
const wakePolicy = cwEntry ? patchWakePolicyEphemeral(cwEntry.peerCwd) : "missing-profile";
|
|
294
309
|
step(
|
|
295
310
|
"roles",
|
|
296
|
-
`${roleEntries.map((r) => r.role).join(", ")} (doctrines v${version},
|
|
297
|
-
|
|
311
|
+
`${roleEntries.map((r) => r.role).join(", ")} (doctrines v${version}, ` +
|
|
312
|
+
`copywriter wake_policy: ${wakePolicy}, manifest ${paths.rolesManifestPath})`,
|
|
313
|
+
rolesOk && roleEntries.length === ROLE_NAMES.length && wakePolicy !== "missing-profile",
|
|
298
314
|
);
|
|
299
315
|
}
|
|
300
316
|
|
|
301
|
-
// 7.
|
|
302
|
-
//
|
|
317
|
+
// 7. notifier wiring (ADR-015, инверсия): the EVENT trigger targets the
|
|
318
|
+
// COPYWRITER (first receiver); two TIMERS target the index — weekly
|
|
319
|
+
// DREAM_TICK and the check-gated fail-open sweep. Registrant = index for
|
|
320
|
+
// all three (one durable profile to verify); same-id re-send = replace.
|
|
303
321
|
if (flags.skipEcosystem) {
|
|
304
322
|
step("watcher", "skipped (--skip-ecosystem)");
|
|
323
|
+
step("timers", "skipped (--skip-ecosystem)");
|
|
305
324
|
} else {
|
|
306
325
|
writeLauncherScript({ launcherPath: paths.launcherPath, binaryPath: paths.binaryPath });
|
|
307
326
|
const sent = registerWatcher({
|
|
@@ -310,10 +329,36 @@ export async function cmdInit(argv: string[]): Promise<number> {
|
|
|
310
329
|
});
|
|
311
330
|
step(
|
|
312
331
|
"watcher",
|
|
313
|
-
sent.
|
|
314
|
-
?
|
|
315
|
-
:
|
|
316
|
-
|
|
332
|
+
sent.suppressed
|
|
333
|
+
? "skipped (test sandbox — sends suppressed)"
|
|
334
|
+
: sent.ok
|
|
335
|
+
? `registration sent (${paths.launcherPath} → target copywriter); confirm: iapeer-memory verify`
|
|
336
|
+
: `registration failed — ${sent.detail}`,
|
|
337
|
+
sent.ok || Boolean(sent.suppressed),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
writeStaleCheckScript({
|
|
341
|
+
checkScriptPath: paths.checkScriptPath,
|
|
342
|
+
vaultPath: vault,
|
|
343
|
+
inboxFolders: [getTaxonomy(locale).folders.inbox, getTaxonomy(locale).folders.inboxHuman],
|
|
344
|
+
});
|
|
345
|
+
const sweep = registerTimer({
|
|
346
|
+
message: sweepTimerMessage({ checkScriptPath: paths.checkScriptPath }),
|
|
347
|
+
iapeerBin: flags.iapeerBin,
|
|
348
|
+
});
|
|
349
|
+
const dream = registerTimer({
|
|
350
|
+
message: dreamTimerMessage(),
|
|
351
|
+
iapeerBin: flags.iapeerBin,
|
|
352
|
+
});
|
|
353
|
+
const timersSandboxed = sweep.suppressed && dream.suppressed;
|
|
354
|
+
step(
|
|
355
|
+
"timers",
|
|
356
|
+
timersSandboxed
|
|
357
|
+
? "skipped (test sandbox — sends suppressed)"
|
|
358
|
+
: sweep.ok && dream.ok
|
|
359
|
+
? `sweep (@every 1h, check ${paths.checkScriptPath}) + dream-tick (weekly) → target index`
|
|
360
|
+
: `sweep: ${sweep.ok ? "sent" : sweep.detail}; dream: ${dream.ok ? "sent" : dream.detail}`,
|
|
361
|
+
Boolean(timersSandboxed) || (sweep.ok && dream.ok),
|
|
317
362
|
);
|
|
318
363
|
}
|
|
319
364
|
|
|
@@ -337,10 +382,17 @@ export async function cmdInit(argv: string[]): Promise<number> {
|
|
|
337
382
|
step("sweep", "skipped (--skip-ecosystem)");
|
|
338
383
|
} else {
|
|
339
384
|
const sweep = run([flags.iapeerBin, "native-memory", "off", "--all"]);
|
|
385
|
+
// One line per peer-runtime — summarise ALL peers, not the last line
|
|
386
|
+
// (e2e §A finding: ".pop()" named one peer while three were swept).
|
|
387
|
+
const sweepLines = sweep.stdout.trim().split("\n").filter(Boolean);
|
|
388
|
+
const sweptPeers = [
|
|
389
|
+
...new Set(sweepLines.map((l) => l.split(" ")[0].replace(/:$/, "")).filter(Boolean)),
|
|
390
|
+
];
|
|
340
391
|
step(
|
|
341
392
|
"sweep",
|
|
342
393
|
sweep.exitCode === 0
|
|
343
|
-
? `native auto-memory off across the fleet (${
|
|
394
|
+
? `native auto-memory off across the fleet (${sweptPeers.length} peer(s): ` +
|
|
395
|
+
`${sweptPeers.slice(0, 8).join(", ")}${sweptPeers.length > 8 ? ", …" : ""})`
|
|
344
396
|
: `soft-skip: core verb unavailable (${sweep.stderr.trim().slice(0, 120) || `exit ${sweep.exitCode}`}) — upgrade the iapeer core and re-run`,
|
|
345
397
|
);
|
|
346
398
|
}
|
|
@@ -28,7 +28,8 @@ export function cmdInstallBinary(argv: string[]): number {
|
|
|
28
28
|
switch (outcome.action) {
|
|
29
29
|
case "compiled":
|
|
30
30
|
console.log(
|
|
31
|
-
`install-binary: compiled ${outcome.outPath} (${Math.round(outcome.bytes / 1024 / 1024)}MB
|
|
31
|
+
`install-binary: compiled ${outcome.outPath} (${Math.round(outcome.bytes / 1024 / 1024)}MB; ` +
|
|
32
|
+
`signing: ${outcome.signing.state}${outcome.signing.state === "failed-soft" ? ` — ${outcome.signing.detail}` : ""})`,
|
|
32
33
|
);
|
|
33
34
|
return 0;
|
|
34
35
|
case "skipped-compiled":
|
package/src/commands/status.ts
CHANGED
|
@@ -147,7 +147,9 @@ export async function cmdStatus(argv: string[]): Promise<number> {
|
|
|
147
147
|
}
|
|
148
148
|
console.log(
|
|
149
149
|
` ${"inbox".padEnd(width)} ` +
|
|
150
|
-
(count < 0
|
|
150
|
+
(count < 0
|
|
151
|
+
? `folder missing (${inboxDir})`
|
|
152
|
+
: `${count} draft(s) awaiting the pipeline (a growing pile = the copywriter thread is stuck; the sweep places stale drafts unvetted)`),
|
|
151
153
|
);
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -19,7 +19,13 @@ import fs from "node:fs";
|
|
|
19
19
|
import { memoryPaths } from "../paths.js";
|
|
20
20
|
import { removeBinary } from "../binary.js";
|
|
21
21
|
import { removeSlot } from "../slot.js";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
DREAM_TRIGGER_ID,
|
|
24
|
+
SWEEP_TRIGGER_ID,
|
|
25
|
+
unregisterTimer,
|
|
26
|
+
unregisterWatcher,
|
|
27
|
+
WATCHER_TRIGGER_ID,
|
|
28
|
+
} from "../watcher.js";
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
31
|
* Owner verification before signalling: the process command line must look
|
|
@@ -97,8 +103,8 @@ export function cmdUninstall(argv: string[]): number {
|
|
|
97
103
|
console.log(`slot : ${slot === "removed" ? "declaration removed" : "already absent"}`);
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
//
|
|
101
|
-
// the teaching
|
|
106
|
+
// notifier wiring: best-effort unregister of all three triggers (not-found
|
|
107
|
+
// is soft on the notifier side; teaching replies go to the index session).
|
|
102
108
|
const unreg = unregisterWatcher({ iapeerBin });
|
|
103
109
|
console.log(
|
|
104
110
|
`watcher : ${
|
|
@@ -107,6 +113,16 @@ export function cmdUninstall(argv: string[]): number {
|
|
|
107
113
|
: `unregister not sent (${unreg.detail}) — remove the trigger manually via the watcher peer`
|
|
108
114
|
}`,
|
|
109
115
|
);
|
|
116
|
+
for (const id of [SWEEP_TRIGGER_ID, DREAM_TRIGGER_ID]) {
|
|
117
|
+
const t = unregisterTimer({ id, iapeerBin });
|
|
118
|
+
console.log(
|
|
119
|
+
`timer : ${
|
|
120
|
+
t.ok
|
|
121
|
+
? `unregister sent for ${id}`
|
|
122
|
+
: `unregister not sent for ${id} (${t.detail}) — remove manually via the timer peer`
|
|
123
|
+
}`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
110
126
|
|
|
111
127
|
console.log(`memoryd : ${stopMemorydByPidFile(paths.pidPath)}`);
|
|
112
128
|
|
package/src/commands/update.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
|
+
configFromEnv,
|
|
28
29
|
isLocaleId,
|
|
29
30
|
renderDoctrine,
|
|
30
31
|
type LocaleId,
|
|
@@ -35,7 +36,14 @@ import { readRolesManifest } from "../roles.js";
|
|
|
35
36
|
import { writeSlot } from "../slot.js";
|
|
36
37
|
import { materialiseTemplates } from "../templates/index.js";
|
|
37
38
|
import { packageVersion } from "../version.js";
|
|
38
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
dreamTimerMessage,
|
|
41
|
+
registerTimer,
|
|
42
|
+
registerWatcher,
|
|
43
|
+
sweepTimerMessage,
|
|
44
|
+
writeLauncherScript,
|
|
45
|
+
writeStaleCheckScript,
|
|
46
|
+
} from "../watcher.js";
|
|
39
47
|
import { stopMemorydByPidFile } from "./uninstall.js";
|
|
40
48
|
|
|
41
49
|
export function cmdUpdate(argv: string[]): number {
|
|
@@ -72,7 +80,8 @@ export function cmdUpdate(argv: string[]): number {
|
|
|
72
80
|
step(
|
|
73
81
|
"binary",
|
|
74
82
|
bin.action === "compiled"
|
|
75
|
-
? `recompiled ${bin.outPath} (${Math.round(bin.bytes / 1024 / 1024)}MB
|
|
83
|
+
? `recompiled ${bin.outPath} (${Math.round(bin.bytes / 1024 / 1024)}MB; signing: ${bin.signing.state}` +
|
|
84
|
+
`${bin.signing.state === "failed-soft" ? ` — ${bin.signing.detail}` : ""})`
|
|
76
85
|
: bin.action === "skipped-compiled"
|
|
77
86
|
? "running FROM the installed binary — recompile via: npx @agfpd/iapeer-memory@latest update"
|
|
78
87
|
: `compile failed — ${bin.detail}`,
|
|
@@ -120,6 +129,39 @@ export function cmdUpdate(argv: string[]): number {
|
|
|
120
129
|
// 5. launcher
|
|
121
130
|
step("launcher", writeLauncherScript({ launcherPath: paths.launcherPath, binaryPath: paths.binaryPath }));
|
|
122
131
|
|
|
132
|
+
// 5b. notifier wiring (ADR-015): same-id re-send REPLACES the trigger —
|
|
133
|
+
// the idempotent re-target path (old hosts with target=index migrate to
|
|
134
|
+
// target=copywriter by this very step).
|
|
135
|
+
{
|
|
136
|
+
let inboxFolders: string[] | null = null;
|
|
137
|
+
try {
|
|
138
|
+
const config = configFromEnv();
|
|
139
|
+
inboxFolders = [config.taxonomy.folders.inbox, config.taxonomy.folders.inboxHuman];
|
|
140
|
+
writeStaleCheckScript({
|
|
141
|
+
checkScriptPath: paths.checkScriptPath,
|
|
142
|
+
vaultPath: config.vaultPath,
|
|
143
|
+
inboxFolders,
|
|
144
|
+
});
|
|
145
|
+
} catch {
|
|
146
|
+
// unprovisioned env — registrations below still re-target
|
|
147
|
+
}
|
|
148
|
+
const w = registerWatcher({ launcherPath: paths.launcherPath });
|
|
149
|
+
const s = registerTimer({
|
|
150
|
+
message: sweepTimerMessage({ checkScriptPath: paths.checkScriptPath }),
|
|
151
|
+
});
|
|
152
|
+
const d = registerTimer({ message: dreamTimerMessage() });
|
|
153
|
+
const sandboxed = w.suppressed && s.suppressed && d.suppressed;
|
|
154
|
+
step(
|
|
155
|
+
"triggers",
|
|
156
|
+
sandboxed
|
|
157
|
+
? "skipped (test sandbox — sends suppressed)"
|
|
158
|
+
: w.ok && s.ok && d.ok
|
|
159
|
+
? `re-sent: event→copywriter, sweep+dream→index (same id = replace); confirm: verify`
|
|
160
|
+
: `event: ${w.ok ? "sent" : w.detail}; sweep: ${s.ok ? "sent" : s.detail}; dream: ${d.ok ? "sent" : d.detail}`,
|
|
161
|
+
Boolean(sandboxed) || (w.ok && s.ok && d.ok),
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
123
165
|
// 6. memoryd managed restart (the watcher relaunches with the new binary)
|
|
124
166
|
step("memoryd", `${stopMemorydByPidFile(paths.pidPath)} — the notifier watcher relaunches it with the new binary`);
|
|
125
167
|
|
package/src/commands/verify.ts
CHANGED
|
@@ -30,9 +30,16 @@ import { readRolesManifest } from "../roles.js";
|
|
|
30
30
|
import { readSlot, writeSlot, SLOT_PROVIDER } from "../slot.js";
|
|
31
31
|
import { packageVersion } from "../version.js";
|
|
32
32
|
import {
|
|
33
|
+
dreamTimerMessage,
|
|
34
|
+
DEFAULT_EVENT_TARGET,
|
|
35
|
+
DREAM_TRIGGER_ID,
|
|
33
36
|
readWatcherTrigger,
|
|
37
|
+
registerTimer,
|
|
34
38
|
registerWatcher,
|
|
39
|
+
sweepTimerMessage,
|
|
40
|
+
SWEEP_TRIGGER_ID,
|
|
35
41
|
writeLauncherScript,
|
|
42
|
+
writeStaleCheckScript,
|
|
36
43
|
WATCHER_TRIGGER_ID,
|
|
37
44
|
} from "../watcher.js";
|
|
38
45
|
|
|
@@ -49,6 +56,8 @@ export type VerifyOptions = {
|
|
|
49
56
|
staleMs?: number;
|
|
50
57
|
/** Injectable for tests. */
|
|
51
58
|
nowMs?: number;
|
|
59
|
+
/** Injectable for tests — repair MUST NOT reach the live notifier. */
|
|
60
|
+
iapeerBin?: string;
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
type RolesManifest = {
|
|
@@ -149,56 +158,123 @@ export function runVerify(opts: VerifyOptions = {}): CheckResult[] {
|
|
|
149
158
|
});
|
|
150
159
|
}
|
|
151
160
|
|
|
152
|
-
// 3. notifier
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
// re-run confirms.
|
|
161
|
+
// 3. notifier wiring (ADR-015). Durable triggers live in the REGISTRANT's
|
|
162
|
+
// peer profile (canonical storage contract): registrant = index for all
|
|
163
|
+
// three — the EVENT trigger (target=copywriter, inverted pipeline), the
|
|
164
|
+
// sweep timer and the dream timer (both target=index). Re-registration is
|
|
165
|
+
// ASYNC (same id = replace) — repair reports "sent", a re-run confirms.
|
|
158
166
|
{
|
|
159
167
|
const manifest = readRolesManifest(paths.rolesManifestPath);
|
|
160
168
|
const indexEntry = manifest?.roles.find((r) => r.role === "index") ?? null;
|
|
161
169
|
if (!indexEntry) {
|
|
162
|
-
|
|
163
|
-
name: "notifier-watcher",
|
|
164
|
-
status: "skip",
|
|
165
|
-
detail: "roles manifest has no index peer — init has not run",
|
|
166
|
-
});
|
|
167
|
-
} else {
|
|
168
|
-
const trigger = readWatcherTrigger({ registrantCwd: indexEntry.peerCwd });
|
|
169
|
-
const scriptOk = trigger?.script === paths.launcherPath;
|
|
170
|
-
if (trigger && scriptOk) {
|
|
170
|
+
for (const name of ["notifier-watcher", "sweep-timer", "dream-timer"]) {
|
|
171
171
|
results.push({
|
|
172
|
-
name
|
|
173
|
-
status: "
|
|
174
|
-
detail:
|
|
172
|
+
name,
|
|
173
|
+
status: "skip",
|
|
174
|
+
detail: "roles manifest has no index peer — init has not run",
|
|
175
175
|
});
|
|
176
|
-
}
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
const registrantCwd = indexEntry.peerCwd;
|
|
179
|
+
const checks: Array<{
|
|
180
|
+
name: string;
|
|
181
|
+
id: string;
|
|
182
|
+
role: "event" | "time";
|
|
183
|
+
expect: (t: NonNullable<ReturnType<typeof readWatcherTrigger>>) => string | null;
|
|
184
|
+
repairSend: () => { ok: boolean; detail: string };
|
|
185
|
+
}> = [
|
|
186
|
+
{
|
|
187
|
+
name: "notifier-watcher",
|
|
188
|
+
id: WATCHER_TRIGGER_ID,
|
|
189
|
+
role: "event",
|
|
190
|
+
expect: (t) =>
|
|
191
|
+
t.script !== paths.launcherPath
|
|
192
|
+
? `script is ${t.script}, expected ${paths.launcherPath}`
|
|
193
|
+
: t.target !== DEFAULT_EVENT_TARGET
|
|
194
|
+
? `target is ${t.target ?? "?"}, expected ${DEFAULT_EVENT_TARGET} (inverted pipeline)`
|
|
195
|
+
: null,
|
|
196
|
+
repairSend: () => {
|
|
197
|
+
writeLauncherScript({
|
|
198
|
+
launcherPath: paths.launcherPath,
|
|
199
|
+
binaryPath: paths.binaryPath,
|
|
200
|
+
});
|
|
201
|
+
return registerWatcher({
|
|
202
|
+
launcherPath: paths.launcherPath,
|
|
203
|
+
iapeerBin: opts.iapeerBin,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "sweep-timer",
|
|
209
|
+
id: SWEEP_TRIGGER_ID,
|
|
210
|
+
role: "time",
|
|
211
|
+
expect: (t) =>
|
|
212
|
+
(t as { check?: string }).check !== paths.checkScriptPath
|
|
213
|
+
? `check is ${(t as { check?: string }).check ?? "?"}, expected ${paths.checkScriptPath}`
|
|
214
|
+
: t.target !== "index"
|
|
215
|
+
? `target is ${t.target ?? "?"}, expected index`
|
|
216
|
+
: null,
|
|
217
|
+
repairSend: () => {
|
|
218
|
+
try {
|
|
219
|
+
const config = configFromEnv();
|
|
220
|
+
writeStaleCheckScript({
|
|
221
|
+
checkScriptPath: paths.checkScriptPath,
|
|
222
|
+
vaultPath: config.vaultPath,
|
|
223
|
+
inboxFolders: [
|
|
224
|
+
config.taxonomy.folders.inbox,
|
|
225
|
+
config.taxonomy.folders.inboxHuman,
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
} catch {
|
|
229
|
+
// unprovisioned env — the registration alone still heals the trigger
|
|
230
|
+
}
|
|
231
|
+
return registerTimer({
|
|
232
|
+
message: sweepTimerMessage({ checkScriptPath: paths.checkScriptPath }),
|
|
233
|
+
iapeerBin: opts.iapeerBin,
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "dream-timer",
|
|
239
|
+
id: DREAM_TRIGGER_ID,
|
|
240
|
+
role: "time",
|
|
241
|
+
expect: (t) =>
|
|
242
|
+
t.target !== "index" ? `target is ${t.target ?? "?"}, expected index` : null,
|
|
243
|
+
repairSend: () =>
|
|
244
|
+
registerTimer({ message: dreamTimerMessage(), iapeerBin: opts.iapeerBin }),
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
for (const c of checks) {
|
|
248
|
+
const trigger = readWatcherTrigger({ registrantCwd, id: c.id, role: c.role });
|
|
177
249
|
const problem = trigger
|
|
178
|
-
?
|
|
179
|
-
: `no ${
|
|
180
|
-
if (
|
|
181
|
-
results.push({
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
binaryPath: paths.binaryPath,
|
|
250
|
+
? c.expect(trigger)
|
|
251
|
+
: `no ${c.id} trigger in ${registrantCwd}/.iapeer/peer-profile.json`;
|
|
252
|
+
if (problem === null) {
|
|
253
|
+
results.push({
|
|
254
|
+
name: c.name,
|
|
255
|
+
status: "ok",
|
|
256
|
+
detail: `trigger ${c.id} in index profile → target ${trigger!.target ?? "?"}`,
|
|
186
257
|
});
|
|
187
|
-
|
|
188
|
-
results.push(
|
|
189
|
-
sent.ok
|
|
190
|
-
? {
|
|
191
|
-
name: "notifier-watcher",
|
|
192
|
-
status: "repaired",
|
|
193
|
-
detail: `${problem} — re-registration sent (async; re-run verify to confirm)`,
|
|
194
|
-
}
|
|
195
|
-
: {
|
|
196
|
-
name: "notifier-watcher",
|
|
197
|
-
status: "fail",
|
|
198
|
-
detail: `${problem}; re-registration failed — ${sent.detail}`,
|
|
199
|
-
},
|
|
200
|
-
);
|
|
258
|
+
continue;
|
|
201
259
|
}
|
|
260
|
+
if (!repair) {
|
|
261
|
+
results.push({ name: c.name, status: "fail", detail: problem });
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const sent = c.repairSend();
|
|
265
|
+
results.push(
|
|
266
|
+
sent.ok
|
|
267
|
+
? {
|
|
268
|
+
name: c.name,
|
|
269
|
+
status: "repaired",
|
|
270
|
+
detail: `${problem} — re-registration sent (async; re-run verify to confirm)`,
|
|
271
|
+
}
|
|
272
|
+
: {
|
|
273
|
+
name: c.name,
|
|
274
|
+
status: "fail",
|
|
275
|
+
detail: `${problem}; re-registration failed — ${sent.detail}`,
|
|
276
|
+
},
|
|
277
|
+
);
|
|
202
278
|
}
|
|
203
279
|
}
|
|
204
280
|
}
|
package/src/paths.ts
CHANGED
|
@@ -50,6 +50,8 @@ export type MemoryPaths = {
|
|
|
50
50
|
templatesDir: string;
|
|
51
51
|
/** memoryd launcher — the notifier watcher's script (wraps the stable binary). */
|
|
52
52
|
launcherPath: string;
|
|
53
|
+
/** Sweep check-script — gates the fail-open inbox sweep (ADR-015). */
|
|
54
|
+
checkScriptPath: string;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
export function memoryPaths(
|
|
@@ -87,6 +89,7 @@ export function memoryPaths(
|
|
|
87
89
|
env.IAPEER_MEMORY_BINARY_PATH || path.join(home, ".local", "bin", "iapeer-memory"),
|
|
88
90
|
templatesDir: path.join(path.dirname(configFile), "templates"),
|
|
89
91
|
launcherPath: path.join(path.dirname(configFile), "memoryd-launcher.sh"),
|
|
92
|
+
checkScriptPath: path.join(path.dirname(configFile), "inbox-stale-check.sh"),
|
|
90
93
|
};
|
|
91
94
|
}
|
|
92
95
|
|