@ai-sdlc/orchestrator 0.9.0 → 0.10.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.
@@ -34,12 +34,22 @@
34
34
  /**
35
35
  * The currently-accepted predicate schema versions. CI rejects any envelope
36
36
  * whose `payload.schemaVersion` is not in this allowlist — this is the
37
- * forward-compatibility hatch (we add a new version here when we change the
38
- * predicate shape, and CI keeps accepting v1 until we explicitly remove it).
37
+ * forward-compatibility hatch.
38
+ *
39
+ * AISDLC-103 (Verifier Phase 3) narrowed this to `['v3']` only:
40
+ * - `v1` envelopes (pre-AISDLC-94, diffHash-only) are rejected.
41
+ * - `v2` was never landed as a distinct schemaVersion — the AISDLC-94
42
+ * `contentHash` and AISDLC-101 `contentHashV3` shipped under the v1
43
+ * schemaVersion as additive optional fields during the dual- and
44
+ * triple-hash soak windows.
45
+ * - `v3` envelopes carry `contentHashV3` as a required field and DO NOT
46
+ * carry `diffHash` or `contentHash` (the legacy hashes are forbidden;
47
+ * a v3 envelope smuggling either field is rejected by
48
+ * `validatePredicateShape`).
39
49
  *
40
50
  * Exported so the `verify-attestation` workflow can `import`/inline it.
41
51
  */
42
- export declare const ACCEPTED_SCHEMA_VERSIONS: readonly ["v1"];
52
+ export declare const ACCEPTED_SCHEMA_VERSIONS: readonly ["v3"];
43
53
  export type SchemaVersion = (typeof ACCEPTED_SCHEMA_VERSIONS)[number];
44
54
  /**
45
55
  * The DSSE PAE payload type for our predicate. DSSE spec mandates a payload
@@ -83,14 +93,103 @@ export interface AttestationPredicate {
83
93
  subject: {
84
94
  digest: SubjectDigest;
85
95
  };
86
- /** sha256 of `git diff origin/main...HEAD` at attestation time. */
87
- diffHash: string;
96
+ /**
97
+ * Per-file-delta content binding (AISDLC-101 — required as of AISDLC-103
98
+ * Phase 3). sha256 over a canonical line-per-file string of the form
99
+ * `<path>\t<fileDeltaHash>\n` (sorted ascending by path), where
100
+ * `fileDeltaHash[path] = sha256(<base_blob_sha> + ' -> ' +
101
+ * <head_blob_sha>)`. The base blob SHA comes from the merge-base of the
102
+ * PR's `<baseRef>` and `<headRef>`; the head blob SHA from the PR's
103
+ * `<headRef>`.
104
+ *
105
+ * Why this is the only content binding in v3:
106
+ * - `diffHash` (legacy v1, sha256 of literal `git diff` text) broke on
107
+ * every rebase because `@@` hunk headers shift even when the
108
+ * post-apply file content doesn't change.
109
+ * - `contentHash` (AISDLC-94, sha256 of `(path, head_blob_sha)` per
110
+ * file) was rebase-tolerant for the no-overlap case but broke in the
111
+ * AISDLC-93 / PR #102 sibling-overlap case (the rebased file's HEAD
112
+ * blob contained the sibling's contributions, so the head blob SHA
113
+ * changed even though OUR contribution was unchanged).
114
+ * - `contentHashV3` commits to the (base, head) blob-pair TRANSITION
115
+ * per file ("we moved file F from blob A to blob B"). Stable when
116
+ * paired with the producer-side pre-sign rebase from AISDLC-102 even
117
+ * in the sibling-overlap case, and a genuine content tampering still
118
+ * flips the head blob SHA → fileDeltaHash flips → reject (threat
119
+ * model preserved).
120
+ *
121
+ * Required for v3 envelopes. The dual-hash (v1 → AISDLC-94) and
122
+ * triple-hash (AISDLC-94 → AISDLC-101) windows kept this optional under
123
+ * schemaVersion `v1`; AISDLC-103 narrows the accepted-schema-versions
124
+ * allowlist to `['v3']` and makes `contentHashV3` mandatory in
125
+ * `validatePredicateShape`. Legacy envelopes carrying only `diffHash`
126
+ * and/or `contentHash` are rejected with a schemaVersion-allowlist reason.
127
+ */
128
+ contentHashV3: string;
129
+ /**
130
+ * Base-independent per-file head-blob binding (AISDLC-193.1). sha256
131
+ * over `JSON.stringify(sorted([{path, headBlobSha}]))` for every
132
+ * changed file in `<base>...<head>`, EXCLUDING the envelope file
133
+ * itself (`.ai-sdlc/attestations/<sha>.dsse.json` — see
134
+ * `isAttestationEnvelopePath` for the rationale).
135
+ *
136
+ * Why both v3 AND v4 ship side by side during the transition:
137
+ * - In-flight envelopes signed before AISDLC-193.1 carry only `v3`.
138
+ * Verifier accepts those via the existing v3 ancestor walk so the
139
+ * queue doesn't reject envelopes that were valid yesterday.
140
+ * - New envelopes carry BOTH so the verifier prefers v4 (skip the
141
+ * walk, base-independent) but can fall back to v3 if v4 doesn't
142
+ * match (= the rare case where head blobs DID change between
143
+ * signing and verification — e.g. amend-after-sign).
144
+ *
145
+ * After the transition window, `contentHashV3` will be deprecated
146
+ * and the verifier will require `contentHashV4`. For now both are
147
+ * populated by `buildPredicate` so any envelope this code emits is
148
+ * verifiable on both legs. The TypeScript type marks v4 as OPTIONAL
149
+ * because envelopes parsed from disk that pre-date AISDLC-193.1 will
150
+ * not carry the field; `validatePredicateShape` accepts the absence
151
+ * (= legacy v3 envelope) and the verifier falls back to the v3
152
+ * ancestor walk in that case.
153
+ */
154
+ contentHashV4?: string;
88
155
  /** sha256 of `.ai-sdlc/review-policy.md` at attestation time. */
89
156
  policyHash: string;
90
157
  /** Reviewer entries — typically 3 (code/test/security). */
91
158
  reviewers: ReviewerEntry[];
92
159
  /** Plugin version from `ai-sdlc-plugin/plugin.json`. */
93
160
  pluginVersion: string;
161
+ /**
162
+ * Pipeline-cli version from `pipeline-cli/package.json` (RFC-0012 Phase 6 /
163
+ * AISDLC-100.6). Forensic / audit purpose only — the verifier logs this
164
+ * but does NOT enforce a specific version. Equivalent to AISDLC-87/AISDLC-94's
165
+ * `pluginVersion` field but for the `@ai-sdlc/pipeline-cli` workspace package.
166
+ *
167
+ * Optional in v1 for backward compatibility — envelopes signed BEFORE
168
+ * pipeline-cli existed (and BEFORE this field landed) carry no
169
+ * `pipelineVersion` and the verifier still accepts them, logging
170
+ * `<missing> (legacy envelope)` instead.
171
+ */
172
+ pipelineVersion?: string;
173
+ /**
174
+ * Harness that produced the developer + reviewer verdicts (AISDLC-202.3).
175
+ * Populated by the calling adapter (e.g. `CodexHarnessAdapter` sets
176
+ * `{ name: 'codex', version: '0.128.0' }` when signing a Codex-run task).
177
+ * Claude Code paths omit this field or set `{ name: 'claude-code' }`.
178
+ *
179
+ * Optional for backward compatibility: envelopes produced before
180
+ * AISDLC-202.3 carry no `harness` field; the verifier accepts them and
181
+ * logs `<unknown>` when the field is absent. Downstream trust decisions
182
+ * (e.g. "require Codex review for Claude-developed PRs") can filter on
183
+ * `harness.name` without failing envelopes that predate this field.
184
+ *
185
+ * `name` is constrained to `SHORT_ID` (letters, digits, dot, dash,
186
+ * underscore) to prevent CR/LF injection into GITHUB_OUTPUT. `version`
187
+ * is constrained to `SEMVER` when present.
188
+ */
189
+ harness?: {
190
+ name: string;
191
+ version?: string;
192
+ };
94
193
  /** Iteration count — how many dev rounds the work went through. */
95
194
  iterationCount: number;
96
195
  /**
@@ -148,13 +247,18 @@ export type VerifyResult = {
148
247
  reason: string;
149
248
  };
150
249
  /**
151
- * Validate a parsed predicate against the v1 schema regex patterns.
250
+ * Validate a parsed predicate against the v3 schema regex patterns.
152
251
  *
153
252
  * Returns `null` when the predicate is shape-valid; otherwise returns
154
253
  * a static failure reason that does NOT embed any user-controlled
155
254
  * value (just the field path). This is the load-bearing property:
156
255
  * the malicious value never reaches the `reason` string, so it can't
157
256
  * propagate to GITHUB_OUTPUT or commit-status descriptions.
257
+ *
258
+ * AISDLC-103 (Verifier Phase 3): `contentHashV3` is now required, and the
259
+ * legacy `diffHash` / `contentHash` fields are FORBIDDEN — a predicate
260
+ * carrying either is treated as a v1/v2 envelope smuggling itself into the
261
+ * v3 window and rejected with a static reason.
158
262
  */
159
263
  export declare function validatePredicateShape(parsed: unknown): string | null;
160
264
  /**
@@ -165,10 +269,181 @@ export declare function validatePredicateShape(parsed: unknown): string | null;
165
269
  * Frozen to discourage callers from mutating it.
166
270
  */
167
271
  export declare const REQUIRED_REVIEWER_AGENT_IDS: readonly string[];
272
+ /**
273
+ * Name-equivalence map for the reviewer-set completeness check (AISDLC-252).
274
+ *
275
+ * A "role" is satisfied when any of the listed agentIds is present in the
276
+ * envelope's reviewer set. This lets codex-harness variants (`code-reviewer-codex`,
277
+ * `test-reviewer-codex`) satisfy the same role as their Claude counterparts,
278
+ * enabling the bidirectional cross-harness review goal without requiring a
279
+ * redundant Claude review on Codex-reviewed PRs.
280
+ *
281
+ * Security stays Claude-only: `security-reviewer` has no codex variant per
282
+ * `feedback_subagent_model_selection.md` (Claude Opus for security reasoning
283
+ * depth is not yet validated for Codex o4-mini).
284
+ *
285
+ * The map is keyed by role name (= the canonical agentId), each value is the
286
+ * set of ALL agentIds that satisfy the role (including the canonical one).
287
+ *
288
+ * Frozen to discourage callers from mutating it.
289
+ */
290
+ export declare const REVIEWER_ROLE_EQUIVALENCES: Readonly<Record<string, readonly string[]>>;
291
+ /**
292
+ * When the implementer ran in Codex (`predicate.harness.name === 'codex'`),
293
+ * these reviewer roles MUST be satisfied by a reviewer whose `harness` field
294
+ * differs from `codex`. Per RFC-0010 §13.10 `requiresIndependentHarnessFrom`:
295
+ * code and test reviewers must come from a different harness than the
296
+ * implementer to preserve cross-harness independence.
297
+ *
298
+ * Security is excluded — it is always Claude-only regardless.
299
+ *
300
+ * Frozen to discourage callers from mutating it.
301
+ */
302
+ export declare const INDEPENDENCE_REQUIRED_ROLES: readonly string[];
303
+ /**
304
+ * One entry in the changed-file set used to compute `contentHash`
305
+ * (AISDLC-94). `path` is the repo-relative forward-slash path; `blobSha`
306
+ * is the git blob SHA-1 (40 lowercase hex chars) of the file's CURRENT
307
+ * post-apply content at the attested commit.
308
+ *
309
+ * For deleted files, set `blobSha` to the empty string — the canonical
310
+ * line still includes the path so a delete-vs-keep difference between
311
+ * two PRs produces different hashes.
312
+ */
313
+ export interface ChangedFileEntry {
314
+ path: string;
315
+ blobSha: string;
316
+ }
317
+ /**
318
+ * One entry in the per-file-delta set used to compute `contentHashV3`
319
+ * (AISDLC-101). `path` is the repo-relative forward-slash path;
320
+ * `baseBlobSha` is the git blob SHA-1 of the file at the merge-base of
321
+ * `<baseRef>` and `<headRef>` (= the file's content BEFORE the PR's
322
+ * commits replayed); `headBlobSha` is the git blob SHA-1 of the file at
323
+ * `<headRef>` (= AFTER the PR's commits).
324
+ *
325
+ * For files that don't exist at one of the endpoints (newly added or
326
+ * deleted), the corresponding `*BlobSha` is the empty string. The
327
+ * canonical line still includes the path so:
328
+ * - "added file" (`base=''`, `head=<sha>`) → distinct from "kept file"
329
+ * (`base=<old>`, `head=<new>`)
330
+ * - "deleted file" (`base=<old>`, `head=''`) → distinct from "added file"
331
+ */
332
+ export interface ChangedFileDeltaEntry {
333
+ path: string;
334
+ baseBlobSha: string;
335
+ headBlobSha: string;
336
+ }
337
+ /**
338
+ * Regex matching the envelope self-exclusion path pattern
339
+ * `.ai-sdlc/attestations/<sha>.dsse.json`. Used to filter out the
340
+ * envelope file itself from the file collector for AISDLC-193.1
341
+ * `contentHashV4` and AISDLC-101 `contentHashV3` purposes.
342
+ *
343
+ * The chore-commit pattern signs the predicate at the dev-commit (HEAD
344
+ * BEFORE the envelope file exists), then the chore commit on top adds
345
+ * the envelope file at `.ai-sdlc/attestations/<sha>.dsse.json`. If the
346
+ * collector includes the envelope file in the hashed file set, the
347
+ * verifier (which runs against PR HEAD = dev-commit + chore commit)
348
+ * will see an EXTRA entry for the envelope that the signer never saw
349
+ * → mismatch even on direct PR HEAD without any rebase.
350
+ *
351
+ * The exclusion applies to the file COLLECTOR for HASHING purposes
352
+ * only. The verifier's chore-commit allowlist (`scripts/verify-attestation.mjs`
353
+ * `CHORE_COMMIT_PATH_ALLOWLIST`) STILL allows the envelope file in the
354
+ * chore commit's diff — that's a separate concern from "what is in the
355
+ * file set we hash."
356
+ *
357
+ * Anchored with `^...$` against the forward-slash-normalized path so
358
+ * an attacker cannot bypass with `./.ai-sdlc/attestations/x.dsse.json`
359
+ * or `foo/.ai-sdlc/attestations/x.dsse.json`. Note that git's
360
+ * `--name-only` always emits paths relative to the repo root with
361
+ * forward slashes, so the match is straightforward in practice.
362
+ */
363
+ export declare const ATTESTATION_ENVELOPE_PATH_PATTERN: RegExp;
364
+ /**
365
+ * Predicate to determine whether a file path identifies an attestation
366
+ * envelope and should therefore be excluded from `contentHashV3` /
367
+ * `contentHashV4` file enumeration. Defensive about backslash
368
+ * normalization (Windows callers).
369
+ */
370
+ export declare function isAttestationEnvelopePath(path: string): boolean;
371
+ /**
372
+ * The "shared churn" exclude list for `contentHashV4` (AISDLC-258).
373
+ *
374
+ * Files in this list are EXCLUDED from the v4 file collector in BOTH the
375
+ * signer (`collectChangedFileDeltaEntries`) and the verifier
376
+ * (`computeHeadContentHashV4` in `scripts/verify-attestation.mjs`). When
377
+ * a file appears in this list, changes to it after signing (e.g. from a
378
+ * merge-queue rebase that regenerated `pnpm-lock.yaml`) do NOT cause
379
+ * `contentHashV4` to mismatch, so the operator is never asked to re-sign
380
+ * just because a shared tooling file was regenerated automatically.
381
+ *
382
+ * **Security trade-off (operator-approved, 2026-05-10):** An attacker
383
+ * COULD slip malicious changes through these files undetected (the
384
+ * attestation would still pass even if the ignore-listed file was
385
+ * tampered). The operator accepted this risk because:
386
+ * - None of these files contain reviewable hand-written code.
387
+ * - `pnpm-lock.yaml` is generated from `package.json` (which IS hashed).
388
+ * - `CHANGELOG.md` variants are auto-generated by release-please from
389
+ * commit history (which IS hashed via the commit-level binding).
390
+ * - `generated-schemas.ts` is generated from spec schemas (reviewed
391
+ * separately in the spec/ PR that changed them).
392
+ *
393
+ * **DO NOT add to this list:** `package.json` (real dep changes are
394
+ * reviewable), source files, test files, configs, RFCs, or anything a
395
+ * human writes by hand. The list is intentionally narrow.
396
+ *
397
+ * Paths are exact matches against the forward-slash-normalized repo-relative
398
+ * path emitted by `git diff --name-only`. Patterns (globs/regex) are NOT
399
+ * supported to keep the list auditable — every entry must be exact.
400
+ *
401
+ * Exported so `scripts/verify-attestation.mjs` can import it from the
402
+ * orchestrator barrel and apply the same exclusions on the verifier side.
403
+ */
404
+ export declare const CONTENTHASHV4_IGNORE_FILES: readonly string[];
405
+ /**
406
+ * Predicate to determine whether a file path should be excluded from the
407
+ * `contentHashV4` computation because it is a "shared churn" file (see
408
+ * `CONTENTHASHV4_IGNORE_FILES`). Defensive about backslash normalization.
409
+ *
410
+ * Note: this predicate is intentionally separate from
411
+ * `isAttestationEnvelopePath` because the two exclusions serve different
412
+ * purposes and may diverge independently. Merge them only if the list
413
+ * becomes large enough to warrant a single unified predicate.
414
+ */
415
+ export declare function isIgnoredForContentHash(path: string): boolean;
416
+ /**
417
+ * One entry in the base-independent per-file head-blob set used to
418
+ * compute `contentHashV4` (AISDLC-193.1). Identical in shape to
419
+ * `ChangedFileEntry` (AISDLC-94's `contentHash`) but with `headBlobSha`
420
+ * naming for clarity — v4 binds reviewers' approval to "I approved
421
+ * THESE files at THESE specific head blobs," nothing about the base.
422
+ *
423
+ * Why v4 was added on top of v3:
424
+ * - v3 binds the (base_blob, head_blob) PAIR per file. When the
425
+ * merge queue rebases the PR onto a sibling-merged main, the base
426
+ * blob SHA for shared files changes (the merge-base shifts forward
427
+ * to include the sibling's contributions). The fileDeltaHash flips
428
+ * even though the post-apply file content the reviewers approved
429
+ * hasn't moved → contentHashV3 invalidates → required check fails
430
+ * → queue rejects the PR. Net: every queued code-touching PR
431
+ * deadlocks at the gate.
432
+ * - v4 binds only `{path, headBlobSha}`. The head blob SHA captures
433
+ * "this is the EXACT file content the reviewers signed off on."
434
+ * Whatever the rebase does to the base ref, as long as the head
435
+ * blob SHAs are unchanged, the v4 hash matches.
436
+ * - Threat model preserved: any genuine post-sign content tampering
437
+ * (someone amends the PR to add unreviewed code) flips the head
438
+ * blob SHA → v4 hash flips → verifier rejects.
439
+ */
440
+ export interface ChangedFileHeadEntry {
441
+ path: string;
442
+ headBlobSha: string;
443
+ }
168
444
  /** Inputs for building an attestation predicate. */
169
445
  export interface BuildPredicateInputs {
170
446
  commitSha: string;
171
- diff: string | Buffer;
172
447
  policy: string | Buffer;
173
448
  reviewers: Array<{
174
449
  agentId: string;
@@ -178,10 +453,40 @@ export interface BuildPredicateInputs {
178
453
  findings: ReviewerEntry['findings'];
179
454
  }>;
180
455
  pluginVersion: string;
456
+ /**
457
+ * Pipeline-cli version from `pipeline-cli/package.json` (AISDLC-100.6).
458
+ * Optional — when omitted (e.g. legacy callers, environments where
459
+ * pipeline-cli isn't installed), the predicate's `pipelineVersion` field
460
+ * is also omitted. Forensic / audit purpose only — the verifier logs
461
+ * this but does not enforce.
462
+ */
463
+ pipelineVersion?: string;
464
+ /**
465
+ * Harness that produced the developer + reviewer verdicts (AISDLC-202.3).
466
+ * Optional — when omitted, the predicate carries no `harness` field
467
+ * (back-compat with pre-202.3 envelopes). When provided, the adapter
468
+ * populates both `name` (required, SHORT_ID) and optionally `version`
469
+ * (SEMVER). Example: `{ name: 'codex', version: '0.128.0' }`.
470
+ *
471
+ * The signing script (`sign-attestation.mjs`) passes this via
472
+ * `--harness-name` + `--harness-version` CLI flags.
473
+ */
474
+ harness?: {
475
+ name: string;
476
+ version?: string;
477
+ };
181
478
  iterationCount: number;
182
479
  harnessNote: string;
183
480
  /** Override `signedAt` for deterministic tests. */
184
481
  signedAt?: string;
482
+ /**
483
+ * Per-file-delta set for `contentHashV3` (AISDLC-101 / AISDLC-103).
484
+ * REQUIRED for v3 envelopes — captures the (base_blob_sha →
485
+ * head_blob_sha) transition per file. Pass `[]` for no-op PRs (the
486
+ * resulting `contentHashV3` is `sha256('')`, which is well-defined and
487
+ * still verifiable).
488
+ */
489
+ changedFileDeltas: ChangedFileDeltaEntry[];
185
490
  }
186
491
  /**
187
492
  * Compute a sha256 hex digest. Single source of truth for the hashing
@@ -190,10 +495,180 @@ export interface BuildPredicateInputs {
190
495
  export declare function sha256Hex(input: string | Buffer): string;
191
496
  /** Compute a sha1 hex digest (used for git commit SHAs in the subject). */
192
497
  export declare function sha1Hex(input: string | Buffer): string;
498
+ /**
499
+ * Compute the rebase-tolerant `contentHash` (AISDLC-94) over a changed-file
500
+ * set. The canonical encoding is one line per entry, sorted ascending by
501
+ * path, with `<path>\t<blobSha>\n` per line. The whole string is sha256-ed.
502
+ *
503
+ * Why this beats `diffHash`:
504
+ * - Rebasing PR-X onto a new `main` that already touched the same files
505
+ * does NOT change the post-apply blob SHAs (assuming no conflict),
506
+ * so `contentHash` stays stable across the rebase.
507
+ * - A conflict resolution that picks different content WILL change the
508
+ * blob SHA → `contentHash` changes → attestation correctly invalidated.
509
+ * - Force-pushing a no-op edit (e.g. `git commit --amend --no-edit`) keeps
510
+ * blob SHAs identical → `contentHash` stays stable.
511
+ *
512
+ * The deduplication step makes the function idempotent if a caller
513
+ * accidentally passes the same path twice (last-write-wins per path).
514
+ *
515
+ * Pure function. The caller (sign-attestation script) is responsible for
516
+ * gathering the file set (via `git diff --name-only` + `git ls-tree`).
517
+ */
518
+ export declare function computeContentHash(entries: ChangedFileEntry[]): string;
519
+ /**
520
+ * Optional injection points for `collectChangedFileEntries`. Defaults are
521
+ * production behaviour; tests pass synthetic `runGit` to avoid spawning git.
522
+ */
523
+ export interface CollectChangedFileEntriesOptions {
524
+ /**
525
+ * Run `git <args>` in `cwd` and return stdout (utf-8). Defaults to
526
+ * `execFileSync` with the git-context env scrubbed (see `cleanGitEnv`).
527
+ * Tests pass a stub so they don't depend on a real worktree.
528
+ */
529
+ runGit?: (args: string[], cwd: string) => string;
530
+ }
531
+ /**
532
+ * Collect the changed-file set used to compute `contentHash` (AISDLC-94).
533
+ *
534
+ * Returns one `{ path, blobSha }` entry per file in
535
+ * `git diff --name-only <baseRef>...<headRef>` with the blob SHA from
536
+ * `git ls-tree -r <headRef> -- <path>`. Deleted files get an empty
537
+ * `blobSha` (the path still appears so the canonical encoding distinguishes
538
+ * "deleted" from "kept").
539
+ *
540
+ * `--no-renames` so a rename shows up as add+delete (= two entries) — that
541
+ * way a rebase that resolved a conflict by renaming differently produces a
542
+ * different hash. `-c core.quotepath=false` mirrors the verifier's git
543
+ * helper so unicode paths come back as raw UTF-8.
544
+ *
545
+ * Path entries containing `\t` or `\n` are rejected to keep the canonical
546
+ * encoding injective (mirrors the rejection in `computeContentHash`). Such
547
+ * paths are exceedingly rare in practice — git's default config disallows
548
+ * `\n` in tracked filenames on most platforms — but we defend in depth so
549
+ * malicious or pathological inputs can't smuggle entries past the binding.
550
+ *
551
+ * Extracted from the previously-duplicated helpers in
552
+ * `ai-sdlc-plugin/scripts/sign-attestation.mjs` so a single source of truth
553
+ * applies the same parsing + validation at every signing site.
554
+ */
555
+ export declare function collectChangedFileEntries(baseRef: string, headRef: string, repoRoot: string, options?: CollectChangedFileEntriesOptions): ChangedFileEntry[];
556
+ /**
557
+ * Compute the per-file-delta `contentHashV3` (AISDLC-101) over a set of
558
+ * `{path, baseBlobSha, headBlobSha}` triples. The canonical encoding is
559
+ * one line per entry, sorted ascending by path, with
560
+ * `<path>\t<fileDeltaHash>\n` per line, where
561
+ * `fileDeltaHash = sha256(baseBlobSha + ' -> ' + headBlobSha)`. The
562
+ * outer `contentHashV3` is the sha256 of the concatenated lines.
563
+ *
564
+ * Why per-file delta hashing — and what it adds vs. AISDLC-94's `contentHash`:
565
+ * - `contentHash` (AISDLC-94) hashes the post-apply blob SHA per file.
566
+ * If a sibling PR landed between OUR sign + OUR merge AND modified
567
+ * the SAME file, the rebased file's HEAD blob SHA contains both the
568
+ * sibling contribution AND ours → contentHash diverges (false reject).
569
+ * - `contentHashV3` (AISDLC-101) hashes the (base, head) blob-pair
570
+ * transition per file. Provides a stricter "we moved file F from blob
571
+ * A to blob B" binding than just "we ended up at blob B". Any genuine
572
+ * content change still flips the head blob SHA → fileDeltaHash flips
573
+ * → contentHashV3 flips → reject (threat model preserved).
574
+ *
575
+ * This is the SECOND line of defense in the 3-layer rebase-tolerance
576
+ * plan (AISDLC-94 = Phase 1 verifier-side dual-hash, AISDLC-102 = Phase 1.5
577
+ * producer-side pre-sign rebase, AISDLC-101 = Phase 2 per-file delta).
578
+ * The verifier OR's all three legs during the triple-hash window.
579
+ *
580
+ * Path-delimiter rejection (\t / \n) mirrors `computeContentHash` so the
581
+ * canonical encoding stays injective regardless of caller input.
582
+ *
583
+ * Pure function. Idempotent against double-enumeration via dedup-by-path
584
+ * (last-write-wins per path), same as `computeContentHash`.
585
+ */
586
+ export declare function computeContentHashV3(entries: ChangedFileDeltaEntry[]): string;
587
+ /**
588
+ * Compute the BASE-INDEPENDENT per-file head-blob `contentHashV4`
589
+ * (AISDLC-193.1) over a set of `{path, headBlobSha}` pairs. The
590
+ * canonical encoding is `JSON.stringify(sorted-by-path-array-of-{path,
591
+ * headBlobSha}-objects)`, hashed with sha256.
592
+ *
593
+ * Why JSON-of-sorted-array (and not the v3 `<path>\t<fileDeltaHash>\n`
594
+ * canonical) for v4:
595
+ * - JSON's quoting rules already cover delimiter injection
596
+ * (a malicious path containing tab/newline can't smuggle through
597
+ * because they round-trip as escape sequences). We still reject
598
+ * such paths defensively so the canonical stays injective and
599
+ * the on-the-wire representation is what readers expect.
600
+ * - JSON is unambiguous about field ordering (stringify of a
601
+ * `{path, headBlobSha}` literal always emits `path` first,
602
+ * `headBlobSha` second — V8's object-key ordering is insertion
603
+ * order, and we insert in this order in the .map() below).
604
+ * - Easier to extend: future hash versions can add fields
605
+ * (`mode`, `executable bit`, etc) to the entry objects without
606
+ * breaking the canonical encoding scheme.
607
+ *
608
+ * Why this is BASE-INDEPENDENT (= the whole point):
609
+ * - v3's per-file delta hashes the (base_blob, head_blob) pair.
610
+ * When the merge queue rebases the PR onto current main (which
611
+ * advanced past the merge-base the producer signed against), the
612
+ * base blob SHA for any shared file changes → v3 invalidates.
613
+ * - v4 hashes only `{path, headBlobSha}`. Whatever the rebase does
614
+ * to the base ref or the merge-base, as long as the head blob SHA
615
+ * (= the actual reviewed file content) is unchanged, v4 matches.
616
+ * - The reviewer never approved "base_blob X → head_blob Y"; they
617
+ * approved "the file contents at head_blob Y." v4 binds to that
618
+ * directly.
619
+ *
620
+ * Threat model preserved:
621
+ * - Genuine post-sign content tampering (someone amends the PR to
622
+ * add unreviewed code) flips the head blob SHA → v4 hash flips →
623
+ * verifier rejects. Same threat-model surface as v3.
624
+ * - The signing key still has to be a trusted reviewer's; v4
625
+ * doesn't change the signature/key flow, just what the predicate
626
+ * binds to.
627
+ *
628
+ * Pure function. Idempotent against double-enumeration via dedup-by-path
629
+ * (last-write-wins per path), same as `computeContentHash` and
630
+ * `computeContentHashV3`.
631
+ */
632
+ export declare function computeContentHashV4(entries: ChangedFileHeadEntry[]): string;
633
+ /**
634
+ * Collect the per-file-delta set used to compute `contentHashV3` (AISDLC-101).
635
+ *
636
+ * Returns one `{ path, baseBlobSha, headBlobSha }` entry per file in
637
+ * `git diff --name-only <baseRef>...<headRef>`. The base blob SHA is read
638
+ * from the *merge-base* of `<baseRef>` and `<headRef>` (which the `...`
639
+ * 3-dot diff range already targets — `A...B` diffs against
640
+ * `merge-base(A,B)`); the head blob SHA from `<headRef>`. Files newly
641
+ * added in the PR have empty `baseBlobSha`; deleted files have empty
642
+ * `headBlobSha`.
643
+ *
644
+ * Mirrors `collectChangedFileEntries`'s flag set (`--no-renames`,
645
+ * `core.quotepath=false`) for consistency with the other binding's file
646
+ * enumeration.
647
+ *
648
+ * Extracted so a single source of truth handles the two ls-tree lookups
649
+ * (one per endpoint) at every signing site (`sign-attestation.mjs`).
650
+ */
651
+ export declare function collectChangedFileDeltaEntries(baseRef: string, headRef: string, repoRoot: string, options?: CollectChangedFileEntriesOptions): ChangedFileDeltaEntry[];
652
+ /**
653
+ * Project a v3 `ChangedFileDeltaEntry` set down to the v4
654
+ * `ChangedFileHeadEntry` shape (`{path, headBlobSha}`). Convenience
655
+ * for callers that already collected v3 deltas and want to dual-emit
656
+ * both hashes from the same file enumeration. Pure function.
657
+ *
658
+ * The envelope self-exclusion is enforced upstream by
659
+ * `collectChangedFileDeltaEntries`, so this projection is a simple
660
+ * field-pick — no path filtering needed here.
661
+ */
662
+ export declare function projectDeltaEntriesToHeadEntries(deltas: ChangedFileDeltaEntry[]): ChangedFileHeadEntry[];
193
663
  /**
194
664
  * Build the predicate payload from raw inputs. Pure function — no I/O,
195
665
  * no signing. The caller (`/ai-sdlc execute` Step 10) reads files and git
196
666
  * output, then hands them here.
667
+ *
668
+ * AISDLC-103 (Verifier Phase 3): always emits a v3 envelope. The caller
669
+ * MUST provide `changedFileDeltas` (use `[]` for no-op PRs); the legacy
670
+ * `diff` + `changedFiles` inputs were dropped along with the legacy
671
+ * `diffHash` + `contentHash` fields.
197
672
  */
198
673
  export declare function buildPredicate(inputs: BuildPredicateInputs): AttestationPredicate;
199
674
  /**
@@ -236,8 +711,9 @@ export interface VerifyOptions {
236
711
  */
237
712
  trustedReviewers: TrustedReviewer[];
238
713
  /**
239
- * What the predicate's `subject.digest.sha1`, `diffHash`, `policyHash`,
240
- * and `reviewers[].agentFileHash` MUST equal. Mismatch = invalid.
714
+ * What the predicate's `subject.digest.sha1`, `contentHashV3`,
715
+ * `policyHash`, and `reviewers[].agentFileHash` MUST equal. Mismatch =
716
+ * invalid.
241
717
  *
242
718
  * `expectedAgentFileHashes` is a map from agentId to its sha256 — we
243
719
  * tolerate the predicate listing fewer or more reviewers than the map,
@@ -245,7 +721,23 @@ export interface VerifyOptions {
245
721
  */
246
722
  expected: {
247
723
  commitSha: string;
248
- diffHash: string;
724
+ contentHashV3: string;
725
+ /**
726
+ * AISDLC-193.1 base-independent per-file head-blob binding.
727
+ * Optional — callers that want v4-prefer behavior pass it; callers
728
+ * that only have v3 (legacy) leave it undefined.
729
+ *
730
+ * When BOTH this AND the envelope's `contentHashV4` are present,
731
+ * the verifier prefers v4 (base-independent → survives queue
732
+ * rebases). When v4 matches, v3 is NOT consulted (this is the
733
+ * whole point — v3 will mismatch on a queue rebase even though
734
+ * the reviewed content is unchanged).
735
+ *
736
+ * When the envelope is legacy v3-only (no `contentHashV4`), the
737
+ * verifier falls back to the v3 check unconditionally regardless
738
+ * of whether `expected.contentHashV4` is supplied.
739
+ */
740
+ contentHashV4?: string;
249
741
  policyHash: string;
250
742
  expectedAgentFileHashes: Record<string, string>;
251
743
  };