@codyswann/lisa 5.0.2 → 5.1.1

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 (128) hide show
  1. package/all/copy-overwrite/scripts/lib/automation-provenance-contract.mjs +136 -11
  2. package/all/copy-overwrite/scripts/lib/automation-provenance-local.mjs +3 -0
  3. package/all/copy-overwrite/scripts/lib/npm-update-allocate.mjs +4 -10
  4. package/all/copy-overwrite/scripts/lib/npm-update-bun.mjs +39 -7
  5. package/all/copy-overwrite/scripts/lib/npm-update-cancel-origin.mjs +20 -20
  6. package/all/copy-overwrite/scripts/lib/npm-update-cancellation-proof.mjs +8 -8
  7. package/all/copy-overwrite/scripts/lib/npm-update-cancellation.mjs +5 -3
  8. package/all/copy-overwrite/scripts/lib/npm-update-contract.mjs +12 -5
  9. package/all/copy-overwrite/scripts/lib/npm-update-gate.mjs +3 -6
  10. package/all/copy-overwrite/scripts/lib/npm-update-hosted-gate.mjs +2 -3
  11. package/all/copy-overwrite/scripts/lib/npm-update-leaf-contract.mjs +12 -4
  12. package/all/copy-overwrite/scripts/lib/npm-update-npm.mjs +4 -1
  13. package/all/copy-overwrite/scripts/lib/npm-update-policy.mjs +35 -2
  14. package/all/copy-overwrite/scripts/lib/npm-update-prepare.mjs +26 -17
  15. package/all/copy-overwrite/scripts/lib/npm-update-rails-runtime-contract.mjs +6 -2
  16. package/all/copy-overwrite/scripts/lib/npm-update-supersession.mjs +13 -6
  17. package/all/copy-overwrite/scripts/lisa-automation-provenance.mjs +10 -3
  18. package/all/copy-overwrite/scripts/lisa-npm-updater.mjs +7 -4
  19. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +30 -19
  20. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  21. package/dist/core/lisa-owned-hash-ledger.js +66 -0
  22. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  23. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  24. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  25. package/dist/core/upstream-evidence-manifest.js +43 -25
  26. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  27. package/package.json +4 -4
  28. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  30. package/plugins/lisa/.codex-plugin/skills/lisa-github-validate-issue/SKILL.md +2 -0
  31. package/plugins/lisa/.codex-plugin/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  32. package/plugins/lisa/.codex-plugin/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  33. package/plugins/lisa/.codex-plugin/skills/lisa-task-decomposition/SKILL.md +18 -0
  34. package/plugins/lisa/rules/reference/stale-state-claims.md +1 -0
  35. package/plugins/lisa/rules/reference/work-item-definition-of-ready.md +2 -0
  36. package/plugins/lisa/skills/lisa-github-validate-issue/SKILL.md +2 -0
  37. package/plugins/lisa/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  38. package/plugins/lisa/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  39. package/plugins/lisa/skills/lisa-task-decomposition/SKILL.md +18 -0
  40. package/plugins/lisa-agy/plugin.json +1 -1
  41. package/plugins/lisa-agy/skills/lisa-github-validate-issue/SKILL.md +2 -0
  42. package/plugins/lisa-agy/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  43. package/plugins/lisa-agy/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  44. package/plugins/lisa-agy/skills/lisa-task-decomposition/SKILL.md +18 -0
  45. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  48. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  52. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-copilot/rules/reference/stale-state-claims.md +1 -0
  54. package/plugins/lisa-copilot/rules/reference/work-item-definition-of-ready.md +2 -0
  55. package/plugins/lisa-copilot/skills/lisa-github-validate-issue/SKILL.md +2 -0
  56. package/plugins/lisa-copilot/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  57. package/plugins/lisa-copilot/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  58. package/plugins/lisa-copilot/skills/lisa-task-decomposition/SKILL.md +18 -0
  59. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-cursor/rules/stale-state-claims-reference.mdc +1 -0
  61. package/plugins/lisa-cursor/rules/work-item-definition-of-ready-reference.mdc +2 -0
  62. package/plugins/lisa-cursor/skills/lisa-github-validate-issue/SKILL.md +2 -0
  63. package/plugins/lisa-cursor/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  64. package/plugins/lisa-cursor/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  65. package/plugins/lisa-cursor/skills/lisa-task-decomposition/SKILL.md +18 -0
  66. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  68. package/plugins/lisa-devin/rules/reference/stale-state-claims.md +1 -0
  69. package/plugins/lisa-devin/rules/reference/work-item-definition-of-ready.md +2 -0
  70. package/plugins/lisa-devin/skills/lisa-github-validate-issue/SKILL.md +2 -0
  71. package/plugins/lisa-devin/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  72. package/plugins/lisa-devin/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  73. package/plugins/lisa-devin/skills/lisa-task-decomposition/SKILL.md +18 -0
  74. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  76. package/plugins/lisa-expo-agy/plugin.json +1 -1
  77. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  81. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  84. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  88. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  90. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  91. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  93. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  95. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  97. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  98. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  99. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  102. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  103. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  104. package/plugins/lisa-rails-agy/plugin.json +1 -1
  105. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  106. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  107. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  108. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  109. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  111. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  112. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  113. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  114. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  116. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  118. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  119. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  120. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  121. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  123. package/plugins/src/base/rules/reference/stale-state-claims.md +1 -0
  124. package/plugins/src/base/rules/reference/work-item-definition-of-ready.md +2 -0
  125. package/plugins/src/base/skills/lisa-github-validate-issue/SKILL.md +2 -0
  126. package/plugins/src/base/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  127. package/plugins/src/base/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  128. package/plugins/src/base/skills/lisa-task-decomposition/SKILL.md +18 -0
@@ -2,9 +2,13 @@
2
2
  // Do not edit directly — durable changes belong upstream in Lisa.
3
3
 
4
4
  /** Closed canonical schemas and committed npm policy remain independent of local proof IO. */
5
+ import { posix } from "node:path";
5
6
  import { requireProof } from "./github-attestation-verifier.mjs";
6
7
 
7
- const FILES = ["package-lock.json", "package.json"];
8
+ const MANIFEST = "package.json";
9
+ const NPM_LOCK = "package-lock.json";
10
+ const BUN_LOCK = "bun.lock";
11
+ const FILES = [NPM_LOCK, MANIFEST];
8
12
  const DESCRIPTOR_KEYS = [
9
13
  "author",
10
14
  "claimCommentId",
@@ -24,6 +28,8 @@ const DESCRIPTOR_KEYS = [
24
28
  "workItem",
25
29
  ];
26
30
  const HEX = /^[0-9a-f]{64}$/;
31
+ const SEGMENT = "[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}";
32
+ const DIRECTORY = new RegExp(`^${SEGMENT}(?:/${SEGMENT}){0,7}$`);
27
33
  const OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
28
34
 
29
35
  /** Only an explicit original Bun digest extends the unchanged npm-only schema. */
@@ -46,24 +52,142 @@ export function optionalRuntimeFields(value) {
46
52
  return ["runtimeSha256"];
47
53
  }
48
54
 
49
- /** One exact optional projection preserves historical keys at producer and verifier boundaries. */
55
+ /**
56
+ * A committed npm project directory is "." or a short, normalized relative
57
+ * path. Dot segments, absolute paths and installed trees can never name one,
58
+ * so a policy entry cannot point the updater outside the repository.
59
+ */
60
+ export function validDirectory(value) {
61
+ return (
62
+ typeof value === "string" &&
63
+ value.length <= 200 &&
64
+ (value === "." ||
65
+ (DIRECTORY.test(value) &&
66
+ posix.normalize(value) === value &&
67
+ !value.split("/").includes("node_modules")))
68
+ );
69
+ }
70
+
71
+ /** A proposal or descriptor without a directory is the historical root project. */
72
+ export function directoryOf(value) {
73
+ const directory = Object.hasOwn(value, "directory") ? value.directory : ".";
74
+ requireProof(validDirectory(directory), "invalid npm project directory");
75
+ return directory;
76
+ }
77
+
78
+ /** Repository path of one npm file in the value's project directory. */
79
+ export function npmPath(value, file) {
80
+ const directory = directoryOf(value);
81
+ return directory === "." ? file : `${directory}/${file}`;
82
+ }
83
+
84
+ /**
85
+ * Raw committed entry for one directory; the legacy single object is a one-entry list.
86
+ * More than one match is refused, so the hook never disagrees with selectPolicy.
87
+ */
88
+ export function policyEntry(config, directory) {
89
+ const raw = config?.npmUpdater;
90
+ const list = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];
91
+ const matches = list.filter(entry => entry?.directory === directory);
92
+ requireProof(matches.length <= 1, "duplicate npm updater directory");
93
+ return matches[0];
94
+ }
95
+
96
+ /** Caller must pass a config already validated by selectPolicy. */
97
+ export function proposalPolicy(config, value) {
98
+ const entry = policyEntry(config, directoryOf(value));
99
+ requireProof(
100
+ entry !== undefined,
101
+ "directory is not a committed npm updater selection"
102
+ );
103
+ return entry;
104
+ }
105
+
106
+ /**
107
+ * Only a subdirectory is signed: root descriptors keep their historical key
108
+ * set byte for byte, so an explicit "." stays an undeclared extra field.
109
+ * Subdirectories are npm-only, so they never carry an original Bun digest.
110
+ */
111
+ export function optionalDirectoryFields(value) {
112
+ if (!Object.hasOwn(value, "directory") || value.directory === ".") return [];
113
+ requireProof(
114
+ directoryOf(value) !== "." && !Object.hasOwn(value, "bunLockSha256"),
115
+ "a subdirectory npm proposal cannot bind a Bun lock"
116
+ );
117
+ return ["directory"];
118
+ }
119
+
120
+ /**
121
+ * One exact optional projection preserves historical keys at producer and verifier boundaries.
122
+ * @param {Record<string, any>} value - A proposal, descriptor or optional-field set.
123
+ * @returns {{ bunLockSha256?: string, runtimeSha256?: string, directory?: string }} Present signed optional fields only.
124
+ */
50
125
  export function signedProposalFields(value) {
51
126
  return Object.fromEntries(
52
- [...optionalLockFields(value), ...optionalRuntimeFields(value)].map(
53
- name => [name, value[name]]
54
- )
127
+ [
128
+ ...optionalLockFields(value),
129
+ ...optionalRuntimeFields(value),
130
+ ...optionalDirectoryFields(value),
131
+ ].map(name => [name, value[name]])
55
132
  );
56
133
  }
57
134
 
135
+ /** Sorted repository paths of the cohort the signed optional fields select; Bun stays root-only. */
136
+ function cohortNames(value) {
137
+ optionalDirectoryFields(value);
138
+ return [
139
+ ...(optionalLockFields(value).length ? [BUN_LOCK] : []),
140
+ ...FILES.map(file => npmPath(value, file)),
141
+ ];
142
+ }
143
+
58
144
  /** Signed original presence selects one closed two- or three-file cohort. */
59
145
  export function proposalFileNames(value) {
60
- const files = optionalLockFields(value).length
61
- ? ["bun.lock", ...FILES]
62
- : FILES;
146
+ const files = cohortNames(value);
63
147
  exactKeys(value.files, files, "proposal files");
64
148
  return files;
65
149
  }
66
150
 
151
+ /** The root install's inputs plus the proposal's own files must all survive the ordinary install unchanged. */
152
+ export function installInputs(value) {
153
+ return [...new Set([...FILES, ...cohortNames(value)])];
154
+ }
155
+
156
+ /** Committed history paths in their historical order; the root command string never changes. */
157
+ export function historyPaths(value) {
158
+ return [
159
+ npmPath(value, MANIFEST),
160
+ npmPath(value, NPM_LOCK),
161
+ ...(optionalLockFields(value).length ? [BUN_LOCK] : []),
162
+ ];
163
+ }
164
+
165
+ /** A subdirectory is npm-only: its own Bun lock must be absent, and the root one is outside its scope. */
166
+ export function directoryBunAbsent(value, git, absent) {
167
+ if (directoryOf(value) === ".") return false;
168
+ const lock = npmPath(value, BUN_LOCK);
169
+ requireProof(
170
+ git(["ls-tree", "HEAD", "--", lock]) === "" && absent(lock),
171
+ "subdirectory Bun lock is unsupported"
172
+ );
173
+ return true;
174
+ }
175
+
176
+ /** The closed cohort a recorded hash map must have: root two/three files or one directory's two. */
177
+ export function hashCohort(hashes) {
178
+ const lock = Object.keys(hashes ?? {}).find(name => name.endsWith(NPM_LOCK));
179
+ const directory =
180
+ lock === undefined || lock === NPM_LOCK
181
+ ? "."
182
+ : lock.slice(0, -(NPM_LOCK.length + 1));
183
+ const bun = Object.hasOwn(hashes ?? {}, BUN_LOCK);
184
+ return proposalFileNames({
185
+ directory,
186
+ files: hashes,
187
+ ...(bun ? { bunLockSha256: "0".repeat(64) } : {}),
188
+ });
189
+ }
190
+
67
191
  /** Canonical bytes are shared by allocator and consumer, not inferred hashes. */
68
192
  export function canonicalJson(value) {
69
193
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
@@ -149,9 +273,10 @@ export function trustedConfiguration(git) {
149
273
 
150
274
  /** Updates must be exactly the declared direct npm version changes. */
151
275
  export function npmProposal(descriptor, git) {
152
- const before = JSON.parse(git(["show", "HEAD:package.json"]));
153
- const after = JSON.parse(git(["show", ":package.json"]));
154
- const lock = JSON.parse(git(["show", ":package-lock.json"]));
276
+ const manifest = npmPath(descriptor, MANIFEST);
277
+ const before = JSON.parse(git(["show", `HEAD:${manifest}`]));
278
+ const after = JSON.parse(git(["show", `:${manifest}`]));
279
+ const lock = JSON.parse(git(["show", `:${npmPath(descriptor, NPM_LOCK)}`]));
155
280
  requireProof(
156
281
  [2, 3].includes(lock.lockfileVersion) && lock.packages?.[""],
157
282
  "unsupported npm lock"
@@ -12,6 +12,7 @@ import { requireProof, sha256 } from "./github-attestation-verifier.mjs";
12
12
  import { boundedSpawnSync } from "./bounded-spawn.mjs";
13
13
  import {
14
14
  canonicalJson,
15
+ directoryBunAbsent,
15
16
  exactKeys,
16
17
  proposalFileNames,
17
18
  signedProposalFields,
@@ -50,6 +51,8 @@ function stagedFiles(descriptor) {
50
51
 
51
52
  /** Bind optional lock presence to HEAD and refuse aliased working-tree counterparts. */
52
53
  function originalBun(descriptor) {
54
+ if (directoryBunAbsent(descriptor, git, path => fileAbsent(resolve(path))))
55
+ return;
53
56
  const original = git(["ls-tree", "HEAD", "--", "bun.lock"]);
54
57
  if (!Object.hasOwn(descriptor, "bunLockSha256")) {
55
58
  requireProof(original === "", "original Bun lock omitted from descriptor");
@@ -2,12 +2,8 @@
2
2
  // Do not edit directly — durable changes belong upstream in Lisa.
3
3
 
4
4
  /** Fixed-schema writer evidence and idempotent current claim. @module npm-updater */
5
- import {
6
- required,
7
- CLAIM,
8
- validateProposal,
9
- proposalFileNames,
10
- } from "./npm-update-contract.mjs";
5
+ import { required, CLAIM, validateProposal } from "./npm-update-contract.mjs";
6
+ import { historyPaths } from "./automation-provenance-contract.mjs";
11
7
  import { baseline } from "./npm-update-prepare.mjs";
12
8
  import { locateCheckpoint } from "./npm-update-recovery.mjs";
13
9
  import { runProcess } from "./npm-update-process.mjs";
@@ -48,9 +44,7 @@ export async function filingEvidence(api, proposal, config, cwd) {
48
44
  "--max-count=20",
49
45
  "--format=%H %s",
50
46
  "--",
51
- "package.json",
52
- "package-lock.json",
53
- ...(Object.hasOwn(proposal, "bunLockSha256") ? ["bun.lock"] : []),
47
+ ...historyPaths(proposal),
54
48
  ],
55
49
  {
56
50
  cwd,
@@ -69,7 +63,7 @@ export async function filingEvidence(api, proposal, config, cwd) {
69
63
  );
70
64
  return {
71
65
  history: {
72
- command: `git log ${proposal.parent} --max-count=20 -- package.json package-lock.json${proposalFileNames(proposal).includes("bun.lock") ? " bun.lock" : ""}`,
66
+ command: `git log ${proposal.parent} --max-count=20 -- ${historyPaths(proposal).join(" ")}`,
73
67
  result: history.stdout.toString() || "No matching history.",
74
68
  },
75
69
  search: { query, total: search.total_count },
@@ -10,6 +10,44 @@ import { runProcess, readBytes } from "./npm-update-process-core.mjs";
10
10
  import { binaryDigest } from "./npm-update-worker-lifecycle.mjs";
11
11
  import { canonicalJson } from "./automation-provenance-contract.mjs";
12
12
 
13
+ /** No path at all, including a dangling alias, may stand where a lock must be absent. */
14
+ function requireAbsent(path) {
15
+ required(!existsSync(path), "unexpected Bun lock path");
16
+ try {
17
+ lstatSync(path);
18
+ required(false, "unexpected Bun lock alias");
19
+ } catch (error) {
20
+ if (error.code !== "ENOENT") throw error;
21
+ }
22
+ }
23
+
24
+ /**
25
+ * A subdirectory npm project is a committed, unaliased real directory with no
26
+ * Bun lock of its own. The root bun.lock belongs to the root project, so a
27
+ * subdirectory proposal neither reads nor binds it.
28
+ */
29
+ export async function directoryBun(cwd, command, directory, proposal) {
30
+ if (directory === ".") return committedBun(cwd, command, proposal);
31
+ const tree = (
32
+ await command(["ls-tree", "HEAD", "--", directory])
33
+ ).stdout.toString();
34
+ const path = join(cwd, directory);
35
+ required(
36
+ tree.startsWith("040000 tree ") &&
37
+ tree.endsWith(`\t${directory}\n`) &&
38
+ tree.split("\n").length === 2 &&
39
+ realpathSync(path) === join(realpathSync(cwd), directory),
40
+ "committed real npm project directory required"
41
+ );
42
+ const lock = `${directory}/bun.lock`;
43
+ required(
44
+ !(await command(["ls-tree", "HEAD", "--", lock])).stdout.length,
45
+ "a subdirectory npm project cannot use a Bun lock"
46
+ );
47
+ requireAbsent(join(cwd, lock));
48
+ return undefined;
49
+ }
50
+
13
51
  /** An untracked, removed, aliased or changed original lock never becomes authority. */
14
52
  export async function committedBun(cwd, command, proposal) {
15
53
  const entry = (
@@ -17,13 +55,7 @@ export async function committedBun(cwd, command, proposal) {
17
55
  ).stdout.toString();
18
56
  const path = join(cwd, "bun.lock");
19
57
  if (!entry) {
20
- required(!existsSync(path), "unexpected Bun lock path");
21
- try {
22
- lstatSync(path);
23
- required(false, "unexpected Bun lock alias");
24
- } catch (error) {
25
- if (error.code !== "ENOENT") throw error;
26
- }
58
+ requireAbsent(path);
27
59
  required(
28
60
  !proposal || !Object.hasOwn(proposal, "bunLockSha256"),
29
61
  "original Bun lock was removed"
@@ -9,7 +9,7 @@ import {
9
9
  required,
10
10
  keys,
11
11
  OBJECT,
12
- validatePolicy,
12
+ selectPolicy,
13
13
  validateProposal,
14
14
  } from "./npm-update-contract.mjs";
15
15
  import {
@@ -33,8 +33,8 @@ import {
33
33
  } from "./github-attestation-recovery.mjs";
34
34
  import {
35
35
  DESCRIPTOR_KEYS,
36
- optionalLockFields,
37
- optionalRuntimeFields,
36
+ npmPath,
37
+ signedProposalFields,
38
38
  } from "./automation-provenance-contract.mjs";
39
39
 
40
40
  /** Only complete, digest-checked transport is considered; incomplete chunks grant nothing. */
@@ -58,7 +58,7 @@ export function completeCheckpoints(comments) {
58
58
  }
59
59
 
60
60
  /** Named committed objects, never ignored config or candidate paths, select historical authority. */
61
- export async function committedCancellationConfig(cwd, parent) {
61
+ export async function committedCancellationConfig(cwd, parent, directory) {
62
62
  required(
63
63
  typeof parent === "string" && OBJECT.test(parent),
64
64
  "invalid committed cancellation parent"
@@ -81,9 +81,9 @@ export async function committedCancellationConfig(cwd, parent) {
81
81
  config.automationProvenance?.enabled === true,
82
82
  "original committed authority is disabled"
83
83
  );
84
- validatePolicy(config.npmUpdater, config);
84
+ const { repository } = selectPolicy(config, directory);
85
85
  required(
86
- config.automationProvenance.repository === config.npmUpdater.repository,
86
+ config.automationProvenance.repository === repository,
87
87
  "original committed authority repository differs"
88
88
  );
89
89
  return config;
@@ -132,9 +132,9 @@ export function assertOriginTransport(
132
132
  }
133
133
  }
134
134
 
135
- /** Original claim, body, policy and proposal are checked separately from current authority. */
136
- async function inspectOrigin(api, issue, payload, oldConfig, currentConfig) {
137
- const policy = validatePolicy(oldConfig.npmUpdater, oldConfig);
135
+ /** Original claim, body, policy and proposal are checked separately from current authority; the authenticated current directory selects the old entry. */
136
+ async function inspectOrigin(api, issue, payload, oldConfig, current) {
137
+ const policy = selectPolicy(oldConfig, current.directory);
138
138
  const proposal = validateProposal(payload.proposal, policy);
139
139
  const allocation = payload.allocation;
140
140
  keys(allocation, [
@@ -158,7 +158,7 @@ async function inspectOrigin(api, issue, payload, oldConfig, currentConfig) {
158
158
  // The current qualified classifier checks present holds; historical config only supplies the original draft.
159
159
  const state = await (
160
160
  issue.state === "open" ? inspectLeaf : inspectCancelledLeaf
161
- )(issue, draft, policy, currentConfig);
161
+ )(issue, draft, policy, current.config);
162
162
  required(
163
163
  state.claimed &&
164
164
  !state.unassigned &&
@@ -184,11 +184,8 @@ export function originalDescriptor(checkpoint, old, allocation, authority) {
184
184
  const preview = checkpoint.payload.preview;
185
185
  keys(preview, ["descriptor", "message", "epoch"]);
186
186
  const d = preview.descriptor;
187
- keys(d, [
188
- ...DESCRIPTOR_KEYS,
189
- ...optionalLockFields(old),
190
- ...optionalRuntimeFields(old),
191
- ]);
187
+ const signed = signedProposalFields(old);
188
+ keys(d, [...DESCRIPTOR_KEYS, ...Object.keys(signed)]);
192
189
  required(
193
190
  d.version === 1 &&
194
191
  d.parent === old.parent &&
@@ -199,8 +196,7 @@ export function originalDescriptor(checkpoint, old, allocation, authority) {
199
196
  d.proposalKey === old.bindingKey &&
200
197
  d.policySha256 === sha256(canonicalJson(authority)) &&
201
198
  canonicalJson(d.files) === canonicalJson(old.hashes) &&
202
- d.bunLockSha256 === old.bunLockSha256 &&
203
- d.runtimeSha256 === old.runtimeSha256 &&
199
+ canonicalJson(signedProposalFields(d)) === canonicalJson(signed) &&
204
200
  canonicalJson(d.updates) === canonicalJson(old.updates) &&
205
201
  typeof preview.message === "string" &&
206
202
  sha256(preview.message) === d.messageSha256 &&
@@ -260,7 +256,11 @@ export async function authenticateStaleOrigin({
260
256
  old.selectionKey === proposal.selectionKey,
261
257
  "origin is not this stale selection"
262
258
  );
263
- const oldConfig = await committedCancellationConfig(cwd, old.parent);
259
+ const oldConfig = await committedCancellationConfig(
260
+ cwd,
261
+ old.parent,
262
+ proposal.directory
263
+ );
264
264
  const authority = oldConfig.automationProvenance;
265
265
  required(
266
266
  [
@@ -278,11 +278,11 @@ export async function authenticateStaleOrigin({
278
278
  issue,
279
279
  checkpoint.payload,
280
280
  oldConfig,
281
- config
281
+ { config, directory: proposal.directory }
282
282
  );
283
283
  const manifest = await runProcess(
284
284
  "git",
285
- ["show", `${old.parent}:package.json`],
285
+ ["show", `${old.parent}:${npmPath(old, "package.json")}`],
286
286
  {
287
287
  cwd,
288
288
  env: {
@@ -3,7 +3,11 @@
3
3
 
4
4
  /** A manual cancellation is a third fixed signing purpose, never publication or review authority. */
5
5
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
6
- import { required, keys, FILES, OBJECT } from "./npm-update-contract.mjs";
6
+ import { required, keys, OBJECT } from "./npm-update-contract.mjs";
7
+ import {
8
+ hashCohort,
9
+ proposalPolicy,
10
+ } from "./automation-provenance-contract.mjs";
7
11
  import { observedRunChronology } from "./github-attestation-recovery.mjs";
8
12
  import {
9
13
  verifiedRole,
@@ -106,12 +110,8 @@ export function assertManualCancellation(
106
110
  /** The closed subject preserves one stale origin and one exact replacement, with no published destination. */
107
111
  export function validateCancellation(value, expected) {
108
112
  keys(value, RECORD_KEYS);
109
- keys(
110
- value.proposalHashes,
111
- Object.hasOwn(expected.proposalHashes, "bun.lock")
112
- ? ["bun.lock", ...FILES]
113
- : FILES
114
- );
113
+ // Root {bun.lock?, package-lock.json, package.json} or exactly one directory's two npm files.
114
+ keys(value.proposalHashes, hashCohort(expected.proposalHashes));
115
115
  keys(value.destination, ["branch", "expectedBranchHead", "prNumber"]);
116
116
  required(
117
117
  value.version === 1 &&
@@ -228,7 +228,7 @@ export function cancellationRecord(
228
228
  leafBodySha256: sha256(origin.allocation.draft.body),
229
229
  policySha256: sha256(canonicalJson(authority)),
230
230
  npmPolicySha256: proposal.policySha256,
231
- maintainer: config.npmUpdater.maintainer,
231
+ maintainer: proposalPolicy(config, proposal).maintainer,
232
232
  operatorId,
233
233
  runId: invocation.runId,
234
234
  runAttempt: invocation.runAttempt,
@@ -6,6 +6,7 @@ import { join } from "node:path";
6
6
  import { writeFileSync } from "node:fs";
7
7
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
8
8
  import { required, keys } from "./npm-update-contract.mjs";
9
+ import { proposalPolicy } from "./automation-provenance-contract.mjs";
9
10
  import { readBytes, readJson, writeJson } from "./npm-update-process.mjs";
10
11
  import { assertHostedGate } from "./npm-update-hosted-gate.mjs";
11
12
  import { sha256 } from "./github-attestation-verifier.mjs";
@@ -47,7 +48,8 @@ export function assertDispatchCancellation(event, run, request, authority) {
47
48
 
48
49
  /** The actual run and repository permission are read through the existing pinned default-token transport. */
49
50
  async function manualAuthority(api, proposal, config, request) {
50
- assertHostedGate({ policy: config.npmUpdater, proposal, config });
51
+ const policy = proposalPolicy(config, proposal);
52
+ assertHostedGate({ policy, proposal, config });
51
53
  const invocation = {
52
54
  runId: process.env.GITHUB_RUN_ID,
53
55
  runAttempt: process.env.GITHUB_RUN_ATTEMPT,
@@ -63,13 +65,13 @@ async function manualAuthority(api, proposal, config, request) {
63
65
  `repos/${proposal.repository}/actions/runs/${invocation.runId}/attempts/${invocation.runAttempt}`
64
66
  );
65
67
  const permission = await api.request(
66
- `repos/${proposal.repository}/collaborators/${config.npmUpdater.maintainer}/permission`
68
+ `repos/${proposal.repository}/collaborators/${policy.maintainer}/permission`
67
69
  );
68
70
  const operatorId = assertManualCancellation(
69
71
  run,
70
72
  permission,
71
73
  api.policy,
72
- config.npmUpdater.maintainer,
74
+ policy.maintainer,
73
75
  proposal,
74
76
  request,
75
77
  invocation
@@ -12,6 +12,7 @@ export { UpdaterError, required, keys } from "./npm-update-invariants.mjs";
12
12
  import { canonicalJson } from "./automation-provenance-contract.mjs";
13
13
  import { sha256 } from "./github-attestation-verifier.mjs";
14
14
  import {
15
+ npmPath,
15
16
  optionalLockFields,
16
17
  optionalRuntimeFields,
17
18
  proposalFileNames,
@@ -28,7 +29,12 @@ export const SECTIONS = [
28
29
  ];
29
30
  export const CLAIM =
30
31
  "[lisa-tracker-claim] Claimed by Lisa. Starting implementation.";
31
- export { NAME, VERSION, validatePolicy } from "./npm-update-policy.mjs";
32
+ export {
33
+ NAME,
34
+ VERSION,
35
+ validatePolicy,
36
+ selectPolicy,
37
+ } from "./npm-update-policy.mjs";
32
38
  import { VERSION } from "./npm-update-policy.mjs";
33
39
  export const OBJECT = /^[a-f0-9]{40}$/;
34
40
 
@@ -168,7 +174,7 @@ export function selectionKey(policy, updates) {
168
174
  repository: policy.repository,
169
175
  target: "main",
170
176
  ecosystem: "npm",
171
- directory: ".",
177
+ directory: policy.directory,
172
178
  policySha256: sha256(canonicalJson(policy)),
173
179
  versions: updates
174
180
  .map(({ name, to }) => ({ name, version: to }))
@@ -190,6 +196,7 @@ export function proposalFrom(
190
196
  const optional = {
191
197
  ...(bunLockSha256 === undefined ? {} : { bunLockSha256 }),
192
198
  ...runtimeBinding(policy),
199
+ ...(policy.directory === "." ? {} : { directory: policy.directory }),
193
200
  };
194
201
  const names = proposalFileNames({ files, ...optional });
195
202
  for (const value of Object.values(files))
@@ -197,8 +204,8 @@ export function proposalFrom(
197
204
  typeof value === "string" && Buffer.byteLength(value) <= 1_048_576,
198
205
  "oversize proposal file"
199
206
  );
200
- const after = JSON.parse(files["package.json"]);
201
- const lock = JSON.parse(files["package-lock.json"]);
207
+ const after = JSON.parse(files[npmPath(optional, "package.json")]);
208
+ const lock = JSON.parse(files[npmPath(optional, "package-lock.json")]);
202
209
  validateManifest(before, after, updates, policy);
203
210
  validateLock(lock, after, updates);
204
211
  const ordered = [...updates].sort((a, b) => a.name.localeCompare(b.name));
@@ -206,7 +213,7 @@ export function proposalFrom(
206
213
  repository: policy.repository,
207
214
  target: policy.target,
208
215
  ecosystem: "npm",
209
- directory: ".",
216
+ directory: policy.directory,
210
217
  parent,
211
218
  policySha256: sha256(canonicalJson(policy)),
212
219
  updates: ordered,
@@ -22,6 +22,7 @@ import {
22
22
  withPrivateRoot,
23
23
  } from "./npm-update-process.mjs";
24
24
  import { baseline } from "./npm-update-prepare.mjs";
25
+ import { signedProposalFields } from "./automation-provenance-contract.mjs";
25
26
  import { sha256 } from "./github-attestation-verifier.mjs";
26
27
  import {
27
28
  createHostedGate,
@@ -125,12 +126,8 @@ export async function descriptorFor({
125
126
  author: identity,
126
127
  committer: identity,
127
128
  files: proposal.hashes,
128
- ...(proposal.bunLockSha256 === undefined
129
- ? {}
130
- : { bunLockSha256: proposal.bunLockSha256 }),
131
- ...(proposal.runtimeSha256 === undefined
132
- ? {}
133
- : { runtimeSha256: proposal.runtimeSha256 }),
129
+ // Root keeps its historical key set; only a subdirectory adds `directory`.
130
+ ...signedProposalFields(proposal),
134
131
  messageSha256: sha256(message),
135
132
  updates: proposal.updates,
136
133
  proposalKey: proposal.bindingKey,
@@ -5,6 +5,7 @@
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { required, proposalFileNames } from "./npm-update-contract.mjs";
8
+ import { installInputs } from "./automation-provenance-contract.mjs";
8
9
  import { qualifiedBun, frozenBun } from "./npm-update-bun.mjs";
9
10
  import { runProcess } from "./npm-update-process.mjs";
10
11
  import { qualifiedControllerGraph } from "./npm-update-helper.mjs";
@@ -97,9 +98,7 @@ async function installHostedDependencies(context, root, env) {
97
98
  installed.BUNDLE_FROZEN = "true";
98
99
  }
99
100
  const before = [
100
- "package.json",
101
- "package-lock.json",
102
- ...(context.proposal.bunLockSha256 === undefined ? [] : ["bun.lock"]),
101
+ ...installInputs(context.proposal),
103
102
  ...(ruby ? ["Gemfile", "Gemfile.lock"] : []),
104
103
  ].map(name => [name, readFileSync(join(context.cwd, name))]);
105
104
  await nativeStep(context, installed, "npm", [
@@ -5,6 +5,7 @@
5
5
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
6
6
  import { required } from "./npm-update-contract.mjs";
7
7
  import { trackerContract } from "../lisa-work-item.mjs";
8
+ import { directoryOf, npmPath } from "./automation-provenance-contract.mjs";
8
9
 
9
10
  /** Immutable host config, not candidate data or local aliases, chooses lifecycle. */
10
11
  export function leafRoles(config, repository) {
@@ -79,6 +80,10 @@ export function buildDraft(proposal, policy, config, evidence) {
79
80
  .map(update => `${update.name}: ${update.from} -> ${update.to}`)
80
81
  .join("\n");
81
82
  const bun = Object.hasOwn(proposal, "bunLockSha256");
83
+ // Root paths render exactly as they always have; a subdirectory names its own files.
84
+ const directory = directoryOf(proposal);
85
+ const manifest = npmPath(proposal, "package.json");
86
+ const lock = npmPath(proposal, "package-lock.json");
82
87
  const body = `## Context / Business Value
83
88
 
84
89
  Keep the selected dependencies current while preserving ordinary review, required checks and runtime verification. This Task owns one exact dependency proposal; its implementation ticket is never reused for another update.
@@ -88,7 +93,7 @@ Keep the selected dependencies current while preserving ordinary review, require
88
93
  Base parent: ${proposal.parent}
89
94
  Proposal key: ${proposal.key}
90
95
  Selection key: ${proposal.selectionKey}
91
- Update exactly package.json and package-lock.json${bun ? " and bun.lock" : ""}:
96
+ Update exactly ${manifest} and ${lock}${bun ? " and bun.lock" : ""}:
92
97
  ${versions}
93
98
  Use the trusted four-job npm updater. Preparation performs an installed-tree npm outdated check and npm ci with lifecycle scripts disabled. Allocation precedes the first attributed commit. Ordinary commit and original pre-push gates remain mandatory. Publish only the exact gated unsigned raw Git object with unchanged parent, tree, identities, times and message. Preserve every unrelated dependency, script and existing assignee. Stop on stale base, unavailable authorization, hold, failed gate or mismatching bytes. Lisa is excluded only with verified local full-apply ownership.
94
99
 
@@ -156,14 +161,17 @@ Matches are read completely before allocating this deterministic proposal. No pa
156
161
 
157
162
  ## Proposal Bytes
158
163
 
159
- package.json SHA256: ${proposal.hashes["package.json"]}
160
- package-lock.json SHA256: ${proposal.hashes["package-lock.json"]}${bun ? `\nbun.lock SHA256: ${proposal.hashes["bun.lock"]}\nOriginal bun.lock SHA256: ${proposal.bunLockSha256}` : ""}
164
+ ${manifest} SHA256: ${proposal.hashes[manifest]}
165
+ ${lock} SHA256: ${proposal.hashes[lock]}${bun ? `\nbun.lock SHA256: ${proposal.hashes["bun.lock"]}\nOriginal bun.lock SHA256: ${proposal.bunLockSha256}` : ""}
161
166
 
162
167
  <!-- [lisa-npm-filing] ${Buffer.from(canonicalJson(evidence)).toString("base64")} -->
163
168
  <!-- [lisa-npm-proposal] ${proposal.key} -->
164
169
  `;
165
170
  return {
166
- title: "Update selected npm dependencies",
171
+ title:
172
+ directory === "."
173
+ ? "Update selected npm dependencies"
174
+ : `Update selected npm dependencies in ${directory}`,
167
175
  body,
168
176
  labels: ["type:Task", "priority:medium", roles.ready],
169
177
  assignees: [policy.maintainer],
@@ -15,6 +15,7 @@ import {
15
15
  import { createHash } from "node:crypto";
16
16
  import { join, dirname, isAbsolute, parse } from "node:path";
17
17
  import { required } from "./npm-update-contract.mjs";
18
+ import { npmPath } from "./automation-provenance-contract.mjs";
18
19
  import { readBytes, runProcess } from "./npm-update-process-core.mjs";
19
20
  import { sha256 } from "./github-attestation-verifier.mjs";
20
21
 
@@ -94,7 +95,9 @@ export async function registryVersion(update, proposal) {
94
95
  ignoreBOM: true,
95
96
  }).decode(Buffer.concat(chunks));
96
97
  const value = JSON.parse(text);
97
- const lock = JSON.parse(proposal.files["package-lock.json"]);
98
+ const lock = JSON.parse(
99
+ proposal.files[npmPath(proposal, "package-lock.json")]
100
+ );
98
101
  const item = lock.packages?.[`node_modules/${update.name}`];
99
102
  required(
100
103
  value.name === update.name &&