@codyswann/lisa 4.92.0 → 4.92.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/all/copy-overwrite/scripts/lisa-enforcement-fallback.sh +11 -1
  2. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  3. package/dist/core/lisa-owned-hash-ledger.js +2 -0
  4. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  5. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  6. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  7. package/dist/core/upstream-evidence-manifest.js +22 -4
  8. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  9. package/package.json +4 -4
  10. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  11. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  13. package/plugins/lisa/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  14. package/plugins/lisa-agy/plugin.json +1 -1
  15. package/plugins/lisa-agy/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  16. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  17. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  19. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  23. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-copilot/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  25. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cursor/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  27. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  29. package/plugins/lisa-devin/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  30. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  32. package/plugins/lisa-expo-agy/plugin.json +1 -1
  33. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  46. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  47. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  51. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  54. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  58. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  61. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  65. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  67. package/plugins/lisa-rails-agy/plugin.json +1 -1
  68. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  72. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  74. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  75. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  79. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  81. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  82. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  86. package/plugins/src/base/skills/lisa-verification-lifecycle/SKILL.md +49 -0
  87. package/scripts/fixtures/packaged-apply/Dockerfile +7 -0
  88. package/scripts/fixtures/packaged-apply/guard-cases.json +16 -0
  89. package/scripts/lib/packaged-apply-driver.mjs +292 -0
  90. package/scripts/lib/packaged-apply-isolation.d.mts +25 -0
  91. package/scripts/lib/packaged-apply-isolation.mjs +160 -0
  92. package/scripts/lisa-enforcement-fallback.sh +11 -1
  93. package/scripts/two-channel-couplings.json +2 -2
  94. package/scripts/verify-packaged-apply.mjs +327 -0
@@ -0,0 +1,292 @@
1
+ /** Runs only in the controller's inspected disposable container. */
2
+ import assert from "node:assert/strict";
3
+ import { execFileSync, spawnSync } from "node:child_process";
4
+ import { createHash } from "node:crypto";
5
+ import {
6
+ accessSync,
7
+ constants,
8
+ existsSync,
9
+ mkdirSync,
10
+ readFileSync,
11
+ writeFileSync,
12
+ } from "node:fs";
13
+ import os from "node:os";
14
+ import path from "node:path";
15
+ import { pathToFileURL } from "node:url";
16
+
17
+ const root = "/lisa-fixture";
18
+ const packageFile = "package.json";
19
+ assert.ok(
20
+ process.platform === "linux" &&
21
+ process.env.LISA_DISPOSABLE_APPLY === "1" &&
22
+ existsSync("/.dockerenv"),
23
+ "This internal driver requires the inspected disposable-container controller"
24
+ );
25
+ const proof = {
26
+ harness: process.argv[2],
27
+ native_agent_activation: "not established",
28
+ };
29
+ const budget = 15 * 60_000;
30
+
31
+ /**
32
+ * @param {string} command - Genuine runtime tool.
33
+ * @param {string[]} args - Literal arguments.
34
+ * @param {object} options - Additional child options.
35
+ * @returns {string} Actual stdout.
36
+ */
37
+ function execute(command, args, options = {}) {
38
+ return execFileSync(command, args, {
39
+ cwd: root,
40
+ encoding: "utf8",
41
+ timeout: budget,
42
+ maxBuffer: 32 * 1024 * 1024,
43
+ ...options,
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Resolve actual optional tools without executing them or fabricating a stub.
49
+ * @param {string} name - Native executable basename.
50
+ * @returns {string | null} Existing executable or absence.
51
+ */
52
+ function executable(name) {
53
+ for (const directory of (process.env.PATH ?? "").split(path.delimiter)) {
54
+ const file = path.join(directory, name);
55
+ try {
56
+ accessSync(file, constants.X_OK);
57
+ return file;
58
+ } catch {
59
+ /* Keep searching PATH. */
60
+ }
61
+ }
62
+ return null;
63
+ }
64
+
65
+ try {
66
+ mkdirSync(root);
67
+ writeFileSync(
68
+ path.join(root, packageFile),
69
+ JSON.stringify({
70
+ name: "lisa-disposable-verification",
71
+ private: true,
72
+ version: "1.0.0",
73
+ type: "module",
74
+ packageManager: "bun@1.4.4",
75
+ trustedDependencies: [
76
+ "@codyswann/lisa",
77
+ "@ast-grep/cli",
78
+ "@parcel/watcher",
79
+ "esbuild",
80
+ ],
81
+ })
82
+ );
83
+ writeFileSync(path.join(root, ".gitignore"), "node_modules/\n");
84
+ proof.tools = {
85
+ node: process.version,
86
+ npm: execute("npm", ["--version"]).trim(),
87
+ git: execute("git", ["--version"]).trim(),
88
+ bun: execute("bun", ["--version"]).trim(),
89
+ bash: execute("bash", ["--version"]).split("\n")[0],
90
+ jq: execute("jq", ["--version"]).trim(),
91
+ };
92
+ // Installation and all its lifecycle scripts are inside the checked boundary.
93
+ proof.install_stdout = execute("bun", ["add", "/lisa-input.tgz"]);
94
+ const installed = path.join(root, "node_modules/@codyswann/lisa");
95
+ const manifest = JSON.parse(
96
+ readFileSync(path.join(installed, packageFile), "utf8")
97
+ );
98
+ proof.package = {
99
+ name: manifest.name,
100
+ version: manifest.version,
101
+ bin: manifest.bin,
102
+ };
103
+ assert.equal(manifest.name, "@codyswann/lisa");
104
+ const bin = path.resolve(installed, manifest.bin.lisa);
105
+ assert.ok(bin.startsWith(`${installed}/`));
106
+ const { defaultUserMcpConfigPath } = await import(
107
+ pathToFileURL(path.join(installed, "dist/agy/mcp-installer.js")).href
108
+ );
109
+ proof.destinations = {
110
+ ownership:
111
+ "Every selected writer is inside the disposable root filesystem; zero host mounts",
112
+ project: root,
113
+ agy_user_config: defaultUserMcpConfigPath(),
114
+ temporary_backups: os.tmpdir(),
115
+ update_cache: path.join(
116
+ root,
117
+ "node_modules/.cache/@codyswann/lisa/update-check.json"
118
+ ),
119
+ claude:
120
+ "project instructions; vendor machine plugin registry/cache when CLI exists",
121
+ codex: "project .codex and .agents overlays; optional Sonar integration",
122
+ cursor: "shared project templates/instruction reconciliation",
123
+ agy: "project instructions; unconditional resolved user MCP file; vendor plugins and Sonar",
124
+ copilot: "project instructions; vendor plugin store/cache and Sonar",
125
+ opencode: "project .opencode, opencode.json and instructions",
126
+ devin: "project hook fallback; machine-local vendor plugin store",
127
+ shared:
128
+ "Git common config/hooks, learnings relocation, transaction backups, package-manager caches, detached reconciliation",
129
+ unresolved_vendor_paths:
130
+ "Owned by the same disposable filesystem, including writes from descendants",
131
+ };
132
+ proof.optional_vendor_executables = Object.fromEntries(
133
+ [
134
+ "claude",
135
+ "codex",
136
+ "cursor",
137
+ "agy",
138
+ "copilot",
139
+ "opencode",
140
+ "devin",
141
+ "sonar",
142
+ ].map(name => [name, executable(name)])
143
+ );
144
+ execute("git", ["init", "--initial-branch=main"]);
145
+ execute("git", ["config", "user.name", "Lisa verification"]);
146
+ execute("git", ["config", "user.email", "verification@example.invalid"]);
147
+ execute("git", ["add", "--all"]);
148
+ execute("git", ["commit", "-m", "Initialize disposable fixture"]);
149
+ proof.git_destinations = {
150
+ common: execute("git", ["rev-parse", "--git-common-dir"]).trim(),
151
+ hooks: execute("git", ["rev-parse", "--git-path", "hooks"]).trim(),
152
+ };
153
+ if (process.argv[3] === "failure-control") {
154
+ // Fail the actual user-scope writer AFTER project writes. This is a real
155
+ // filesystem error inside the owned container, never a replacement CLI.
156
+ mkdirSync(defaultUserMcpConfigPath(), { recursive: true });
157
+ proof.failure_control = {
158
+ kind: "agy-config-is-directory",
159
+ path: defaultUserMcpConfigPath(),
160
+ };
161
+ }
162
+ const args = [
163
+ bin,
164
+ "apply",
165
+ root,
166
+ "--yes",
167
+ "--full-apply",
168
+ "--no-update-check",
169
+ "--harness",
170
+ proof.harness,
171
+ ];
172
+ proof.command = [process.execPath, ...args];
173
+ const apply = spawnSync(process.execPath, args, {
174
+ cwd: root,
175
+ env: { ...process.env, LISA_BOOTSTRAP: "1" },
176
+ encoding: "utf8",
177
+ timeout: budget,
178
+ maxBuffer: 32 * 1024 * 1024,
179
+ });
180
+ proof.apply = {
181
+ status: apply.status,
182
+ signal: apply.signal,
183
+ error: apply.error?.message ?? null,
184
+ stdout: apply.stdout,
185
+ stderr: apply.stderr,
186
+ };
187
+ assert.equal(apply.error, undefined);
188
+ assert.equal(apply.signal, null);
189
+ assert.equal(apply.status, 0);
190
+ const agyConfig = defaultUserMcpConfigPath();
191
+ proof.agy_config_after = existsSync(agyConfig)
192
+ ? {
193
+ present: true,
194
+ sha256: createHash("sha256")
195
+ .update(readFileSync(agyConfig))
196
+ .digest("hex"),
197
+ }
198
+ : { present: false };
199
+ const receipt = JSON.parse(
200
+ readFileSync(path.join(root, ".lisa/apply-receipt.json"), "utf8")
201
+ );
202
+ proof.apply_receipt = receipt;
203
+ assert.equal(receipt.apply_mode, "full");
204
+ // #4672 retired the safety net. Exercise a surviving emitted guard while
205
+ // keeping every proposed command inert, including the retired-target control.
206
+ const retired = path.join(root, "scripts/lisa-hooks/parity-safety-net.sh");
207
+ const retiredResult = spawnSync("/bin/bash", [retired], {
208
+ cwd: root,
209
+ encoding: "utf8",
210
+ timeout: 60_000,
211
+ env: { ...process.env, CLAUDE_PROJECT_DIR: root },
212
+ input: JSON.stringify({
213
+ tool_name: "Bash",
214
+ tool_input: { command: "rm -rf /outside-project" },
215
+ }),
216
+ });
217
+ proof.retired_safety_net = {
218
+ sha256: createHash("sha256").update(readFileSync(retired)).digest("hex"),
219
+ status: retiredResult.status,
220
+ signal: retiredResult.signal,
221
+ stdout: retiredResult.stdout,
222
+ stderr: retiredResult.stderr,
223
+ };
224
+ assert.equal(retiredResult.error, undefined);
225
+ assert.equal(retiredResult.signal, null);
226
+ assert.equal(retiredResult.status, 0);
227
+ const guard = path.join(root, "scripts/lisa-hooks/block-no-verify.sh");
228
+ const guardBytes = readFileSync(guard);
229
+ proof.guard_sha256 = createHash("sha256").update(guardBytes).digest("hex");
230
+ const prohibited = "git commit --no-verify -m fixture";
231
+ const cases = JSON.parse(readFileSync("/lisa-guard-cases.json", "utf8"));
232
+ assert.equal(cases.length, 14);
233
+ assert.equal(new Set(cases.map(row => row[0])).size, 14);
234
+ proof.guard_cases = [];
235
+ for (const [name, source, expected] of cases) {
236
+ assert.ok(
237
+ typeof name === "string" && !name.includes("/") && !name.includes("..")
238
+ );
239
+ assert.ok(typeof source === "string" && [0, 2].includes(expected));
240
+ const directory = path.join(root, "native-guard-cases", name);
241
+ mkdirSync(path.join(directory, "safe"), { recursive: true });
242
+ writeFileSync(path.join(directory, "payload.sh"), `${prohibited}\n`);
243
+ writeFileSync(path.join(directory, "safe/payload.sh"), "echo safe\n");
244
+ writeFileSync(path.join(directory, "run.sh"), source);
245
+ const result = spawnSync("/bin/bash", [guard], {
246
+ cwd: directory,
247
+ encoding: "utf8",
248
+ timeout: 60_000,
249
+ env: { ...process.env, CLAUDE_PROJECT_DIR: directory },
250
+ input: JSON.stringify({
251
+ tool_name: "Bash",
252
+ tool_input: { command: "sh run.sh" },
253
+ }),
254
+ });
255
+ proof.guard_cases.push({
256
+ name,
257
+ source_sha256: createHash("sha256").update(source).digest("hex"),
258
+ expected,
259
+ status: result.status,
260
+ signal: result.signal,
261
+ stdout: result.stdout,
262
+ stderr: result.stderr,
263
+ });
264
+ assert.equal(result.error, undefined);
265
+ assert.equal(result.signal, null);
266
+ assert.equal(result.status, expected);
267
+ }
268
+ assert.equal(
269
+ createHash("sha256").update(readFileSync(guard)).digest("hex"),
270
+ proof.guard_sha256
271
+ );
272
+ proof.passed = true;
273
+ } catch (error) {
274
+ proof.passed = false;
275
+ proof.failure = {
276
+ message: error.message,
277
+ stdout: error.stdout ?? null,
278
+ stderr: error.stderr ?? null,
279
+ };
280
+ process.exitCode = 1;
281
+ } finally {
282
+ writeFileSync("/lisa-proof.json", `${JSON.stringify(proof, null, 2)}\n`, {
283
+ mode: 0o600,
284
+ });
285
+ console.log(
286
+ JSON.stringify({
287
+ passed: proof.passed,
288
+ harness: proof.harness,
289
+ native_agent_activation: "not established",
290
+ })
291
+ );
292
+ }
@@ -0,0 +1,25 @@
1
+ export declare function refuseHostApply(
2
+ harness: string,
3
+ agyDestination: string
4
+ ): never;
5
+ export declare function assertDisposableContainer(
6
+ row: Record<string, unknown>,
7
+ id: string
8
+ ): void;
9
+ export declare function snapshotFiles(
10
+ files: readonly string[],
11
+ evidenceDirectory?: string,
12
+ options?: { phase?: "before" | "after" }
13
+ ): Promise<Record<string, object>>;
14
+ export declare function compareSnapshots(
15
+ before: Record<string, object>,
16
+ after: Record<string, object>
17
+ ): string[];
18
+ export declare function preserveUnexpectedWrite(
19
+ file: string,
20
+ evidenceDirectory: string
21
+ ): Promise<{
22
+ copy: string;
23
+ prior_content: "unknown";
24
+ restored: false;
25
+ }>;
@@ -0,0 +1,160 @@
1
+ /** Shared fail-closed boundary for verification, never ordinary apply. */
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import { lstat, mkdir, readFile, readlink, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import os from "node:os";
6
+
7
+ /**
8
+ * Local cwd/PATH/env routing cannot prove ownership of vendor and cache paths.
9
+ * @param {string} harness - Selected native harness.
10
+ * @param {string} agyDestination - Actual installed user-scope resolver result.
11
+ * @returns {never} Always refuses before a host apply.
12
+ */
13
+ export function refuseHostApply(harness, agyDestination) {
14
+ const global = ["fleet", "all", "agy"].includes(harness)
15
+ ? ` Uncontained Antigravity destination: ${agyDestination}.`
16
+ : ` Uncontained temporary-backup root: ${os.tmpdir()}. Unresolved vendor registration and package-cache destinations.`;
17
+ throw new Error(
18
+ `Refused before spawning apply.${global} Use the inspected disposable Docker route; a temporary project or missing agent CLI is not isolation.`
19
+ );
20
+ }
21
+
22
+ /**
23
+ * Inspect the actual newly created container, not the requested docker flags.
24
+ * No host mount (even read-only), device, privileged or shared namespace passes.
25
+ * @param {Record<string, any>} row - Native docker inspect object.
26
+ * @param {string} id - Exact ID returned by create.
27
+ * @returns {void}
28
+ */
29
+ export function assertDisposableContainer(row, id) {
30
+ const h = row.HostConfig;
31
+ if (
32
+ !/^[a-f0-9]{64}$/u.test(id) ||
33
+ row.Id !== id ||
34
+ row.State?.Status !== "created" ||
35
+ row.State?.Running !== false ||
36
+ !Array.isArray(row.Mounts) ||
37
+ row.Mounts.length !== 0 ||
38
+ !h
39
+ ) {
40
+ throw new Error(
41
+ "Isolation preflight: incomplete, started or mounted container"
42
+ );
43
+ }
44
+ // Docker omits optional HostConfig.Mounts when no --mount was requested.
45
+ const empty = value =>
46
+ value === undefined ||
47
+ value === null ||
48
+ (Array.isArray(value) && value.length === 0);
49
+ const noHostResources = [
50
+ "Binds",
51
+ "Mounts",
52
+ "VolumesFrom",
53
+ "Devices",
54
+ "DeviceRequests",
55
+ "CapAdd",
56
+ ].every(key => empty(h[key]));
57
+ if (
58
+ !noHostResources ||
59
+ h.Privileged !== false ||
60
+ !h.CapDrop?.includes("ALL") ||
61
+ !Array.isArray(h.SecurityOpt) ||
62
+ h.SecurityOpt.length !== 1 ||
63
+ h.SecurityOpt[0] !== "no-new-privileges" ||
64
+ h.NetworkMode !== "bridge" ||
65
+ h.PidMode !== "" ||
66
+ h.IpcMode !== "private" ||
67
+ h.UsernsMode !== "" ||
68
+ h.CgroupnsMode !== "private"
69
+ ) {
70
+ throw new Error(
71
+ "Isolation preflight: host resources or unsafe namespace/privileges"
72
+ );
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Capture complete file bytes by digest or absence; never print config contents.
78
+ * Refuse initial symlinks. After execution, capture changed link bytes without
79
+ * following the link or exposing its target in the public observation.
80
+ * @param {readonly string[]} files - Every declared outside file, no exclusions.
81
+ * @param {string} [evidenceDirectory] - Private directory for complete before/after images.
82
+ * @param {{phase?: "before" | "after"}} [options] - Only the post-run observation accepts changed symlinks.
83
+ * @returns {Promise<Record<string, object>>} Ordered path-to-observation map.
84
+ */
85
+ export async function snapshotFiles(files, evidenceDirectory, options = {}) {
86
+ const result = {};
87
+ if (evidenceDirectory) await privateDirectory(evidenceDirectory);
88
+ for (const file of files) {
89
+ try {
90
+ const info = await lstat(file);
91
+ const postRunLink = options.phase === "after" && info.isSymbolicLink();
92
+ if (!info.isFile() && !postRunLink)
93
+ throw new Error(`Preservation path is not a regular file: ${file}`);
94
+ const bytes = postRunLink
95
+ ? await readlink(file, { encoding: "buffer" })
96
+ : await readFile(file);
97
+ if (evidenceDirectory) {
98
+ const name = `${createHash("sha256").update(file).digest("hex")}.private`;
99
+ await writeFile(path.join(evidenceDirectory, name), bytes, {
100
+ mode: 0o600,
101
+ flag: "wx",
102
+ });
103
+ }
104
+ result[file] = {
105
+ present: true,
106
+ ...(postRunLink ? { kind: "symlink" } : {}),
107
+ bytes: bytes.length,
108
+ mode: info.mode & 0o777,
109
+ sha256: createHash("sha256").update(bytes).digest("hex"),
110
+ };
111
+ } catch (error) {
112
+ if (error.code !== "ENOENT") throw error;
113
+ result[file] = { present: false };
114
+ }
115
+ }
116
+ return result;
117
+ }
118
+
119
+ /**
120
+ * @param {Record<string, object>} before - Complete before observation.
121
+ * @param {Record<string, object>} after - Complete after observation.
122
+ * @returns {string[]} Changed paths, including newly observed destinations.
123
+ */
124
+ export function compareSnapshots(before, after) {
125
+ return [...new Set([...Object.keys(before), ...Object.keys(after)])].filter(
126
+ file => JSON.stringify(before[file]) !== JSON.stringify(after[file])
127
+ );
128
+ }
129
+
130
+ /**
131
+ * Preserve observed current bytes without altering the original or guessing its
132
+ * history. Caller must stop the writer before invoking this recovery operation.
133
+ * @param {string} file - Unexpected destination, possibly without a before-image.
134
+ * @param {string} evidenceDirectory - Private recovery directory.
135
+ * @returns {Promise<{copy: string, prior_content: "unknown", restored: false}>}
136
+ */
137
+ export async function preserveUnexpectedWrite(file, evidenceDirectory) {
138
+ await privateDirectory(evidenceDirectory);
139
+ const copy = path.join(evidenceDirectory, `${randomUUID()}.private`);
140
+ const info = await lstat(file);
141
+ const current = info.isSymbolicLink()
142
+ ? await readlink(file, { encoding: "buffer" })
143
+ : await readFile(file);
144
+ await writeFile(copy, current, { mode: 0o600, flag: "wx" });
145
+ return { copy, prior_content: "unknown", restored: false };
146
+ }
147
+
148
+ /**
149
+ * @param {string} evidenceDirectory - Owned evidence path.
150
+ * @returns {Promise<void>} Reject public or symlinked recovery directories.
151
+ */
152
+ async function privateDirectory(evidenceDirectory) {
153
+ await mkdir(evidenceDirectory, { mode: 0o700, recursive: true });
154
+ const directory = await lstat(evidenceDirectory);
155
+ if (!directory.isDirectory() || (directory.mode & 0o077) !== 0) {
156
+ throw new Error(
157
+ "Recovery requires a private directory without symlink redirection"
158
+ );
159
+ }
160
+ }
@@ -274,7 +274,17 @@ run_optional_freshness() (
274
274
  builtin kill -KILL -- -"$group"
275
275
  ) &
276
276
  anchor=$!
277
- if [ "$(builtin jobs -pr)" = "$anchor" ]; then
277
+ # The child's admission timer is already running. Keep the job census in this
278
+ # shell: an extra command-substitution fork can consume that fixed window.
279
+ # Accept exactly one live job with the freshly captured anchor identity.
280
+ builtin jobs -pr >"$scratch/jobs" || exit 1
281
+ live_job_count=0
282
+ live_job=""
283
+ while IFS= builtin read -r observed_job; do
284
+ live_job_count=$((live_job_count + 1))
285
+ live_job="$observed_job"
286
+ done <"$scratch/jobs"
287
+ if [ "$live_job_count" -eq 1 ] && [ "$live_job" = "$anchor" ]; then
278
288
  # Preauthorize termination only after the helper finishes. This removes
279
289
  # parent polling and external sleep startup without accepting partial facts.
280
290
  builtin printf 'anchor:%s\nstop\n' "$anchor" >&8
@@ -2,7 +2,7 @@
2
2
  "ratified": {
3
3
  "quality.yml::scripts/check-learnings-budget.ts": "Lisa-source-only branch, and the else arm is the delivery. The step tests for BOTH scripts/check-learnings-budget.ts and src/core/learnings-budget-check.ts, which co-exist only in this repository; every consumer takes the else arm and runs the prover as `bunx @codyswann/lisa@<their own declared version>`, which is the PACKAGE channel and not a caller-tree read at all. A trailing `grep -qE \"learnings budget (passed|saturated)|no learnings file\"` then refuses a run that printed no verdict, so the arm cannot pass vacuously. Ratified because the caller-tree read is unreachable outside this repository, not because the gap is tolerated.",
4
4
  "quality.yml::scripts/generate-nightly-e2e-guard-certificate.mjs": "Lisa-source-only branch. Both reusable jobs require `github.repository == 'CodySwannGT/lisa'` before the step can start, and the run body repeats that exact repository guard before checking this artifact path. Ordinary and private host callers therefore skip the step without reading or fetching from their own tree. The scoped branch fetches only the immutable refs needed to behavior-test Lisa's own retained certificate inputs. Ratified because the caller-tree read is unreachable outside this repository, not because an undelivered host dependency is tolerated.",
5
- "quality.yml::scripts/verify-host-name-target-scope.mjs": "Lisa-source-only regression proof. The step requires `github.repository == 'CodySwannGT/lisa' && steps.gate_run.outcome == 'success'` before executing this driver. Every host caller skips the step without reading this path. Ratified because the caller-tree read is unreachable outside this repository; no host dependency is introduced."
5
+ "quality.yml::scripts/verify-host-name-target-scope.mjs": "Lisa-source-only regression proof. Two steps execute this driver, each behind `github.repository == 'CodySwannGT/lisa'`: the enforcing `🔒 Enforce host-name target scope` step in `test_unit` (also gated on `steps.gate_run.outcome == 'success'`), and the named host-name target-scope step in the Lisa-only `test_named_regression_specs` job, whose job-level `if:` carries the same repository guard. Every host caller skips both without reading this path. Ratified because the caller-tree read is unreachable outside this repository; no host dependency is introduced."
6
6
  },
7
7
  "staleness": {
8
8
  "npm-updater.yml::scripts/lisa-npm-updater.mjs": {
@@ -120,7 +120,7 @@
120
120
  },
121
121
  "inspected": {
122
122
  "workflows": 26,
123
- "steps": 824,
123
+ "steps": 834,
124
124
  "couplings": 40,
125
125
  "inventory": 208
126
126
  },