@codyswann/lisa 5.2.2 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/all/copy-overwrite/scripts/lib/automation-provenance-contract.mjs +38 -2
  2. package/all/copy-overwrite/scripts/lib/github-attestation-provider.mjs +13 -9
  3. package/all/copy-overwrite/scripts/lib/github-attestation-recovery.mjs +12 -1
  4. package/all/copy-overwrite/scripts/lib/github-attestation-verifier.mjs +40 -3
  5. package/all/copy-overwrite/scripts/lib/npm-update-allocate.mjs +9 -4
  6. package/all/copy-overwrite/scripts/lib/npm-update-cancel-origin.mjs +1 -1
  7. package/all/copy-overwrite/scripts/lib/npm-update-cancellation-proof.mjs +16 -5
  8. package/all/copy-overwrite/scripts/lib/npm-update-cancellation.mjs +23 -6
  9. package/all/copy-overwrite/scripts/lib/npm-update-contract.mjs +9 -3
  10. package/all/copy-overwrite/scripts/lib/npm-update-controller-factory.mjs +4 -2
  11. package/all/copy-overwrite/scripts/lib/npm-update-gh-requests.mjs +5 -1
  12. package/all/copy-overwrite/scripts/lib/npm-update-github.mjs +28 -6
  13. package/all/copy-overwrite/scripts/lib/npm-update-hosted-gate.mjs +6 -2
  14. package/all/copy-overwrite/scripts/lib/npm-update-hosted-scope.mjs +2 -2
  15. package/all/copy-overwrite/scripts/lib/npm-update-invariants.mjs +2 -0
  16. package/all/copy-overwrite/scripts/lib/npm-update-leaf-contract.mjs +31 -16
  17. package/all/copy-overwrite/scripts/lib/npm-update-leaf.mjs +3 -3
  18. package/all/copy-overwrite/scripts/lib/npm-update-policy.mjs +40 -4
  19. package/all/copy-overwrite/scripts/lib/npm-update-publication.mjs +15 -4
  20. package/all/copy-overwrite/scripts/lib/npm-update-publish.mjs +2 -1
  21. package/all/copy-overwrite/scripts/lib/npm-update-quality.mjs +29 -6
  22. package/all/copy-overwrite/scripts/lib/npm-update-recovery.mjs +3 -0
  23. package/all/copy-overwrite/scripts/lib/npm-update-supersession.mjs +1 -1
  24. package/all/copy-overwrite/scripts/lisa-automation-provenance.mjs +7 -1
  25. package/all/copy-overwrite/scripts/lisa-npm-updater.mjs +46 -1
  26. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +28 -25
  27. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  28. package/dist/core/lisa-owned-hash-ledger.js +56 -0
  29. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  30. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  31. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  32. package/dist/core/upstream-evidence-manifest.js +33 -27
  33. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  34. package/package.json +4 -4
  35. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa/rules/reference/derived-branch-plan.md +2 -2
  38. package/plugins/lisa-agy/plugin.json +1 -1
  39. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  41. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  42. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  46. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-copilot/rules/reference/derived-branch-plan.md +2 -2
  48. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-cursor/rules/derived-branch-plan-reference.mdc +2 -2
  50. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  52. package/plugins/lisa-devin/rules/reference/derived-branch-plan.md +2 -2
  53. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  55. package/plugins/lisa-expo-agy/plugin.json +1 -1
  56. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  60. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  63. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  67. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  69. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  70. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  74. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  76. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  77. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  81. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-rails-agy/plugin.json +1 -1
  84. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  88. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  90. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  91. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  93. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  95. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  97. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  98. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  99. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  102. package/plugins/src/base/rules/reference/derived-branch-plan.md +2 -2
@@ -3,7 +3,11 @@
3
3
 
4
4
  /** Closed canonical schemas and committed npm policy remain independent of local proof IO. */
5
5
  import { posix } from "node:path";
6
- import { requireProof } from "./github-attestation-verifier.mjs";
6
+ import {
7
+ requireProof,
8
+ DEFAULT_TARGET,
9
+ targetBranch,
10
+ } from "./github-attestation-verifier.mjs";
7
11
 
8
12
  const MANIFEST = "package.json";
9
13
  const NPM_LOCK = "package-lock.json";
@@ -93,6 +97,20 @@ export function policyEntry(config, directory) {
93
97
  return matches[0];
94
98
  }
95
99
 
100
+ /**
101
+ * A signed subject's target must be the committed policy's target for its
102
+ * directory; an omitted target on either side is main.
103
+ */
104
+ export function assertCommittedTarget(config, value) {
105
+ const entry = policyEntry(config, directoryOf(value));
106
+ const committed =
107
+ entry && Object.hasOwn(entry, "target") ? entry.target : DEFAULT_TARGET;
108
+ requireProof(
109
+ targetBranch(value) === committed,
110
+ "proposal target differs from committed npm policy"
111
+ );
112
+ }
113
+
96
114
  /** Caller must pass a config already validated by selectPolicy. */
97
115
  export function proposalPolicy(config, value) {
98
116
  const entry = policyEntry(config, directoryOf(value));
@@ -117,10 +135,27 @@ export function optionalDirectoryFields(value) {
117
135
  return ["directory"];
118
136
  }
119
137
 
138
+ /**
139
+ * Only a non-main target is signed: main descriptors keep their historical key
140
+ * set byte for byte, so an explicit "main" stays an undeclared extra field.
141
+ */
142
+ export function optionalTargetFields(value) {
143
+ if (!Object.hasOwn(value, "target") || value.target === DEFAULT_TARGET)
144
+ return [];
145
+ targetBranch(value);
146
+ return ["target"];
147
+ }
148
+
149
+ /** A value's target field only when it is not main; spread into signed subjects. */
150
+ export function targetField(value) {
151
+ const target = targetBranch(value);
152
+ return target === DEFAULT_TARGET ? {} : { target };
153
+ }
154
+
120
155
  /**
121
156
  * One exact optional projection preserves historical keys at producer and verifier boundaries.
122
157
  * @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.
158
+ * @returns {{ bunLockSha256?: string, runtimeSha256?: string, directory?: string, target?: string }} Present signed optional fields only.
124
159
  */
125
160
  export function signedProposalFields(value) {
126
161
  return Object.fromEntries(
@@ -128,6 +163,7 @@ export function signedProposalFields(value) {
128
163
  ...optionalLockFields(value),
129
164
  ...optionalRuntimeFields(value),
130
165
  ...optionalDirectoryFields(value),
166
+ ...optionalTargetFields(value),
131
167
  ].map(name => [name, value[name]])
132
168
  );
133
169
  }
@@ -8,6 +8,8 @@ import {
8
8
  requireProof,
9
9
  sha256,
10
10
  assertPinnedVerifier,
11
+ DEFAULT_TARGET,
12
+ targetBranch,
11
13
  } from "./github-attestation-verifier.mjs";
12
14
 
13
15
  const API = "api";
@@ -15,20 +17,22 @@ const HOST_FLAG = "--hostname";
15
17
  const PUBLIC_HOST = "github.com";
16
18
 
17
19
  /** Provider identity never treats unavailable state as an absent scope. */
18
- function repositoryState(read, policy, parent) {
20
+ function repositoryState(read, policy, parent, target) {
19
21
  const repo = read(`repos/${policy.repository}`);
20
22
  requireProof(
21
23
  String(repo.id) === policy.repositoryId &&
22
24
  String(repo.owner?.id) === policy.ownerId,
23
25
  "provider repository identity differs"
24
26
  );
27
+ // A non-main target need not be the repository default; its ref read proves it exists.
25
28
  requireProof(
26
- repo.full_name === policy.repository && repo.default_branch === "main",
29
+ repo.full_name === policy.repository &&
30
+ (target !== DEFAULT_TARGET || repo.default_branch === DEFAULT_TARGET),
27
31
  "provider main scope differs"
28
32
  );
29
- const main = read(`repos/${policy.repository}/git/ref/heads/main`);
33
+ const main = read(`repos/${policy.repository}/git/ref/heads/${target}`);
30
34
  requireProof(
31
- main.ref === "refs/heads/main" && main.object?.sha === parent,
35
+ main.ref === `refs/heads/${target}` && main.object?.sha === parent,
32
36
  "provider main base differs"
33
37
  );
34
38
  }
@@ -45,7 +49,7 @@ function runState(read, policy, descriptor, historical) {
45
49
  );
46
50
  requireProof(
47
51
  run.head_sha === descriptor.parent &&
48
- run.head_branch === "main" &&
52
+ run.head_branch === targetBranch(descriptor) &&
49
53
  (historical
50
54
  ? ["in_progress", "completed"].includes(run.status)
51
55
  : run.status === "in_progress"),
@@ -99,7 +103,7 @@ function claimState(read, policy, descriptor) {
99
103
  function providerOrigin(policy, descriptor, historical, execute) {
100
104
  const read = endpoint =>
101
105
  ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
102
- repositoryState(read, policy, descriptor.parent);
106
+ repositoryState(read, policy, descriptor.parent, targetBranch(descriptor));
103
107
  return {
104
108
  run: runState(read, policy, descriptor, historical),
105
109
  claim: claimState(read, policy, descriptor),
@@ -165,7 +169,7 @@ export function verifyCurrentRun(
165
169
  ) {
166
170
  const read = endpoint =>
167
171
  ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
168
- repositoryState(read, policy, descriptor.parent);
172
+ repositoryState(read, policy, descriptor.parent, targetBranch(descriptor));
169
173
  return runState(read, policy, descriptor, false);
170
174
  }
171
175
 
@@ -193,7 +197,7 @@ export function verifyStaleOriginProvider(
193
197
  );
194
198
  const read = endpoint =>
195
199
  ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
196
- repositoryState(read, policy, currentParent);
200
+ repositoryState(read, policy, currentParent, targetBranch(descriptor));
197
201
  return {
198
202
  run: runState(read, policy, descriptor, true),
199
203
  claim: claimState(read, policy, descriptor),
@@ -271,7 +275,7 @@ export function verifyRecoveryProvider(
271
275
  pulls[0].head?.sha === recovery.expectedPrHead &&
272
276
  pulls[0].head?.ref === recovery.branch &&
273
277
  pulls[0].head?.repo?.full_name === policy.repository &&
274
- pulls[0].base?.ref === "main" &&
278
+ pulls[0].base?.ref === targetBranch(descriptor) &&
275
279
  pulls[0].base?.repo?.full_name === policy.repository,
276
280
  "foreign/closed/changed recovery PR"
277
281
  );
@@ -16,6 +16,8 @@ import {
16
16
  officialResult,
17
17
  PROPOSAL_PREDICATE,
18
18
  RECOVERY_PREDICATE,
19
+ DEFAULT_TARGET,
20
+ targetBranch,
19
21
  } from "./github-attestation-verifier.mjs";
20
22
 
21
23
  /** An active run's update is not completion; invalid provider chronology has no usable bounds. */
@@ -112,10 +114,19 @@ export function validateRecovery(value, origin, digest, policy) {
112
114
  typeof value === "object" &&
113
115
  !Array.isArray(value) &&
114
116
  Object.keys(value).sort().join("\n") ===
115
- [...RECOVERY_KEYS].sort().join("\n"),
117
+ [
118
+ ...RECOVERY_KEYS,
119
+ // Only a non-main origin target is carried, so main recoveries keep their bytes.
120
+ ...(targetBranch(origin) === DEFAULT_TARGET ? [] : ["target"]),
121
+ ]
122
+ .sort()
123
+ .join("\n"),
116
124
  "recovery fields differ"
117
125
  );
118
126
  const expected = {
127
+ ...(targetBranch(origin) === DEFAULT_TARGET
128
+ ? {}
129
+ : { target: targetBranch(origin) }),
119
130
  version: 1,
120
131
  purpose: "resume-identical-npm-proposal",
121
132
  repository: policy.repository,
@@ -23,6 +23,43 @@ export function requireProof(condition, reason) {
23
23
  if (!condition) throw new Error(`Invalid automation provenance: ${reason}`);
24
24
  }
25
25
 
26
+ /** An absent target is the historical branch, so main-target bytes never change. */
27
+ export const DEFAULT_TARGET = "main";
28
+
29
+ /**
30
+ * git check-ref-format rules, narrowed to a conservative character set, so a
31
+ * target is safe inside an API path, a refs/heads/ ref and a public diagnostic.
32
+ */
33
+ export function validBranchName(name) {
34
+ return (
35
+ typeof name === "string" &&
36
+ name.length > 0 &&
37
+ name.length <= 255 &&
38
+ /^[A-Za-z0-9._/-]+$/.test(name) &&
39
+ !name.startsWith("-") &&
40
+ !name.endsWith(".") &&
41
+ !name.includes("..") &&
42
+ name
43
+ .split("/")
44
+ .every(
45
+ part =>
46
+ part.length > 0 && !part.startsWith(".") && !part.endsWith(".lock")
47
+ )
48
+ );
49
+ }
50
+
51
+ /**
52
+ * The branch a proposal, descriptor, recovery, cancellation or GH subject targets.
53
+ * Only a non-main target is ever written into those objects.
54
+ */
55
+ export function targetBranch(value) {
56
+ const target = Object.hasOwn(value ?? {}, "target")
57
+ ? value.target
58
+ : DEFAULT_TARGET;
59
+ requireProof(validBranchName(target), "invalid target branch");
60
+ return target;
61
+ }
62
+
26
63
  /** Run only the trusted, hash-pinned official executable with bounded output. */
27
64
  export function assertPinnedVerifier(policy) {
28
65
  requireProof(
@@ -67,11 +104,11 @@ function matchCertificate(certificate, descriptor, policy) {
67
104
  issuer: ACTIONS_ISSUER,
68
105
  buildSignerURI: `https://github.com/${policy.signerWorkflow}@${policy.signerDigest}`,
69
106
  buildSignerDigest: policy.signerDigest,
70
- buildConfigURI: `https://github.com/${policy.callerWorkflow}@refs/heads/main`,
107
+ buildConfigURI: `https://github.com/${policy.callerWorkflow}@refs/heads/${targetBranch(descriptor)}`,
71
108
  buildConfigDigest: descriptor.parent,
72
109
  sourceRepositoryURI: `https://github.com/${policy.repository}`,
73
110
  sourceRepositoryDigest: descriptor.parent,
74
- sourceRepositoryRef: "refs/heads/main",
111
+ sourceRepositoryRef: `refs/heads/${targetBranch(descriptor)}`,
75
112
  sourceRepositoryIdentifier: policy.repositoryId,
76
113
  sourceRepositoryOwnerIdentifier: policy.ownerId,
77
114
  runInvocationURI: `https://github.com/${policy.repository}/actions/runs/${descriptor.runId}/attempts/${descriptor.runAttempt}`,
@@ -190,7 +227,7 @@ export function officialArguments(policy, identity, file, bundle, predicate) {
190
227
  "--source-digest",
191
228
  identity.parent,
192
229
  "--source-ref",
193
- "refs/heads/main",
230
+ `refs/heads/${targetBranch(identity)}`,
194
231
  "--predicate-type",
195
232
  predicate,
196
233
  "--cert-oidc-issuer",
@@ -2,7 +2,12 @@
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 { required, CLAIM, validateProposal } from "./npm-update-contract.mjs";
5
+ import {
6
+ required,
7
+ CLAIM,
8
+ validateProposal,
9
+ policyTarget,
10
+ } from "./npm-update-contract.mjs";
6
11
  import { historyPaths } from "./automation-provenance-contract.mjs";
7
12
  import { baseline } from "./npm-update-prepare.mjs";
8
13
  import { locateCheckpoint } from "./npm-update-recovery.mjs";
@@ -32,7 +37,7 @@ export async function filingEvidence(api, proposal, config, cwd) {
32
37
  proposal
33
38
  );
34
39
  const tracker = trackerFor(api, proposal, config);
35
- await api.main(proposal.parent);
40
+ await api.main(proposal.parent, proposal.target);
36
41
  const search = await tracker.relationships(proposal);
37
42
  required(
38
43
  !search.incomplete_results && search.total_count <= 100,
@@ -250,7 +255,7 @@ export async function allocateLeaf({
250
255
  let proposal = suppliedProposal;
251
256
  validateProposal(proposal, policy);
252
257
  const tracker = trackerFor(api, policy, config);
253
- await api.main(proposal.parent);
258
+ await api.main(proposal.parent, proposal.target);
254
259
  const prior = await discoverPrior(api, proposal, { cwd, config });
255
260
  if (prior.status === "stale-outstanding")
256
261
  return {
@@ -273,7 +278,7 @@ export async function allocateLeaf({
273
278
  const evidence = prior.issue
274
279
  ? historicalFiling(prior.issue)
275
280
  : currentEvidence;
276
- const roles = leafRoles(config, policy.repository);
281
+ const roles = leafRoles(config, policy.repository, policyTarget(policy));
277
282
  const inputs = {
278
283
  api,
279
284
  proposal,
@@ -248,7 +248,7 @@ export async function authenticateStaleOrigin({
248
248
  proposal,
249
249
  config,
250
250
  }) {
251
- await api.main(proposal.parent);
251
+ await api.main(proposal.parent, proposal.target);
252
252
  const checkpoint = originCheckpoint(issue);
253
253
  const old = checkpoint.payload.proposal;
254
254
  required(
@@ -3,10 +3,17 @@
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, OBJECT } from "./npm-update-contract.mjs";
6
+ import {
7
+ required,
8
+ keys,
9
+ OBJECT,
10
+ policyTarget,
11
+ } from "./npm-update-contract.mjs";
7
12
  import {
8
13
  hashCohort,
9
14
  proposalPolicy,
15
+ optionalTargetFields,
16
+ targetField,
10
17
  } from "./automation-provenance-contract.mjs";
11
18
  import { observedRunChronology } from "./github-attestation-recovery.mjs";
12
19
  import {
@@ -14,6 +21,7 @@ import {
14
21
  matchSigningTime,
15
22
  officialResult,
16
23
  sha256,
24
+ targetBranch,
17
25
  } from "./github-attestation-verifier.mjs";
18
26
 
19
27
  export const CANCELLATION_PREDICATE =
@@ -78,7 +86,7 @@ export function assertManualCancellation(
78
86
  policy.allowedTriggers?.includes("workflow_dispatch") &&
79
87
  run.status === "in_progress" &&
80
88
  run.head_sha === proposal.parent &&
81
- run.head_branch === "main" &&
89
+ run.head_branch === policyTarget(proposal) &&
82
90
  run.path === policy.callerWorkflow.slice(policy.repository.length + 1) &&
83
91
  String(run.head_repository?.id) === policy.repositoryId &&
84
92
  Array.isArray(run.referenced_workflows) &&
@@ -87,7 +95,7 @@ export function assertManualCancellation(
87
95
  workflow.path?.split("@")[0] === policy.signerWorkflow &&
88
96
  workflow.sha === policy.signerDigest
89
97
  ),
90
- "cancellation requires the actual manual main invocation"
98
+ "cancellation requires the actual manual target-branch invocation"
91
99
  );
92
100
  const actor = run.triggering_actor;
93
101
  required(
@@ -109,7 +117,8 @@ export function assertManualCancellation(
109
117
 
110
118
  /** The closed subject preserves one stale origin and one exact replacement, with no published destination. */
111
119
  export function validateCancellation(value, expected) {
112
- keys(value, RECORD_KEYS);
120
+ // Only a non-main target is recorded; the final canonical comparison binds it.
121
+ keys(value, [...RECORD_KEYS, ...optionalTargetFields(value ?? {})]);
113
122
  // Root {bun.lock?, package-lock.json, package.json} or exactly one directory's two npm files.
114
123
  keys(value.proposalHashes, hashCohort(expected.proposalHashes));
115
124
  keys(value.destination, ["branch", "expectedBranchHead", "prNumber"]);
@@ -179,7 +188,7 @@ export function assertRecordedOperator(run, permission, policy, record) {
179
188
  run.event === "workflow_dispatch" &&
180
189
  policy.allowedTriggers?.includes("workflow_dispatch") &&
181
190
  run.head_sha === record.parent &&
182
- run.head_branch === "main" &&
191
+ run.head_branch === targetBranch(record) &&
183
192
  run.path === policy.callerWorkflow.slice(policy.repository.length + 1) &&
184
193
  String(run.head_repository?.id) === policy.repositoryId &&
185
194
  run.triggering_actor?.type === "User" &&
@@ -237,6 +246,8 @@ export function cancellationRecord(
237
246
  expectedBranchHead: null,
238
247
  prNumber: null,
239
248
  },
249
+ // Only a non-main target is recorded; the cancellation certificate names that ref.
250
+ ...targetField(proposal),
240
251
  };
241
252
  }
242
253
 
@@ -5,7 +5,12 @@
5
5
  import { join } from "node:path";
6
6
  import { writeFileSync } from "node:fs";
7
7
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
8
- import { required, keys } from "./npm-update-contract.mjs";
8
+ import {
9
+ required,
10
+ keys,
11
+ DEFAULT_TARGET,
12
+ policyTarget,
13
+ } from "./npm-update-contract.mjs";
9
14
  import { proposalPolicy } from "./automation-provenance-contract.mjs";
10
15
  import { readBytes, readJson, writeJson } from "./npm-update-process.mjs";
11
16
  import { assertHostedGate } from "./npm-update-hosted-gate.mjs";
@@ -29,10 +34,16 @@ import {
29
34
  import { withStage } from "./npm-update-invariants.mjs";
30
35
 
31
36
  /** Native dispatch bytes are checked independently of reusable workflow input forwarding. */
32
- export function assertDispatchCancellation(event, run, request, authority) {
37
+ export function assertDispatchCancellation(
38
+ event,
39
+ run,
40
+ request,
41
+ authority,
42
+ target = DEFAULT_TARGET
43
+ ) {
33
44
  required(
34
45
  event &&
35
- ["main", "refs/heads/main"].includes(event.ref) &&
46
+ [target, `refs/heads/${target}`].includes(event.ref) &&
36
47
  event.repository?.full_name === authority.repository &&
37
48
  String(event.repository.id) === authority.repositoryId &&
38
49
  String(event.repository.owner?.id) === authority.ownerId &&
@@ -60,7 +71,7 @@ async function manualAuthority(api, proposal, config, request) {
60
71
  ),
61
72
  "native cancellation invocation is absent"
62
73
  );
63
- await api.main(proposal.parent);
74
+ await api.main(proposal.parent, proposal.target);
64
75
  const run = await api.request(
65
76
  `repos/${proposal.repository}/actions/runs/${invocation.runId}/attempts/${invocation.runAttempt}`
66
77
  );
@@ -81,7 +92,13 @@ async function manualAuthority(api, proposal, config, request) {
81
92
  readBytes(process.env.GITHUB_EVENT_PATH, 1_048_576, false)
82
93
  )
83
94
  );
84
- assertDispatchCancellation(event, run, request, api.policy);
95
+ assertDispatchCancellation(
96
+ event,
97
+ run,
98
+ request,
99
+ api.policy,
100
+ policyTarget(proposal)
101
+ );
85
102
  return { invocation, operatorId };
86
103
  }
87
104
 
@@ -240,7 +257,7 @@ export async function finalizeCancellation(context) {
240
257
  closed.title === issue.title,
241
258
  "cancellation closure readback differs"
242
259
  );
243
- await api.main(proposal.parent);
260
+ await api.main(proposal.parent, proposal.target);
244
261
  await cancellationDestinationAbsent(api, request.proposalKey);
245
262
  return {
246
263
  status: "cancelled",
@@ -17,6 +17,7 @@ import {
17
17
  optionalRuntimeFields,
18
18
  proposalFileNames,
19
19
  signedProposalFields,
20
+ targetField,
20
21
  } from "./automation-provenance-contract.mjs";
21
22
  export { proposalFileNames } from "./automation-provenance-contract.mjs";
22
23
  import { runtimeBinding } from "./npm-update-rails-runtime-contract.mjs";
@@ -34,8 +35,11 @@ export {
34
35
  VERSION,
35
36
  validatePolicy,
36
37
  selectPolicy,
38
+ policyTarget,
39
+ validBranchName,
40
+ DEFAULT_TARGET,
37
41
  } from "./npm-update-policy.mjs";
38
- import { VERSION } from "./npm-update-policy.mjs";
42
+ import { VERSION, policyTarget } from "./npm-update-policy.mjs";
39
43
  export const OBJECT = /^[a-f0-9]{40}$/;
40
44
 
41
45
  /** Host declarations are checked before npm or lifecycle execution. */
@@ -172,7 +176,7 @@ export function selectionKey(policy, updates) {
172
176
  return sha256(
173
177
  canonicalJson({
174
178
  repository: policy.repository,
175
- target: "main",
179
+ target: policyTarget(policy),
176
180
  ecosystem: "npm",
177
181
  directory: policy.directory,
178
182
  policySha256: sha256(canonicalJson(policy)),
@@ -197,6 +201,8 @@ export function proposalFrom(
197
201
  ...(bunLockSha256 === undefined ? {} : { bunLockSha256 }),
198
202
  ...runtimeBinding(policy),
199
203
  ...(policy.directory === "." ? {} : { directory: policy.directory }),
204
+ // Only a non-main target is signed into the binding and descriptor.
205
+ ...targetField(policy),
200
206
  };
201
207
  const names = proposalFileNames({ files, ...optional });
202
208
  for (const value of Object.values(files))
@@ -211,7 +217,7 @@ export function proposalFrom(
211
217
  const ordered = [...updates].sort((a, b) => a.name.localeCompare(b.name));
212
218
  const identity = {
213
219
  repository: policy.repository,
214
- target: policy.target,
220
+ target: policyTarget(policy),
215
221
  ecosystem: "npm",
216
222
  directory: policy.directory,
217
223
  parent,
@@ -5,13 +5,14 @@
5
5
  import { mkdirSync, realpathSync, existsSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
7
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
8
- import { required, OBJECT } from "./npm-update-contract.mjs";
8
+ import { required, OBJECT, policyTarget } from "./npm-update-contract.mjs";
9
9
  import { leafRoles } from "./npm-update-leaf-contract.mjs";
10
10
  import { qualifiedControllerGraph } from "./npm-update-helper.mjs";
11
11
  import { withPrivateRoot, writeJson } from "./npm-update-process.mjs";
12
12
  import { assertPinnedVerifier } from "./github-attestation-verifier.mjs";
13
13
  import { binaryDigest } from "./npm-update-isolation.mjs";
14
14
  import { createGhRequests } from "./npm-update-gh-requests.mjs";
15
+ import { targetField } from "./automation-provenance-contract.mjs";
15
16
  import { startControllerBroker } from "./npm-update-controller-broker.mjs";
16
17
  import { invokeControllerRecipe } from "./npm-update-broker-client.mjs";
17
18
  import { boundedSpawnSync } from "./bounded-spawn.mjs";
@@ -31,7 +32,7 @@ export function controllerDeadline(context, now = Date.now()) {
31
32
  export function controllerSubject(context, phase, pr, proofs = []) {
32
33
  const { config, policy, proposal, allocation } = context;
33
34
  const descriptor = context.descriptor ?? context.preview?.descriptor;
34
- leafRoles(config, policy.repository);
35
+ leafRoles(config, policy.repository, policyTarget(policy));
35
36
  required(
36
37
  proposal.repository === policy.repository &&
37
38
  Number.isSafeInteger(allocation.number) &&
@@ -70,6 +71,7 @@ export function controllerSubject(context, phase, pr, proofs = []) {
70
71
  maintainer: policy.maintainer,
71
72
  pr: pr === null ? null : { number: String(pr.number), url: pr.html_url },
72
73
  proofs,
74
+ ...targetField(proposal),
73
75
  };
74
76
  createGhRequests(subject);
75
77
  return subject;
@@ -15,7 +15,9 @@ import {
15
15
  officialArguments,
16
16
  PROPOSAL_PREDICATE,
17
17
  RECOVERY_PREDICATE,
18
+ targetBranch,
18
19
  } from "./github-attestation-verifier.mjs";
20
+ import { optionalTargetFields } from "./automation-provenance-contract.mjs";
19
21
  const BACKLINK_PHASE = "publication-backlink";
20
22
  const STAGE_PHASE = "stage-read";
21
23
  const PHASES = [
@@ -46,6 +48,8 @@ function checkedSubject(subject) {
46
48
  "maintainer",
47
49
  "pr",
48
50
  "proofs",
51
+ // Only a non-main target is named, so a main subject keeps its exact shape.
52
+ ...optionalTargetFields(subject ?? {}),
49
53
  ]);
50
54
  required(
51
55
  PHASES.includes(subject.phase) &&
@@ -131,7 +135,7 @@ function proofRequests(subject) {
131
135
  const repository = subject.repository;
132
136
  const endpoints = [
133
137
  `repos/${repository}`,
134
- `repos/${repository}/git/ref/heads/main`,
138
+ `repos/${repository}/git/ref/heads/${targetBranch(subject)}`,
135
139
  `repos/${repository}/actions/runs/${subject.origin.runId}/attempts/${subject.origin.runAttempt}`,
136
140
  `repos/${subject.tracker}/issues/comments/${subject.claim}`,
137
141
  ];
@@ -4,7 +4,12 @@
4
4
  /** Bounded trusted GitHub transport. @module npm-updater */
5
5
  import { canonicalJson } from "../lisa-automation-provenance.mjs";
6
6
  import { assertPinnedVerifier } from "./github-attestation-verifier.mjs";
7
- import { required } from "./npm-update-contract.mjs";
7
+ import {
8
+ required,
9
+ DEFAULT_TARGET,
10
+ validBranchName,
11
+ } from "./npm-update-contract.mjs";
12
+ import { operatorRefusal } from "./npm-update-invariants.mjs";
8
13
  import { runProcess } from "./npm-update-process.mjs";
9
14
  import { gitObjectId } from "./npm-update-object.mjs";
10
15
  import { proposalFileNames } from "./npm-update-contract.mjs";
@@ -36,6 +41,14 @@ function providerPurpose(repository, endpoint) {
36
41
  return "unclassified";
37
42
  }
38
43
 
44
+ /** A grammar-checked branch name is safe to name in the public diagnostic. */
45
+ export function missingTarget(target) {
46
+ return operatorRefusal(
47
+ "npm updater target branch does not exist",
48
+ `Target branch "${target}" does not exist on the remote; create it or change npmUpdater target. Nothing was published and no work item was created.`
49
+ );
50
+ }
51
+
39
52
  export class GitHub {
40
53
  constructor(policy, token, execute = runProcess) {
41
54
  assertPinnedVerifier(policy);
@@ -144,18 +157,27 @@ export class GitHub {
144
157
  issue.blockers = await this.list(`${path}/dependencies/blocked_by`);
145
158
  return issue;
146
159
  }
147
- async main(parent) {
160
+ /**
161
+ * The configured target's tip must still be the proposal parent. main keeps its
162
+ * exact historical requests and default-branch check; another target must be a
163
+ * valid branch that exists, because it need not be the repository default.
164
+ */
165
+ async main(parent, target = DEFAULT_TARGET) {
166
+ required(validBranchName(target), "invalid npm updater target branch");
148
167
  const repo = await this.request(`repos/${this.policy.repository}`);
149
168
  required(
150
169
  repo.full_name === this.policy.repository &&
151
- repo.default_branch === "main" &&
170
+ (target !== DEFAULT_TARGET || repo.default_branch === DEFAULT_TARGET) &&
152
171
  String(repo.id) === this.policy.repositoryId &&
153
172
  String(repo.owner.id) === this.policy.ownerId,
154
173
  "actual repository identity differs"
155
174
  );
156
- const main = await this.request(
157
- `repos/${this.policy.repository}/git/ref/heads/main`
158
- );
175
+ const endpoint = `repos/${this.policy.repository}/git/ref/heads/${target}`;
176
+ const main =
177
+ target === DEFAULT_TARGET
178
+ ? await this.request(endpoint)
179
+ : await this.maybe(endpoint);
180
+ if (main === null) throw missingTarget(target);
159
181
  required(main.object?.sha === parent, "actual main parent changed");
160
182
  return repo;
161
183
  }
@@ -4,7 +4,11 @@
4
4
  /** Supported disposable Actions Linux gates use original native tools; publisher authority stays in another job. */
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
- import { required, proposalFileNames } from "./npm-update-contract.mjs";
7
+ import {
8
+ required,
9
+ proposalFileNames,
10
+ policyTarget,
11
+ } from "./npm-update-contract.mjs";
8
12
  import { installInputs } from "./automation-provenance-contract.mjs";
9
13
  import { qualifiedBun, frozenBun } from "./npm-update-bun.mjs";
10
14
  import { runProcess } from "./npm-update-process.mjs";
@@ -45,7 +49,7 @@ export function assertHostedGate(
45
49
  env.RUNNER_ENVIRONMENT === "github-hosted" &&
46
50
  env.GITHUB_REPOSITORY === context.policy.repository &&
47
51
  env.GITHUB_SHA === context.proposal.parent &&
48
- env.GITHUB_REF === "refs/heads/main" &&
52
+ env.GITHUB_REF === `refs/heads/${policyTarget(context.proposal)}` &&
49
53
  context.config.automationProvenance.allowedTriggers.includes(
50
54
  env.GITHUB_EVENT_NAME
51
55
  ),
@@ -5,7 +5,7 @@
5
5
  import { mkdirSync, writeFileSync } from "node:fs";
6
6
  import { join, resolve } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
- import { required } from "./npm-update-contract.mjs";
8
+ import { required, policyTarget } from "./npm-update-contract.mjs";
9
9
  import { withStage } from "./npm-update-invariants.mjs";
10
10
  import { writeJson } from "./npm-update-process.mjs";
11
11
  import { controllerSubject } from "./npm-update-controller-factory.mjs";
@@ -120,7 +120,7 @@ function hostedEnvironment(context, root, bin, installed) {
120
120
  GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
121
121
  GITHUB_RUN_ATTEMPT: process.env.GITHUB_RUN_ATTEMPT,
122
122
  GITHUB_SHA: context.proposal.parent,
123
- GITHUB_REF: "refs/heads/main",
123
+ GITHUB_REF: `refs/heads/${policyTarget(context.proposal)}`,
124
124
  GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME,
125
125
  };
126
126
  }
@@ -319,6 +319,8 @@ export class UpdaterError extends Error {
319
319
  * A refusal the operator must act on carries one fixed plain-language sentence,
320
320
  * registered here rather than read from an error property, so no provider
321
321
  * payload or arbitrary exception text can ever reach the public diagnostic.
322
+ * Any value interpolated into the sentence must already be validated (for
323
+ * example a branch name checked by validBranchName).
322
324
  */
323
325
  export function operatorRefusal(reason, sentence) {
324
326
  const error = new UpdaterError(reason);