@warpgogol/forge 9.7.0 → 10.0.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.
- package/AGENTS.md +50 -27
- package/CHANGELOG.md +52 -0
- package/bin/cli.js +0 -0
- package/dist/os/adr/handlers/archive.d.ts.map +1 -1
- package/dist/os/adr/handlers/archive.js +3 -7
- package/dist/os/adr/handlers/archive.js.map +1 -1
- package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
- package/dist/os/adr/handlers/list-create.js +8 -6
- package/dist/os/adr/handlers/list-create.js.map +1 -1
- package/dist/os/audit/handlers/archive.d.ts.map +1 -1
- package/dist/os/audit/handlers/archive.js +3 -7
- package/dist/os/audit/handlers/archive.js.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
- package/dist/os/core/archive-regen.d.ts +1 -0
- package/dist/os/core/archive-regen.d.ts.map +1 -1
- package/dist/os/core/archive-regen.js +31 -6
- package/dist/os/core/archive-regen.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +6 -69
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +2 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
- package/dist/os/core/handlers/determinism-check.js +2 -3
- package/dist/os/core/handlers/determinism-check.js.map +1 -1
- package/dist/os/core/handlers/pinned-check.d.ts +13 -0
- package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-check.js +25 -0
- package/dist/os/core/handlers/pinned-check.js.map +1 -1
- package/dist/os/core/handlers/pinned-types.d.ts +7 -0
- package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.js +24 -1
- package/dist/os/core/handlers/pinned-validate.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +2 -4
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/digest.d.ts +73 -1
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +344 -92
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/evidence-lock.d.ts +36 -0
- package/dist/os/flow/evidence-lock.d.ts.map +1 -0
- package/dist/os/flow/evidence-lock.js +156 -0
- package/dist/os/flow/evidence-lock.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +36 -14
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/git.d.ts +50 -3
- package/dist/os/flow/git.d.ts.map +1 -1
- package/dist/os/flow/git.js +144 -12
- package/dist/os/flow/git.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +3 -5
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.js +1 -1
- package/dist/os/flow/handlers/flow-peers.js.map +1 -1
- package/dist/os/flow/handlers/flow-push.d.ts +81 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-push.js +642 -138
- package/dist/os/flow/handlers/flow-push.js.map +1 -1
- package/dist/os/flow/locks.d.ts +8 -0
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +6 -3
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
- package/dist/os/flow/open-missions.d.ts.map +1 -0
- package/dist/os/flow/open-missions.js +37 -0
- package/dist/os/flow/open-missions.js.map +1 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +5 -3
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +9 -5
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +2 -2
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/friction/friction.module.d.ts.map +1 -1
- package/dist/os/friction/friction.module.js +30 -5
- package/dist/os/friction/friction.module.js.map +1 -1
- package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-add.js +10 -17
- package/dist/os/friction/handlers/friction-add.js.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.js +188 -2
- package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
- package/dist/os/friction/store.d.ts +4 -0
- package/dist/os/friction/store.d.ts.map +1 -1
- package/dist/os/friction/store.js +20 -0
- package/dist/os/friction/store.js.map +1 -1
- package/dist/os/friction/types.d.ts +12 -0
- package/dist/os/friction/types.d.ts.map +1 -1
- package/dist/os/friction/types.js +8 -0
- package/dist/os/friction/types.js.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
- package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
- package/dist/os/plan/handlers/archive.d.ts.map +1 -1
- package/dist/os/plan/handlers/archive.js +3 -7
- package/dist/os/plan/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
- package/dist/os/rfc/handlers/archive.js +3 -7
- package/dist/os/rfc/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +15 -7
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/session/handlers/archive.d.ts.map +1 -1
- package/dist/os/session/handlers/archive.js +3 -7
- package/dist/os/session/handlers/archive.js.map +1 -1
- package/dist/os/system/handlers/system-product-register.d.ts +24 -0
- package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
- package/dist/os/system/handlers/system-product-register.js +322 -0
- package/dist/os/system/handlers/system-product-register.js.map +1 -0
- package/dist/os/system/handlers/system-products-status.d.ts +23 -0
- package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
- package/dist/os/system/handlers/system-products-status.js +235 -0
- package/dist/os/system/handlers/system-products-status.js.map +1 -0
- package/dist/os/system/schemas.d.ts +13 -0
- package/dist/os/system/schemas.d.ts.map +1 -1
- package/dist/os/system/schemas.js +15 -0
- package/dist/os/system/schemas.js.map +1 -1
- package/dist/os/system/system.module.d.ts.map +1 -1
- package/dist/os/system/system.module.js +113 -3
- package/dist/os/system/system.module.js.map +1 -1
- package/dist/src/command-modules.d.ts.map +1 -1
- package/dist/src/command-modules.js +0 -2
- package/dist/src/command-modules.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +2 -0
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +11 -10
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +27 -2
- package/dist/src/onboarding/create.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts +0 -5
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +6 -79
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
- package/dist/src/onboarding/npm-token-check.js +2 -2
- package/dist/src/onboarding/npm-token-check.js.map +1 -1
- package/dist/src/profiles/stack-profile.js +2 -2
- package/dist/src/types.js +2 -2
- package/dist/src/utils/hash.d.ts +1 -0
- package/dist/src/utils/hash.d.ts.map +1 -1
- package/dist/src/utils/hash.js +4 -0
- package/dist/src/utils/hash.js.map +1 -1
- package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
- package/dist/src/utils/lockfile.d.ts.map +1 -0
- package/dist/src/utils/lockfile.js +70 -0
- package/dist/src/utils/lockfile.js.map +1 -0
- package/dist/src/utils/verifier-git.d.ts +27 -1
- package/dist/src/utils/verifier-git.d.ts.map +1 -1
- package/dist/src/utils/verifier-git.js +36 -6
- package/dist/src/utils/verifier-git.js.map +1 -1
- package/docs/reference/system-hub.md +104 -0
- package/os/adr/handlers/archive.ts +3 -11
- package/os/adr/handlers/list-create.test.ts +174 -0
- package/os/adr/handlers/list-create.ts +16 -8
- package/os/audit/handlers/archive.ts +3 -11
- package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
- package/os/core/archive-regen.ts +33 -7
- package/os/core/core.module.ts +10 -76
- package/os/core/docs-archive.test.ts +25 -0
- package/os/core/handlers/assets-helpers.ts +2 -4
- package/os/core/handlers/determinism-check.ts +2 -3
- package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
- package/os/core/handlers/pinned-check.ts +30 -0
- package/os/core/handlers/pinned-types.ts +7 -0
- package/os/core/handlers/pinned-validate.ts +28 -3
- package/os/core/handlers/release-prepare.ts +2 -4
- package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
- package/os/flow/digest.ts +436 -95
- package/os/flow/evidence-lock.ts +184 -0
- package/os/flow/flow.module.ts +37 -14
- package/os/flow/git.ts +206 -11
- package/os/flow/handlers/flow-digest.ts +12 -8
- package/os/flow/handlers/flow-peers.ts +1 -1
- package/os/flow/handlers/flow-push.ts +725 -137
- package/os/flow/locks.ts +24 -7
- package/os/flow/open-missions.ts +45 -0
- package/os/flow/preflight.ts +5 -3
- package/os/flow/registry.ts +7 -3
- package/os/flow/tests/digest-id-inputs.test.ts +106 -0
- package/os/flow/tests/digest-persist.test.ts +243 -0
- package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
- package/os/flow/tests/flow-push-attest.test.ts +137 -0
- package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
- package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
- package/os/flow/tests/release-lines.test.ts +136 -0
- package/os/flow/tests/state-roots.test.ts +1 -48
- package/os/friction/friction-add.test.ts +42 -0
- package/os/friction/friction-migrate.test.ts +67 -2
- package/os/friction/friction.module.ts +33 -5
- package/os/friction/handlers/friction-add.ts +10 -15
- package/os/friction/handlers/friction-migrate.ts +220 -1
- package/os/friction/store.ts +19 -0
- package/os/friction/types.ts +8 -0
- package/os/gate/handlers/gate-probe-catalog.ts +39 -7
- package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
- package/os/plan/handlers/archive.ts +3 -11
- package/os/rfc/handlers/archive.ts +3 -11
- package/os/rfc/handlers/list-create.ts +22 -17
- package/os/rfc/handlers/validate-corpus.test.ts +149 -0
- package/os/rfc/probe-batch.test.ts +253 -0
- package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
- package/os/session/handlers/archive.ts +3 -11
- package/os/system/handlers/system-product-register.ts +492 -0
- package/os/system/handlers/system-products-status.ts +395 -0
- package/os/system/schemas.ts +17 -0
- package/os/system/system.module.ts +117 -3
- package/os/system/tests/system-product-register.test.ts +304 -0
- package/os/system/tests/system-products-status.test.ts +154 -0
- package/package.json +161 -506
- package/profiles/root-agents-system.md +82 -0
- package/profiles/system.yaml +1 -0
- package/src/command-modules.ts +0 -2
- package/src/config/forge-config.ts +16 -11
- package/src/index.ts +0 -2
- package/src/onboarding/create-superfolder-guard.test.ts +73 -0
- package/src/onboarding/create.ts +28 -2
- package/src/onboarding/doctor.ts +9 -96
- package/src/onboarding/npm-token-check.ts +3 -3
- package/src/profiles/stack-profile.ts +2 -2
- package/src/tests/evidence-consult-serialization.test.ts +202 -0
- package/src/tests/pinned-validate.test.ts +194 -0
- package/src/tests/pkg-health-self-scan.test.ts +29 -0
- package/src/tests/profile-flow-hooks.test.ts +1 -0
- package/src/tests/profile-schema.test.ts +1 -0
- package/src/tests/rfc-evidence-sync.test.ts +369 -0
- package/src/tests/skill-agents-sync.test.ts +192 -0
- package/src/tests/stack-profile.test.ts +1 -0
- package/src/types.ts +2 -2
- package/src/utils/hash.ts +5 -0
- package/src/utils/lockfile.ts +78 -0
- package/src/utils/verifier-git.ts +53 -5
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
- package/dist/os/mission/handlers/archive.d.ts +0 -4
- package/dist/os/mission/handlers/archive.d.ts.map +0 -1
- package/dist/os/mission/handlers/archive.js +0 -587
- package/dist/os/mission/handlers/archive.js.map +0 -1
- package/dist/os/mission/importer-block.d.ts +0 -19
- package/dist/os/mission/importer-block.d.ts.map +0 -1
- package/dist/os/mission/importer-block.js +0 -124
- package/dist/os/mission/importer-block.js.map +0 -1
- package/dist/os/mission/index.d.ts +0 -2
- package/dist/os/mission/index.d.ts.map +0 -1
- package/dist/os/mission/index.js +0 -15
- package/dist/os/mission/index.js.map +0 -1
- package/dist/os/mission/lockfile.d.ts.map +0 -1
- package/dist/os/mission/lockfile.js +0 -138
- package/dist/os/mission/lockfile.js.map +0 -1
- package/dist/os/mission/mission.module.d.ts +0 -3
- package/dist/os/mission/mission.module.d.ts.map +0 -1
- package/dist/os/mission/mission.module.js +0 -63
- package/dist/os/mission/mission.module.js.map +0 -1
- package/dist/os/mission/open-missions.d.ts.map +0 -1
- package/dist/os/mission/open-missions.js +0 -42
- package/dist/os/mission/open-missions.js.map +0 -1
- package/dist/os/mission/types.d.ts +0 -23
- package/dist/os/mission/types.d.ts.map +0 -1
- package/dist/os/mission/types.js +0 -19
- package/dist/os/mission/types.js.map +0 -1
- package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
- package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/lock.js +0 -153
- package/dist/os/werkstatt/handlers/lock.js.map +0 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
- package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/schema.js +0 -42
- package/dist/os/werkstatt/handlers/schema.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
- package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
- package/dist/os/werkstatt/index.d.ts +0 -7
- package/dist/os/werkstatt/index.d.ts.map +0 -1
- package/dist/os/werkstatt/index.js +0 -18
- package/dist/os/werkstatt/index.js.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.js +0 -91
- package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
- package/os/core/handlers/forge-autonomy-validate.ts +0 -276
- package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
- package/os/mission/handlers/archive.test.ts +0 -764
- package/os/mission/handlers/archive.ts +0 -719
- package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
- package/os/mission/importer-block.ts +0 -119
- package/os/mission/index.ts +0 -15
- package/os/mission/lockfile.ts +0 -152
- package/os/mission/mission.module.ts +0 -68
- package/os/mission/open-missions.ts +0 -50
- package/os/mission/types.ts +0 -42
- package/os/werkstatt/handlers/lock.ts +0 -168
- package/os/werkstatt/handlers/schema.ts +0 -47
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
- package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
- package/os/werkstatt/handlers/workspace-deps.ts +0 -56
- package/os/werkstatt/index.ts +0 -39
- package/os/werkstatt/werkstatt.module.ts +0 -95
- package/src/tests/doctor-autonomy.test.ts +0 -246
- package/src/tests/forge-autonomy-validate.test.ts +0 -159
- package/src/tests/werkstatt-lock.test.ts +0 -357
|
@@ -17,55 +17,11 @@ path.</purpose>
|
|
|
17
17
|
<item>Publication failures are FLOW-PUSH-05 per tag; the command continues with the next tag and exits non-zero at the end.</item>
|
|
18
18
|
</KEY_DECISIONS>
|
|
19
19
|
<CHANGE_SUMMARY>
|
|
20
|
-
<item>RFC-1616: close RFC-1616 r5 trust-boundary counterexamples</item>
|
|
21
|
-
<item>RFC-1616: close RFC-1616 r7 trust-boundary counterexamples
|
|
22
|
-
|
|
23
|
-
Independent clean-context verification (round 7, candidate d2f270ad6)
|
|
24
|
-
returned REFUTED with eleven live counterexamples against the
|
|
25
|
-
r6-hardened evidence channel — this commit closes all nine root causes.
|
|
26
|
-
|
|
27
|
-
- remote.<name>.fetch is value-judged: only the clone-default
|
|
28
|
-
+?refs/heads/*:refs/remotes/<name>/* shape stays KEEP, because git
|
|
29
|
-
UNIONs configured refspecs with the pinned fetch argv and a session
|
|
30
|
-
spec writes arbitrary local refs inside the trusted fetch (CX-94).
|
|
31
|
-
remote.<name>.tagopt|promirror|followremotehead|prunetags|
|
|
32
|
-
skipfetchall|mirror move to REFUSE for the same reason.
|
|
33
|
-
- Alternates/shape comment lexing is col-0 `#` only — git's parser does
|
|
34
|
-
not treat whitespace-led `#` as a comment, so ` # forged` is a real
|
|
35
|
-
alternates path the shape check must count (CX-95).
|
|
36
|
-
- config reads forbid the alternate-source selectors --file/-f, --blob,
|
|
37
|
-
--worktree (reaches config.worktree even under the disabled-extension
|
|
38
|
-
pin), --system/--global, --default and --includes, plus the
|
|
39
|
-
write-action spellings, on both the evidence and shared read-only
|
|
40
|
-
tables (CX-96).
|
|
41
|
-
- verifierGit judges fabrication argv on the runner/policy channel:
|
|
42
|
-
@{...}, -g, --reflog, --walk-reflogs and --fork-point return
|
|
43
|
-
EVIDENCE-REFUSED before the spawn — policy.digest --base 'HEAD@{0}'
|
|
44
|
-
can no longer verify an unattested advance (CX-97).
|
|
45
|
-
- --use-bitmap-index/--test-bitmap are forbidden on rev-list/log in
|
|
46
|
-
both tables — the flag opts the trusted walk into the session-
|
|
47
|
-
writable pack bitmap cache the commitGraph/MIDX pins closed (CX-98).
|
|
48
|
-
- for-each-ref/show-ref/ls-remote forbid --stdin and --exclude-existing
|
|
49
|
-
on both tables — they block on input the no-stdin spawn never
|
|
50
|
-
supplies (CX-101).
|
|
51
|
-
- The workflow-adoption heredoc lexer is bash-faithful: openers are
|
|
52
|
-
scanned on the raw line before the # comment strip (quoted-#
|
|
53
|
-
delimiters, CX-99a), bare delimiters accept digits/./- (CX-99b), and
|
|
54
|
-
the terminator match is strict — << wants the delimiter alone, <<-/
|
|
55
|
-
<<~ skip leading tabs only (CX-100).
|
|
56
|
-
- Trailer scans read %e beside %(trailers): a commit declaring a
|
|
57
|
-
non-UTF-8 encoding header recodes every trusted message read, so the
|
|
58
|
-
digest trail and the push-time scan flag it as unverifiable and the
|
|
59
|
-
policy attestation scan skips it (CX-102).
|
|
60
|
-
|
|
61
|
-
Probe premise updates for the tightened contract: CX-61's decoy
|
|
62
|
-
remote.origin.fetch (cx4 and cx5 R5-R1) now asserts the wholesale
|
|
63
|
-
EVIDENCE-REFUSED plus FLOW-PUSH-13 refuse — strictly stronger than the
|
|
64
|
-
decoy-namespace guard it replaces. The independent r7 probe file and
|
|
65
|
-
acceptance report land in the follow-up port commit.</item>
|
|
66
|
-
<item>RFC-1616: close RFC-1616 r12 trust-boundary counterexamples</item>
|
|
67
|
-
<item>RFC-1616: close RFC-1616 r13 trust-boundary counterexamples</item>
|
|
68
20
|
<item>RFC-1616: close r21 counterexample CX-179 + push-scan refusal polarity</item>
|
|
21
|
+
<item>RFC-1633: serialize evidence consults + bestEffort reader mode (RFC-1633)</item>
|
|
22
|
+
<item>RFC-1638: persist reviewed digests + attest pushed state by input hash</item>
|
|
23
|
+
<item>RFC-1638: review round 1 — payload preimage binding, fail-closed coverage scan, FLOW-PUSH-15</item>
|
|
24
|
+
<item>RFC-1643: committed verifier-review baseline for flow.push</item>
|
|
69
25
|
<history>RFC-1491, RFC-1501, RFC-1503, RFC-1616</history>
|
|
70
26
|
</CHANGE_SUMMARY>
|
|
71
27
|
*/
|
|
@@ -81,8 +37,24 @@ import type {
|
|
|
81
37
|
} from "../../../src/types.ts";
|
|
82
38
|
import { resolveIo } from "../../../src/utils/io.ts";
|
|
83
39
|
import { parse as parseYaml } from "yaml";
|
|
84
|
-
import {
|
|
85
|
-
|
|
40
|
+
import {
|
|
41
|
+
collectDigest,
|
|
42
|
+
digestInputHash,
|
|
43
|
+
lineForTag,
|
|
44
|
+
loadPersistedDigest,
|
|
45
|
+
observeDigestInputs,
|
|
46
|
+
recomputePersistedDigestId,
|
|
47
|
+
versionOfTag,
|
|
48
|
+
type FlowDigestData,
|
|
49
|
+
} from "../digest.ts";
|
|
50
|
+
import {
|
|
51
|
+
assertJudgedEvidence,
|
|
52
|
+
git,
|
|
53
|
+
gitEvidence,
|
|
54
|
+
parseGitTrailers,
|
|
55
|
+
requireGit,
|
|
56
|
+
verifierTopLevel,
|
|
57
|
+
} from "../git.ts";
|
|
86
58
|
import { EVIDENCE_REFUSED_PREFIX } from "../../../src/utils/verifier-git.ts";
|
|
87
59
|
import { markerIsValid } from "../markers.ts";
|
|
88
60
|
import { publishTag, tagAnnotationLevel, type PublicationRow } from "../publish.ts";
|
|
@@ -111,6 +83,24 @@ export interface FlowPushData {
|
|
|
111
83
|
verifierTrailerCommits?: Array<{ sha: string; trailers: string[] }>;
|
|
112
84
|
/** RFC-1616: the operator reason passed to --accept-verifier-trailers, when accepted. */
|
|
113
85
|
verifierTrailersAccepted?: string;
|
|
86
|
+
/** RFC-1643: how the committed review baseline was judged; absent when the scan did not run. */
|
|
87
|
+
verifierReviewBaseline?: {
|
|
88
|
+
status: "absent" | "applied" | "unusable";
|
|
89
|
+
declared?: string;
|
|
90
|
+
reason?: VerifierReviewBaselineReason;
|
|
91
|
+
/** Full shas of hits the baseline exempted, sorted. */
|
|
92
|
+
exempted: string[];
|
|
93
|
+
/** Subset of `exempted` the previous baseline did not cover. */
|
|
94
|
+
newlyExempted: string[];
|
|
95
|
+
/** The first-parent commit that last changed the parsed value, when found. */
|
|
96
|
+
bumpedBy?: string;
|
|
97
|
+
/** Every parsed-value change in the walk window, newest first. */
|
|
98
|
+
changes: BaselineChange[];
|
|
99
|
+
};
|
|
100
|
+
/** RFC-1638: how the quoted digest was validated — persisted-input attestation or full recount. */
|
|
101
|
+
attestation?: "input-hash" | "recount";
|
|
102
|
+
/** RFC-1638: when the reviewed digest was computed (attestation path). */
|
|
103
|
+
digestComputedAt?: string;
|
|
114
104
|
}
|
|
115
105
|
|
|
116
106
|
/** RFC-1616: the commit trailers the push-time verifier-review scan flags. */
|
|
@@ -139,13 +129,21 @@ function refuse(ruleId: string, message: string, fixHint?: string): FlowPushData
|
|
|
139
129
|
*/
|
|
140
130
|
/**
|
|
141
131
|
* RFC-1616 (AC-6): list commits in `range` whose message carries a verifier /
|
|
142
|
-
* audit trailer.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* (CX-
|
|
146
|
-
* exactly as `git interpret-trailers` counts them (CX-60). The channel is
|
|
132
|
+
* audit trailer. Commit SHAs enumerate via `rev-list` (hex-only output) and
|
|
133
|
+
* each commit's trailers arrive through git's OWN `%(trailers:only)` parser —
|
|
134
|
+
* `x-verifier-report:`/`X-Verifier-Report :` spellings count exactly as
|
|
135
|
+
* `git interpret-trailers` counts them (CX-60). The channel is
|
|
147
136
|
* `gitEvidence`: session GIT_* variables and refs/replace cannot redirect
|
|
148
137
|
* or substitute what the scan sees (CX-48).
|
|
138
|
+
*
|
|
139
|
+
* F-0394: the range is the whole local branch (CX-82/CX-132), and every
|
|
140
|
+
* judged consult re-runs the full evidence preflight (seconds each), so a
|
|
141
|
+
* per-commit read pair walked tens of thousands of consults — ~85 h on an
|
|
142
|
+
* 18k-commit repo. The scan now reads the range in TWO batched judged
|
|
143
|
+
* consults (`batchedCommitReads`) and falls back to the exact per-commit
|
|
144
|
+
* reads whenever the batch cannot be proven to frame one record per
|
|
145
|
+
* enumerated sha (CX-33) — the per-record judgment is byte-identical on
|
|
146
|
+
* both paths.
|
|
149
147
|
*/
|
|
150
148
|
async function scanVerifierTrailers(
|
|
151
149
|
repoRoot: string,
|
|
@@ -153,68 +151,451 @@ async function scanVerifierTrailers(
|
|
|
153
151
|
range: string,
|
|
154
152
|
): Promise<Array<{ sha: string; trailers: string[] }> | null> {
|
|
155
153
|
const list = await gitEvidence(repoRoot, ["rev-list", range]);
|
|
154
|
+
assertJudgedEvidence(list);
|
|
156
155
|
// Any failure on an enumerable range is unverifiable — `[]` would run
|
|
157
156
|
// the trailer scan over nothing (CX-174's shape inside the push gate
|
|
158
157
|
// itself); null lets the caller refuse loudly.
|
|
159
158
|
if (list.exitCode !== 0) return null;
|
|
160
|
-
const
|
|
161
|
-
const canonical = new Map(VERIFIER_TRAILERS.map((t) => [t.toLowerCase(), t]));
|
|
162
|
-
const hits: Array<{ sha: string; trailers: string[] }> = [];
|
|
163
|
-
for (const sha of list.stdout
|
|
159
|
+
const shas = list.stdout
|
|
164
160
|
.split("\n")
|
|
165
161
|
.map((s) => s.trim())
|
|
166
|
-
.filter(Boolean)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
162
|
+
.filter(Boolean);
|
|
163
|
+
if (shas.length === 0) return [];
|
|
164
|
+
const batched = await batchedCommitReads(repoRoot, range, shas);
|
|
165
|
+
const hits: Array<{ sha: string; trailers: string[] }> = [];
|
|
166
|
+
for (const sha of shas) {
|
|
167
|
+
const reads = batched?.get(sha) ?? (await perCommitReads(repoRoot, sha));
|
|
168
|
+
const found = judgeVerifierTrailers(reads);
|
|
169
|
+
if (found.length > 0) hits.push({ sha, trailers: found });
|
|
170
|
+
}
|
|
171
|
+
return hits;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** One commit's two judged reads: `null` = that read failed (unverifiable). */
|
|
175
|
+
interface CommitReads {
|
|
176
|
+
/** stdout of `log -1 --format=%(trailers:only,separator=%x00)%x00%e <sha>`. */
|
|
177
|
+
trailers: string | null;
|
|
178
|
+
/** stdout of `log -1 --format=%s <sha>`. */
|
|
179
|
+
subject: string | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const TRAILER_READ_FORMAT = "%(trailers:only,separator=%x00)%x00%e";
|
|
183
|
+
|
|
184
|
+
/** The exact pre-F-0394 per-commit reads — two judged consults per sha. */
|
|
185
|
+
async function perCommitReads(repoRoot: string, sha: string): Promise<CommitReads> {
|
|
186
|
+
// `%e` rides along — a commit declaring a non-default `encoding:`
|
|
187
|
+
// header RECODES this very output, so %(trailers) over it is already
|
|
188
|
+
// garbage: the header lives in the object and no -c pin reaches it
|
|
189
|
+
// (CX-102). An encoded commit's trailers are unverifiable — flag it.
|
|
190
|
+
const parsed = await gitEvidence(repoRoot, ["log", "-1", `--format=${TRAILER_READ_FORMAT}`, sha]);
|
|
191
|
+
assertJudgedEvidence(parsed);
|
|
192
|
+
// `%s` is one line — no delimiter to smuggle.
|
|
193
|
+
const subj = await gitEvidence(repoRoot, ["log", "-1", "--format=%s", sha]);
|
|
194
|
+
assertJudgedEvidence(subj);
|
|
195
|
+
return {
|
|
196
|
+
trailers: parsed.exitCode === 0 ? parsed.stdout : null,
|
|
197
|
+
subject: subj.exitCode === 0 ? subj.stdout : null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* F-0394: both reads for every commit of `range` in two judged consults.
|
|
203
|
+
* Each record is `\x1e<sha>\x00<per-commit read output>` — the payload
|
|
204
|
+
* after the sha prefix is exactly what `perCommitReads` would have read.
|
|
205
|
+
* A \x1e or forged `<sha>\x00` inside a message can only ADD records
|
|
206
|
+
* (separators are never consumed), so the batch is accepted only when
|
|
207
|
+
* every record carries an enumerated sha, no sha repeats, and the record
|
|
208
|
+
* count equals the `rev-list` count (CX-33). Any mismatch, failure or
|
|
209
|
+
* refusal returns null and the caller reads per commit — slow but exact,
|
|
210
|
+
* never a narrower scan.
|
|
211
|
+
*/
|
|
212
|
+
export async function batchedCommitReads(
|
|
213
|
+
repoRoot: string,
|
|
214
|
+
range: string,
|
|
215
|
+
shas: readonly string[],
|
|
216
|
+
): Promise<Map<string, CommitReads> | null> {
|
|
217
|
+
const trailerRecords = await batchedRecords(repoRoot, range, TRAILER_READ_FORMAT, shas);
|
|
218
|
+
if (trailerRecords === null) return null;
|
|
219
|
+
const subjectRecords = await batchedRecords(repoRoot, range, "%s", shas);
|
|
220
|
+
if (subjectRecords === null) return null;
|
|
221
|
+
const out = new Map<string, CommitReads>();
|
|
222
|
+
for (const sha of shas) {
|
|
223
|
+
out.set(sha, { trailers: trailerRecords.get(sha)!, subject: subjectRecords.get(sha)! });
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async function batchedRecords(
|
|
229
|
+
repoRoot: string,
|
|
230
|
+
range: string,
|
|
231
|
+
format: string,
|
|
232
|
+
shas: readonly string[],
|
|
233
|
+
): Promise<Map<string, string> | null> {
|
|
234
|
+
const r = await gitEvidence(repoRoot, ["log", `--format=%x1e%H%x00${format}`, range]);
|
|
235
|
+
assertJudgedEvidence(r);
|
|
236
|
+
if (r.exitCode !== 0) return null;
|
|
237
|
+
const expected = new Set(shas);
|
|
238
|
+
const parts = r.stdout.split("\x1e");
|
|
239
|
+
// The output starts with the separator — anything before it is foreign.
|
|
240
|
+
if (parts.shift() !== "") return null;
|
|
241
|
+
if (parts.length !== expected.size) return null;
|
|
242
|
+
const records = new Map<string, string>();
|
|
243
|
+
for (const part of parts) {
|
|
244
|
+
const nul = part.indexOf("\x00");
|
|
245
|
+
if (nul <= 0) return null;
|
|
246
|
+
const sha = part.slice(0, nul);
|
|
247
|
+
if (!expected.has(sha) || records.has(sha)) return null;
|
|
248
|
+
records.set(sha, part.slice(nul + 1));
|
|
249
|
+
}
|
|
250
|
+
return records.size === expected.size ? records : null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Verifier/audit trailers one commit's reads carry, sorted; [] = clean. */
|
|
254
|
+
function judgeVerifierTrailers(reads: CommitReads): string[] {
|
|
255
|
+
const wanted = new Set(VERIFIER_TRAILERS.map((t) => t.toLowerCase()));
|
|
256
|
+
const canonical = new Map(VERIFIER_TRAILERS.map((t) => [t.toLowerCase(), t]));
|
|
257
|
+
if (reads.trailers === null) {
|
|
258
|
+
// An enumerated commit whose trailer read fails is unverifiable —
|
|
259
|
+
// flag it like the encoding case instead of silently dropping its
|
|
260
|
+
// provenance under a surgical refusal.
|
|
261
|
+
return ["x-unverifiable-commit"];
|
|
262
|
+
}
|
|
263
|
+
const parsedParts = reads.trailers.split("\x00");
|
|
264
|
+
const declaredEncoding = (parsedParts.pop() ?? "").trim();
|
|
265
|
+
const found = new Set<string>();
|
|
266
|
+
if (declaredEncoding.length > 0 && !/^utf-?8$/i.test(declaredEncoding)) {
|
|
267
|
+
found.add(`x-unverifiable-encoding: ${declaredEncoding}`);
|
|
268
|
+
}
|
|
269
|
+
for (const t of parseGitTrailers(parsedParts.join("\x00").replaceAll("\x00", "\n"))) {
|
|
270
|
+
const c = canonical.get(t.key);
|
|
271
|
+
if (wanted.has(t.key) && c && t.value.length > 0) found.add(c);
|
|
272
|
+
}
|
|
273
|
+
// A trailer-shaped SUBJECT is not a git trailer on every version — but it
|
|
274
|
+
// looks exactly like provenance text, so flag it anyway (stricter is
|
|
275
|
+
// safe, CX-23).
|
|
276
|
+
if (reads.subject !== null) {
|
|
277
|
+
const m = /^([^:\s][^:]*?)\s*:\s*(.*)$/.exec(reads.subject.trim());
|
|
278
|
+
if (m) {
|
|
279
|
+
const c = canonical.get(m[1]!.trim().toLowerCase());
|
|
280
|
+
if (c && m[2]!.trim().length > 0) found.add(c);
|
|
193
281
|
}
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
282
|
+
} else {
|
|
283
|
+
// The subject-shaped-trailer check could not run — flag the sha
|
|
284
|
+
// rather than assume no trailer-shaped subject.
|
|
285
|
+
found.add("x-unverifiable-commit");
|
|
286
|
+
}
|
|
287
|
+
return [...found].sort();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** RFC-1643: why a declared review baseline exempts nothing. */
|
|
291
|
+
export type VerifierReviewBaselineReason =
|
|
292
|
+
"malformed" | "unknown" | "not-a-commit" | "not-ancestor" | "unverifiable";
|
|
293
|
+
|
|
294
|
+
/** RFC-1643: the judged state of `push.verifierReviewedThrough`. */
|
|
295
|
+
export type VerifierReviewBaseline =
|
|
296
|
+
| { status: "absent" }
|
|
297
|
+
| { status: "applied"; sha: string }
|
|
298
|
+
| { status: "unusable"; declared: string; reason: VerifierReviewBaselineReason };
|
|
299
|
+
|
|
300
|
+
/** RFC-1643: the committed `forge.yaml` at a sha — `unverifiable` on a refused read. */
|
|
301
|
+
type CommittedForgeDoc =
|
|
302
|
+
| { kind: "doc"; doc: Record<string, unknown> | null; raw: string }
|
|
303
|
+
| { kind: "missing" }
|
|
304
|
+
| { kind: "unparsable"; raw: string }
|
|
305
|
+
| { kind: "unverifiable" };
|
|
306
|
+
|
|
307
|
+
async function readCommittedForgeDoc(repoRoot: string, rev: string): Promise<CommittedForgeDoc> {
|
|
308
|
+
const show = await gitEvidence(repoRoot, ["show", `${rev}:forge.yaml`]);
|
|
309
|
+
assertJudgedEvidence(show);
|
|
310
|
+
if (show.exitCode === -1) return { kind: "unverifiable" };
|
|
311
|
+
if (show.exitCode !== 0) return { kind: "missing" };
|
|
312
|
+
try {
|
|
313
|
+
// `yaml` rejects duplicate keys by default — a shadowed `push:` block
|
|
314
|
+
// is a parse error, never a silently-chosen winner.
|
|
315
|
+
const doc = parseYaml(show.stdout) as unknown;
|
|
316
|
+
return {
|
|
317
|
+
kind: "doc",
|
|
318
|
+
doc: typeof doc === "object" && doc !== null ? (doc as Record<string, unknown>) : null,
|
|
319
|
+
raw: show.stdout,
|
|
320
|
+
};
|
|
321
|
+
} catch {
|
|
322
|
+
return { kind: "unparsable", raw: show.stdout };
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function pushSection(doc: Record<string, unknown> | null): Record<string, unknown> | undefined {
|
|
327
|
+
const push = doc?.["push"];
|
|
328
|
+
return typeof push === "object" && push !== null && !Array.isArray(push)
|
|
329
|
+
? (push as Record<string, unknown>)
|
|
330
|
+
: undefined;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** The raw declared baseline in a committed doc — `undefined` when absent. */
|
|
334
|
+
function declaredBaseline(doc: CommittedForgeDoc): unknown {
|
|
335
|
+
if (doc.kind !== "doc") return undefined;
|
|
336
|
+
const v = pushSection(doc.doc)?.["verifierReviewedThrough"];
|
|
337
|
+
return v === null ? undefined : v;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* RFC-1643: judge `push.verifierReviewedThrough` from the committed
|
|
342
|
+
* forge.yaml at the digest-reviewed develop tip. Every read is a judged
|
|
343
|
+
* consult; every failure exempts nothing (fail closed). Only a full,
|
|
344
|
+
* lower-case object name of the repository's format that names a commit
|
|
345
|
+
* reachable from `refs/heads/develop` (re-read, must equal `developTip`)
|
|
346
|
+
* is `applied`.
|
|
347
|
+
*/
|
|
348
|
+
export async function resolveVerifierReviewBaseline(
|
|
349
|
+
repoRoot: string,
|
|
350
|
+
developTip: string,
|
|
351
|
+
committed: CommittedForgeDoc,
|
|
352
|
+
): Promise<VerifierReviewBaseline> {
|
|
353
|
+
if (committed.kind === "unverifiable") {
|
|
354
|
+
return { status: "unusable", declared: "", reason: "unverifiable" };
|
|
355
|
+
}
|
|
356
|
+
if (committed.kind === "missing") return { status: "absent" };
|
|
357
|
+
if (committed.kind === "unparsable") {
|
|
358
|
+
return committed.raw.includes("verifierReviewedThrough")
|
|
359
|
+
? { status: "unusable", declared: "", reason: "malformed" }
|
|
360
|
+
: { status: "absent" };
|
|
361
|
+
}
|
|
362
|
+
const raw = declaredBaseline(committed);
|
|
363
|
+
if (raw === undefined) return { status: "absent" };
|
|
364
|
+
if (typeof raw !== "string") {
|
|
365
|
+
return { status: "unusable", declared: String(raw), reason: "malformed" };
|
|
366
|
+
}
|
|
367
|
+
const unusable = (reason: VerifierReviewBaselineReason): VerifierReviewBaseline => ({
|
|
368
|
+
status: "unusable",
|
|
369
|
+
declared: raw,
|
|
370
|
+
reason,
|
|
371
|
+
});
|
|
372
|
+
const fmt = await gitEvidence(repoRoot, ["rev-parse", "--show-object-format"]);
|
|
373
|
+
assertJudgedEvidence(fmt);
|
|
374
|
+
if (fmt.exitCode !== 0) return unusable("unverifiable");
|
|
375
|
+
const hexLen = fmt.stdout.trim() === "sha256" ? 64 : 40;
|
|
376
|
+
if (!new RegExp(`^[0-9a-f]{${hexLen}}$`).test(raw)) return unusable("malformed");
|
|
377
|
+
// The develop tip the baseline is judged against must still be the
|
|
378
|
+
// fully-qualified local branch — a persisted digest from a bare-name
|
|
379
|
+
// resolution, or a shadow ref, must not anchor the ancestry check.
|
|
380
|
+
const tip = await gitEvidence(repoRoot, [
|
|
381
|
+
"rev-parse",
|
|
382
|
+
"--verify",
|
|
383
|
+
"--quiet",
|
|
384
|
+
"refs/heads/develop",
|
|
385
|
+
]);
|
|
386
|
+
assertJudgedEvidence(tip);
|
|
387
|
+
if (tip.exitCode !== 0 || tip.stdout.trim() !== developTip) return unusable("unverifiable");
|
|
388
|
+
const peeled = await gitEvidence(repoRoot, [
|
|
389
|
+
"rev-parse",
|
|
390
|
+
"--verify",
|
|
391
|
+
"--quiet",
|
|
392
|
+
"--end-of-options",
|
|
393
|
+
`${raw}^{commit}`,
|
|
394
|
+
]);
|
|
395
|
+
assertJudgedEvidence(peeled);
|
|
396
|
+
if (peeled.exitCode === -1) return unusable("unverifiable");
|
|
397
|
+
if (peeled.exitCode !== 0) return unusable("unknown");
|
|
398
|
+
// A tag object peels to a DIFFERENT commit — never a stand-in.
|
|
399
|
+
if (peeled.stdout.trim() !== raw) return unusable("not-a-commit");
|
|
400
|
+
const anc = await gitEvidence(repoRoot, ["merge-base", "--is-ancestor", raw, developTip]);
|
|
401
|
+
assertJudgedEvidence(anc);
|
|
402
|
+
if (anc.exitCode === 1) return unusable("not-ancestor");
|
|
403
|
+
if (anc.exitCode !== 0) return unusable("unverifiable");
|
|
404
|
+
return { status: "applied", sha: raw };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** `rev-list <rev>` as a set — null when the read fails (exempt nothing). */
|
|
408
|
+
async function ancestrySet(repoRoot: string, rev: string): Promise<Set<string> | null> {
|
|
409
|
+
const r = await gitEvidence(repoRoot, ["rev-list", rev]);
|
|
410
|
+
assertJudgedEvidence(r);
|
|
411
|
+
if (r.exitCode !== 0) return null;
|
|
412
|
+
return new Set(
|
|
413
|
+
r.stdout
|
|
414
|
+
.split("\n")
|
|
415
|
+
.map((s) => s.trim())
|
|
416
|
+
.filter(Boolean),
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async function singleParent(repoRoot: string, sha: string): Promise<string | null> {
|
|
421
|
+
const r = await gitEvidence(repoRoot, ["rev-list", "--parents", "-n", "1", sha]);
|
|
422
|
+
assertJudgedEvidence(r);
|
|
423
|
+
if (r.exitCode !== 0) return null;
|
|
424
|
+
const parts = r.stdout.trim().split(/\s+/);
|
|
425
|
+
return parts.length === 2 && parts[0] === sha ? parts[1]! : null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function treeOf(repoRoot: string, sha: string): Promise<string | null> {
|
|
429
|
+
const r = await gitEvidence(repoRoot, [
|
|
430
|
+
"rev-parse",
|
|
431
|
+
"--verify",
|
|
432
|
+
"--quiet",
|
|
433
|
+
"--end-of-options",
|
|
434
|
+
`${sha}^{tree}`,
|
|
435
|
+
]);
|
|
436
|
+
assertJudgedEvidence(r);
|
|
437
|
+
return r.exitCode === 0 ? r.stdout.trim() : null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async function treeListing(repoRoot: string, sha: string): Promise<Map<string, string> | null> {
|
|
441
|
+
const r = await gitEvidence(repoRoot, ["ls-tree", "-r", "-z", sha]);
|
|
442
|
+
assertJudgedEvidence(r);
|
|
443
|
+
if (r.exitCode !== 0) return null;
|
|
444
|
+
const out = new Map<string, string>();
|
|
445
|
+
for (const rec of r.stdout.split("\0")) {
|
|
446
|
+
if (rec.length === 0) continue;
|
|
447
|
+
const tab = rec.indexOf("\t");
|
|
448
|
+
if (tab <= 0) return null;
|
|
449
|
+
out.set(rec.slice(tab + 1), rec.slice(0, tab));
|
|
450
|
+
}
|
|
451
|
+
return out;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** Canonical JSON for doc comparison — key order never matters. */
|
|
455
|
+
function canonicalDoc(v: unknown): string {
|
|
456
|
+
if (Array.isArray(v)) return `[${v.map(canonicalDoc).join(",")}]`;
|
|
457
|
+
if (typeof v === "object" && v !== null) {
|
|
458
|
+
const rec = v as Record<string, unknown>;
|
|
459
|
+
return `{${Object.keys(rec)
|
|
460
|
+
.sort()
|
|
461
|
+
.map((k) => `${JSON.stringify(k)}:${canonicalDoc(rec[k])}`)
|
|
462
|
+
.join(",")}}`;
|
|
463
|
+
}
|
|
464
|
+
// NaN/±Infinity serialize as `null` and unsafe integers lose
|
|
465
|
+
// precision — a doc carrying one never compares equal (no exemption).
|
|
466
|
+
if (typeof v === "number" && (!Number.isFinite(v) || !Number.isSafeInteger(Math.trunc(v)))) {
|
|
467
|
+
return `\u0000unfaithful:${Math.random()}`;
|
|
468
|
+
}
|
|
469
|
+
if (typeof v === "bigint") return `\u0000unfaithful:${Math.random()}`;
|
|
470
|
+
return JSON.stringify(v ?? null);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function withoutBaseline(doc: Record<string, unknown> | null): string {
|
|
474
|
+
if (doc === null) return "null";
|
|
475
|
+
const push = pushSection(doc);
|
|
476
|
+
if (push === undefined) return canonicalDoc(doc);
|
|
477
|
+
const { verifierReviewedThrough: _drop, ...restPush } = push;
|
|
478
|
+
return canonicalDoc({ ...doc, push: restPush });
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* RFC-1643: the integrate-generated weakening record of a baseline-only
|
|
483
|
+
* bump. In a `policy:` repository `push` is a contour key, so
|
|
484
|
+
* `flow.integrate --accept-weakening` appends an EMPTY commit carrying
|
|
485
|
+
* `X-Correctness-Weakening` on top of the bump — always a descendant of
|
|
486
|
+
* the baseline it records. Exempt exactly that record: sole trailer
|
|
487
|
+
* X-Correctness-Weakening, empty, single parent P, P single-parent, P
|
|
488
|
+
* changes only forge.yaml, only `push.verifierReviewedThrough` differs,
|
|
489
|
+
* and P sets it to the APPLIED baseline.
|
|
490
|
+
*/
|
|
491
|
+
async function isBaselineBumpRecord(
|
|
492
|
+
repoRoot: string,
|
|
493
|
+
hit: { sha: string; trailers: string[] },
|
|
494
|
+
baseline: string,
|
|
495
|
+
): Promise<boolean> {
|
|
496
|
+
if (hit.trailers.length !== 1 || hit.trailers[0] !== "X-Correctness-Weakening") return false;
|
|
497
|
+
const p = await singleParent(repoRoot, hit.sha);
|
|
498
|
+
if (p === null) return false;
|
|
499
|
+
const [wTree, pTree] = await Promise.all([treeOf(repoRoot, hit.sha), treeOf(repoRoot, p)]);
|
|
500
|
+
if (wTree === null || wTree !== pTree) return false;
|
|
501
|
+
const pp = await singleParent(repoRoot, p);
|
|
502
|
+
if (pp === null) return false;
|
|
503
|
+
const [before, after] = await Promise.all([treeListing(repoRoot, pp), treeListing(repoRoot, p)]);
|
|
504
|
+
if (before === null || after === null) return false;
|
|
505
|
+
const changed = new Set<string>();
|
|
506
|
+
for (const [path, entry] of after) if (before.get(path) !== entry) changed.add(path);
|
|
507
|
+
for (const path of before.keys()) if (!after.has(path)) changed.add(path);
|
|
508
|
+
if (changed.size !== 1 || !changed.has("forge.yaml")) return false;
|
|
509
|
+
const [docBefore, docAfter] = await Promise.all([
|
|
510
|
+
readCommittedForgeDoc(repoRoot, pp),
|
|
511
|
+
readCommittedForgeDoc(repoRoot, p),
|
|
512
|
+
]);
|
|
513
|
+
if (docBefore.kind !== "doc" || docAfter.kind !== "doc") return false;
|
|
514
|
+
if (declaredBaseline(docAfter) !== baseline) return false;
|
|
515
|
+
if (declaredBaseline(docBefore) === baseline) return false;
|
|
516
|
+
return withoutBaseline(docBefore.doc) === withoutBaseline(docAfter.doc);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** RFC-1643: how far back FLOW-PUSH-17 walks forge.yaml-touching first-parent commits. */
|
|
520
|
+
const BASELINE_HISTORY_WINDOW = 64;
|
|
521
|
+
|
|
522
|
+
/** RFC-1643: one change of the parsed baseline value on develop's first-parent chain. */
|
|
523
|
+
export interface BaselineChange {
|
|
524
|
+
commit: string;
|
|
525
|
+
from: string;
|
|
526
|
+
to: string;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* RFC-1643 (FLOW-PUSH-17 visibility): every change of the PARSED
|
|
531
|
+
* `push.verifierReviewedThrough` value on develop's first-parent chain,
|
|
532
|
+
* newest first — compared by value, never by text (a comment or a
|
|
533
|
+
* re-quote that `-G` would match is not a change, and a decoy commit can
|
|
534
|
+
* no longer pose as the bump). The walk covers the forge.yaml-touching
|
|
535
|
+
* first-parent commits up to BASELINE_HISTORY_WINDOW and stops where the
|
|
536
|
+
* key is absent (its introduction). `oldest` is the value at the window's
|
|
537
|
+
* far end — `undefined` when the key was introduced inside the window, so
|
|
538
|
+
* "newly exempted" is measured from a point a chain of session bumps
|
|
539
|
+
* cannot move inside the window. Advisory — a failed read yields
|
|
540
|
+
* `undefined`, never an exemption.
|
|
541
|
+
*/
|
|
542
|
+
async function baselineHistory(
|
|
543
|
+
repoRoot: string,
|
|
544
|
+
developTip: string,
|
|
545
|
+
): Promise<{ changes: BaselineChange[]; oldest: unknown } | undefined> {
|
|
546
|
+
const r = await gitEvidence(repoRoot, [
|
|
547
|
+
"log",
|
|
548
|
+
"--first-parent",
|
|
549
|
+
"--format=%H",
|
|
550
|
+
"-n",
|
|
551
|
+
String(BASELINE_HISTORY_WINDOW),
|
|
552
|
+
developTip,
|
|
553
|
+
"--",
|
|
554
|
+
"forge.yaml",
|
|
555
|
+
]);
|
|
556
|
+
assertJudgedEvidence(r);
|
|
557
|
+
if (r.exitCode !== 0) return undefined;
|
|
558
|
+
const commits = r.stdout
|
|
559
|
+
.split("\n")
|
|
560
|
+
.map((l) => l.trim())
|
|
561
|
+
.filter(Boolean);
|
|
562
|
+
if (commits.length === 0 || !commits.every((c) => /^[0-9a-f]{40,64}$/.test(c))) {
|
|
563
|
+
return undefined;
|
|
564
|
+
}
|
|
565
|
+
const valueAt = async (rev: string): Promise<string | undefined | null> => {
|
|
566
|
+
const doc = await readCommittedForgeDoc(repoRoot, rev);
|
|
567
|
+
if (doc.kind === "unverifiable" || doc.kind === "unparsable") return null;
|
|
568
|
+
const v = declaredBaseline(doc);
|
|
569
|
+
return v === undefined ? undefined : String(v);
|
|
570
|
+
};
|
|
571
|
+
const changes: BaselineChange[] = [];
|
|
572
|
+
let current = await valueAt(commits[0]!);
|
|
573
|
+
if (current === null) return undefined;
|
|
574
|
+
for (const c of commits) {
|
|
575
|
+
// History simplification: on the first-parent chain, `c^1` carries
|
|
576
|
+
// the same forge.yaml as the next older listed commit.
|
|
577
|
+
const before = await valueAt(`${c}^1`);
|
|
578
|
+
if (before === null) return undefined;
|
|
579
|
+
if (before !== current) {
|
|
580
|
+
changes.push({ commit: c, from: before ?? "(absent)", to: current ?? "(absent)" });
|
|
208
581
|
}
|
|
209
|
-
|
|
582
|
+
current = before;
|
|
583
|
+
if (current === undefined) return { changes, oldest: undefined };
|
|
210
584
|
}
|
|
211
|
-
return
|
|
585
|
+
return { changes, oldest: current };
|
|
212
586
|
}
|
|
213
587
|
|
|
214
588
|
export async function pushFlow(
|
|
215
589
|
repoRoot: string,
|
|
216
590
|
io: WorkspaceIO,
|
|
217
|
-
opts: {
|
|
591
|
+
opts: {
|
|
592
|
+
digest: string;
|
|
593
|
+
dryRun: boolean;
|
|
594
|
+
now?: Date;
|
|
595
|
+
acceptVerifierTrailers?: string;
|
|
596
|
+
/** RFC-1638: force the full recount path — skip the persisted input-hash attestation. */
|
|
597
|
+
recount?: boolean;
|
|
598
|
+
},
|
|
218
599
|
): Promise<FlowPushData> {
|
|
219
600
|
// These two reads go through gitEvidence — a refused channel (transport
|
|
220
601
|
// lever or shape file in .git) throws here before the digest's own
|
|
@@ -241,12 +622,79 @@ export async function pushFlow(
|
|
|
241
622
|
// RFC-1501: a dry-run never fetches — `git fetch origin --prune` rewrites
|
|
242
623
|
// and prunes remote-tracking refs. It judges the digest exactly like
|
|
243
624
|
// `flow.digest --no-fetch`; a real push still fetches first.
|
|
244
|
-
|
|
625
|
+
// RFC-1638: a persisted reviewed digest attests in seconds when every
|
|
626
|
+
// cheap input still matches (`observeDigestInputs` re-reads through the
|
|
627
|
+
// judged channel — a verdict input, never bestEffort). Any drift, an
|
|
628
|
+
// unprovable input, or --recount falls back to the full recount — the
|
|
629
|
+
// FLOW-PUSH-02 contract byte-for-byte. A missing, unreadable or
|
|
630
|
+
// payload-forged persisted digest refuses FLOW-PUSH-15: no weaker check
|
|
631
|
+
// to silently downgrade to.
|
|
632
|
+
let digest: FlowDigestData | null = null;
|
|
633
|
+
let attestation: "input-hash" | "recount" = "recount";
|
|
634
|
+
let digestComputedAt: string | undefined;
|
|
635
|
+
// Attestation fields ride every refusal decided AFTER the digest loaded —
|
|
636
|
+
// the audit trail always records how the quoted digest was validated.
|
|
637
|
+
// RFC-1643: the baseline judgment rides every refusal decided after the
|
|
638
|
+
// verifier scan ran (FLOW-PUSH-03/06/07…), not only the stop itself.
|
|
639
|
+
const baselineDiags: Diagnostic[] = [];
|
|
640
|
+
let verifierReviewBaseline: FlowPushData["verifierReviewBaseline"];
|
|
641
|
+
const refuseChecked = (ruleId: string, message: string, fixHint?: string): FlowPushData => {
|
|
642
|
+
const base = refuse(ruleId, message, fixHint);
|
|
643
|
+
return {
|
|
644
|
+
...base,
|
|
645
|
+
attestation,
|
|
646
|
+
digestComputedAt,
|
|
647
|
+
...(verifierReviewBaseline !== undefined ? { verifierReviewBaseline } : {}),
|
|
648
|
+
diagnostics: [...base.diagnostics, ...baselineDiags],
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
if (!opts.recount) {
|
|
652
|
+
const persisted = await loadPersistedDigest(io, common, opts.digest);
|
|
653
|
+
if (persisted === "missing") {
|
|
654
|
+
return refuse(
|
|
655
|
+
"FLOW-PUSH-15",
|
|
656
|
+
`no persisted digest ${opts.digest} under .git/forge/digests — the quoted id predates persistence or the forge state was cleaned; re-run flow.digest to record a fresh reviewed state`,
|
|
657
|
+
"re-run flow.digest, review the new state and re-run flow.push --digest <id>",
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
if (persisted === "unknown") {
|
|
661
|
+
return refuse(
|
|
662
|
+
"FLOW-PUSH-15",
|
|
663
|
+
`the persisted digest ${opts.digest} is unreadable or carries an unknown schema — it cannot attest pushed state; re-run flow.digest to record a fresh reviewed state`,
|
|
664
|
+
"re-run flow.digest and re-run flow.push --digest <id>",
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
// Payload binding (RFC-1638 review round 1): the file is session-writable
|
|
668
|
+
// like the journal, but unlike a journal `push` record it MINTS the push
|
|
669
|
+
// payload — so the record must preimage the quoted id. Recomputing
|
|
670
|
+
// digestId from the file's own fields means a forged payload needs a
|
|
671
|
+
// 48-bit sha256 preimage, not a plausible-looking JSON.
|
|
672
|
+
if (
|
|
673
|
+
recomputePersistedDigestId(persisted) !== opts.digest ||
|
|
674
|
+
persisted.digest.digestId !== opts.digest
|
|
675
|
+
) {
|
|
676
|
+
return refuse(
|
|
677
|
+
"FLOW-PUSH-15",
|
|
678
|
+
`the persisted digest ${opts.digest} does not preimage the quoted id — the file is forged or corrupt; re-run flow.digest to record a fresh reviewed state`,
|
|
679
|
+
"re-run flow.digest, review the new state and re-run flow.push --digest <id>",
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
const inputs = await observeDigestInputs(repoRoot, io);
|
|
683
|
+
if (inputs !== null && digestInputHash(inputs) === persisted.inputHash) {
|
|
684
|
+
digest = persisted.digest;
|
|
685
|
+
attestation = "input-hash";
|
|
686
|
+
digestComputedAt = persisted.computedAt;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (digest === null) {
|
|
690
|
+
digest = await collectDigest(repoRoot, io, { fetch: !opts.dryRun, persist: !opts.dryRun });
|
|
691
|
+
digestComputedAt ??= new Date().toISOString();
|
|
692
|
+
}
|
|
245
693
|
const noOrigin = digest.diagnostics.find(
|
|
246
694
|
(d) => d.ruleId === "FLOW-PUSH-01" && d.severity === "error",
|
|
247
695
|
);
|
|
248
696
|
if (noOrigin !== undefined) {
|
|
249
|
-
return
|
|
697
|
+
return refuseChecked("FLOW-PUSH-01", noOrigin.message, "add an 'origin' remote first");
|
|
250
698
|
}
|
|
251
699
|
// Any other error-severity digest diagnostic blocks the push too — a
|
|
252
700
|
// remote identity that cannot be proven (FLOW-PUSH-09: url.insteadOf
|
|
@@ -256,7 +704,7 @@ export async function pushFlow(
|
|
|
256
704
|
const blocking = digest.diagnostics.filter((d) => d.severity === "error");
|
|
257
705
|
if (blocking.length > 0) {
|
|
258
706
|
const first = blocking[0]!;
|
|
259
|
-
return
|
|
707
|
+
return refuseChecked("FLOW-PUSH-10", first.message, first.fixHint);
|
|
260
708
|
}
|
|
261
709
|
// No remote-verification gate exists anymore: `fetched` is
|
|
262
710
|
// structurally false because the evidence channel refuses every
|
|
@@ -267,33 +715,35 @@ export async function pushFlow(
|
|
|
267
715
|
// (`remoteVerified` is never true), so nothing narrows the check on
|
|
268
716
|
// remote-derived state.
|
|
269
717
|
if (digest.digestId !== opts.digest) {
|
|
270
|
-
return
|
|
718
|
+
return refuseChecked(
|
|
271
719
|
"FLOW-PUSH-02",
|
|
272
720
|
`the digest is stale — the current digestId is ${digest.digestId}, not ${opts.digest}`,
|
|
273
721
|
`run flow.digest, review the new state and re-run flow.push --digest ${digest.digestId}`,
|
|
274
722
|
);
|
|
275
723
|
}
|
|
276
724
|
|
|
277
|
-
// RFC-1616 (AC-6): verifier-trailer scan over the
|
|
278
|
-
//
|
|
725
|
+
// RFC-1616 (AC-6): verifier-trailer scan over the develop+main branches.
|
|
726
|
+
// A commit carrying a verifier/audit trailer claims provenance the
|
|
279
727
|
// session cannot self-certify — the operator must see those commits before
|
|
280
728
|
// they leave the machine. `push.requireVerifierReview` defaults to true;
|
|
281
729
|
// an explicit `false` opts the repository out (itself a judged key).
|
|
282
|
-
//
|
|
283
|
-
//
|
|
730
|
+
// RFC-1643: both review keys are read from the COMMITTED forge.yaml at the
|
|
731
|
+
// digest-reviewed develop tip — never the worktree (CX-34) and never HEAD,
|
|
732
|
+
// which in a session worktree is an unintegrated branch. An unreadable or
|
|
284
733
|
// missing committed config defaults to required (fail closed).
|
|
285
|
-
|
|
734
|
+
const developTip = digest.develop.local;
|
|
735
|
+
let committed: CommittedForgeDoc;
|
|
286
736
|
try {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const doc = parseYaml(show.stdout) as Record<string, unknown> | null;
|
|
290
|
-
const v = (doc?.["push"] as Record<string, unknown> | undefined)?.["requireVerifierReview"];
|
|
291
|
-
declared = typeof v === "boolean" ? v : undefined;
|
|
292
|
-
}
|
|
737
|
+
committed =
|
|
738
|
+
developTip === "" ? { kind: "missing" } : await readCommittedForgeDoc(repoRoot, developTip);
|
|
293
739
|
} catch {
|
|
294
|
-
|
|
740
|
+
// A throwing channel is unverifiable — review stays required and the
|
|
741
|
+
// baseline exempts nothing (fail closed, as a diagnostic).
|
|
742
|
+
committed = { kind: "unverifiable" };
|
|
295
743
|
}
|
|
296
|
-
const
|
|
744
|
+
const declaredReview =
|
|
745
|
+
committed.kind === "doc" ? pushSection(committed.doc)?.["requireVerifierReview"] : undefined;
|
|
746
|
+
const requireVerifierReview = declaredReview !== false;
|
|
297
747
|
const scannedRanges: string[] = [];
|
|
298
748
|
const verifierTrailerCommits = new Map<string, { sha: string; trailers: string[] }>();
|
|
299
749
|
for (const [local, remote] of [
|
|
@@ -310,7 +760,7 @@ export async function pushFlow(
|
|
|
310
760
|
scannedRanges.push(range);
|
|
311
761
|
const scan = await scanVerifierTrailers(repoRoot, io, range);
|
|
312
762
|
if (scan === null) {
|
|
313
|
-
return
|
|
763
|
+
return refuseChecked(
|
|
314
764
|
"FLOW-PUSH-13",
|
|
315
765
|
`the verifier-trailer scan over '${range}' is unverifiable — the push cannot prove which commits carry verifier/audit trailers`,
|
|
316
766
|
"remove the evidence-channel refusal and re-run flow.push",
|
|
@@ -323,29 +773,132 @@ export async function pushFlow(
|
|
|
323
773
|
const trailerHits = [...verifierTrailerCommits.values()].sort((a, b) =>
|
|
324
774
|
a.sha.localeCompare(b.sha),
|
|
325
775
|
);
|
|
326
|
-
|
|
776
|
+
// RFC-1643: the committed review baseline — exemption is computed AFTER
|
|
777
|
+
// the full scan, so the scan (batched or per-commit) never narrows and
|
|
778
|
+
// `verifierTrailerCommits` keeps every hit.
|
|
779
|
+
const exempt = new Set<string>();
|
|
780
|
+
if (requireVerifierReview && trailerHits.length > 0) {
|
|
781
|
+
const baseline =
|
|
782
|
+
developTip === ""
|
|
783
|
+
? ({ status: "absent" } as const)
|
|
784
|
+
: await resolveVerifierReviewBaseline(repoRoot, developTip, committed);
|
|
785
|
+
let reason: VerifierReviewBaselineReason | undefined =
|
|
786
|
+
baseline.status === "unusable" ? baseline.reason : undefined;
|
|
787
|
+
const newlyExempted: string[] = [];
|
|
788
|
+
let bumpedBy: string | undefined;
|
|
789
|
+
let baselineChanges: BaselineChange[] = [];
|
|
790
|
+
if (baseline.status === "applied") {
|
|
791
|
+
// Positive membership: an under-reporting read can only shrink the
|
|
792
|
+
// exemption, never widen it.
|
|
793
|
+
const reviewed = await ancestrySet(repoRoot, baseline.sha);
|
|
794
|
+
if (reviewed === null) {
|
|
795
|
+
reason = "unverifiable";
|
|
796
|
+
} else {
|
|
797
|
+
for (const hit of trailerHits) {
|
|
798
|
+
// A pseudo-hit means the scan could not read the commit — it
|
|
799
|
+
// keeps blocking whatever its ancestry.
|
|
800
|
+
if (hit.trailers.some((t) => t.startsWith("x-unverifiable"))) continue;
|
|
801
|
+
if (reviewed.has(hit.sha) || (await isBaselineBumpRecord(repoRoot, hit, baseline.sha))) {
|
|
802
|
+
exempt.add(hit.sha);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (exempt.size > 0) {
|
|
806
|
+
const history = await baselineHistory(repoRoot, developTip);
|
|
807
|
+
baselineChanges = history?.changes ?? [];
|
|
808
|
+
bumpedBy = baselineChanges[0]?.commit;
|
|
809
|
+
const prev =
|
|
810
|
+
typeof history?.oldest === "string" && /^[0-9a-f]{40,64}$/.test(history.oldest)
|
|
811
|
+
? await ancestrySet(repoRoot, history.oldest)
|
|
812
|
+
: null;
|
|
813
|
+
for (const sha of exempt) if (prev === null || !prev.has(sha)) newlyExempted.push(sha);
|
|
814
|
+
newlyExempted.sort();
|
|
815
|
+
const changeLog =
|
|
816
|
+
history === undefined
|
|
817
|
+
? "baseline history unreadable"
|
|
818
|
+
: baselineChanges.length === 0
|
|
819
|
+
? `no value change in the last ${BASELINE_HISTORY_WINDOW} forge.yaml commits`
|
|
820
|
+
: baselineChanges
|
|
821
|
+
.map(
|
|
822
|
+
(c) => `${c.commit.slice(0, 9)}: ${c.from.slice(0, 9)}→${c.to.slice(0, 9)}`,
|
|
823
|
+
)
|
|
824
|
+
.join("; ");
|
|
825
|
+
baselineDiags.push({
|
|
826
|
+
ruleId: "FLOW-PUSH-17",
|
|
827
|
+
severity: "warning",
|
|
828
|
+
message:
|
|
829
|
+
`push.verifierReviewedThrough ${baseline.sha.slice(0, 9)} exempts ${exempt.size} ` +
|
|
830
|
+
`verifier/audit trailer commit(s) from the review stop (${newlyExempted.length} newly ` +
|
|
831
|
+
`exempted within the last ${BASELINE_HISTORY_WINDOW} forge.yaml commits; baseline changes: ${changeLog})`,
|
|
832
|
+
fixHint:
|
|
833
|
+
"confirm the baseline was moved by the operator after reviewing the listed commits (RFC-1643)",
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (reason !== undefined) {
|
|
839
|
+
const declared =
|
|
840
|
+
baseline.status === "unusable"
|
|
841
|
+
? baseline.declared
|
|
842
|
+
: baseline.status === "applied"
|
|
843
|
+
? baseline.sha
|
|
844
|
+
: "";
|
|
845
|
+
baselineDiags.push({
|
|
846
|
+
ruleId: "FLOW-PUSH-16",
|
|
847
|
+
severity: "warning",
|
|
848
|
+
message: `push.verifierReviewedThrough${declared ? ` '${declared}'` : ""} is unusable (${reason}) — it exempts no trailer commit`,
|
|
849
|
+
fixHint:
|
|
850
|
+
"set it to a full, quoted commit sha reachable from refs/heads/develop in the committed forge.yaml (RFC-1643)",
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
verifierReviewBaseline = {
|
|
854
|
+
status: reason !== undefined ? "unusable" : baseline.status,
|
|
855
|
+
...(baseline.status === "unusable" && baseline.declared
|
|
856
|
+
? { declared: baseline.declared }
|
|
857
|
+
: {}),
|
|
858
|
+
...(baseline.status === "applied" ? { declared: baseline.sha } : {}),
|
|
859
|
+
...(reason !== undefined ? { reason } : {}),
|
|
860
|
+
exempted: [...exempt].sort(),
|
|
861
|
+
newlyExempted,
|
|
862
|
+
...(bumpedBy !== undefined ? { bumpedBy } : {}),
|
|
863
|
+
changes: baselineChanges,
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
const blockingHits = trailerHits.filter((h) => !exempt.has(h.sha));
|
|
867
|
+
if (blockingHits.length > 0 && requireVerifierReview) {
|
|
327
868
|
if (!opts.acceptVerifierTrailers) {
|
|
328
869
|
return {
|
|
329
870
|
digestId: digest.digestId,
|
|
871
|
+
attestation,
|
|
872
|
+
digestComputedAt,
|
|
330
873
|
pushed: false,
|
|
331
874
|
refs: [],
|
|
332
875
|
publications: [],
|
|
333
876
|
superseded: [],
|
|
334
877
|
retired: [],
|
|
335
878
|
verifierTrailerCommits: trailerHits,
|
|
879
|
+
...(verifierReviewBaseline !== undefined ? { verifierReviewBaseline } : {}),
|
|
336
880
|
diagnostics: [
|
|
337
881
|
{
|
|
338
882
|
ruleId: "FLOW-PUSH-08",
|
|
339
883
|
severity: "error",
|
|
340
884
|
message:
|
|
341
|
-
`${
|
|
342
|
-
`(
|
|
343
|
-
`
|
|
885
|
+
`${blockingHits.length} commit(s) on the scanned local branches carry a verifier/audit trailer ` +
|
|
886
|
+
`(the scan covers the whole branch — tracking refs cannot prove what is already pushed, CX-82) ` +
|
|
887
|
+
`(${blockingHits.map((h) => `${h.sha.slice(0, 9)}[${h.trailers.join(",")}]`).join("; ")})` +
|
|
888
|
+
(exempt.size > 0
|
|
889
|
+
? ` — ${exempt.size} more exempted by push.verifierReviewedThrough`
|
|
890
|
+
: "") +
|
|
891
|
+
(verifierReviewBaseline?.status === "unusable"
|
|
892
|
+
? ` — push.verifierReviewedThrough is unusable (${verifierReviewBaseline.reason ?? "unverifiable"}) and exempts nothing`
|
|
893
|
+
: "") +
|
|
894
|
+
` — verifier evidence must be reviewed before it leaves the machine`,
|
|
344
895
|
fixHint:
|
|
345
896
|
"review the commits, then re-run with " +
|
|
346
|
-
'--accept-verifier-trailers "<reason>" — or
|
|
347
|
-
"
|
|
897
|
+
'--accept-verifier-trailers "<reason>" — or record the review as a committed ' +
|
|
898
|
+
"push.verifierReviewedThrough baseline (operator only, RFC-1643), or opt the " +
|
|
899
|
+
"repository out with push.requireVerifierReview: false in forge.yaml",
|
|
348
900
|
},
|
|
901
|
+
...baselineDiags,
|
|
349
902
|
],
|
|
350
903
|
};
|
|
351
904
|
}
|
|
@@ -356,9 +909,17 @@ export async function pushFlow(
|
|
|
356
909
|
["main", digest.main.remote],
|
|
357
910
|
] as const) {
|
|
358
911
|
if (remote === null) continue;
|
|
359
|
-
|
|
912
|
+
// RFC-1643: fully qualified — a shadow `refs/tags/<branch>` must not
|
|
913
|
+
// stand in for the local branch.
|
|
914
|
+
const ancestor = await gitEvidence(repoRoot, [
|
|
915
|
+
"merge-base",
|
|
916
|
+
"--is-ancestor",
|
|
917
|
+
remote,
|
|
918
|
+
`refs/heads/${branch}`,
|
|
919
|
+
]);
|
|
920
|
+
assertJudgedEvidence(ancestor);
|
|
360
921
|
if (ancestor.exitCode !== 0) {
|
|
361
|
-
return
|
|
922
|
+
return refuseChecked(
|
|
362
923
|
"FLOW-PUSH-03",
|
|
363
924
|
`origin/${branch} is not an ancestor of ${branch} — someone pushed elsewhere`,
|
|
364
925
|
"fetch, inspect the divergence and reconcile before pushing",
|
|
@@ -382,13 +943,27 @@ export async function pushFlow(
|
|
|
382
943
|
journalEvents.filter((e) => e.event === "publish-retired").map((e) => e.branch),
|
|
383
944
|
);
|
|
384
945
|
|
|
946
|
+
// RFC-1638: `push` records suppress tags at push-PLANNING time — the
|
|
947
|
+
// persisted digest's tags were suppressed at digest time, and records
|
|
948
|
+
// appended meanwhile must hide their tags here too. Suppression is
|
|
949
|
+
// monotonic (a record can only hide, R13-C), so re-filtering the digest's
|
|
950
|
+
// list is idempotent on the recount path.
|
|
951
|
+
const pushedNow = new Set<string>();
|
|
952
|
+
for (const e of journalEvents) {
|
|
953
|
+
if (e.event !== "push") continue;
|
|
954
|
+
for (const token of e.detail.split(/[^A-Za-z0-9._/@-]+/)) {
|
|
955
|
+
if (token.length > 0) pushedNow.add(token);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
const effectiveTags = digest.tags.filter((t) => !pushedNow.has(t));
|
|
959
|
+
|
|
385
960
|
const publicationTags = new Map<string, ReleaseLine>();
|
|
386
961
|
const addCandidate = (tag: string, lineId: string | null): void => {
|
|
387
962
|
const line =
|
|
388
963
|
(lineId === null ? null : lines.find((l) => l.id === lineId)) ?? lineForTag(lines, tag);
|
|
389
964
|
if (line !== null && line.id !== "repo") publicationTags.set(tag, line);
|
|
390
965
|
};
|
|
391
|
-
for (const tag of
|
|
966
|
+
for (const tag of effectiveTags) addCandidate(tag, null);
|
|
392
967
|
|
|
393
968
|
const baselineSkipped: PublicationRow[] = [];
|
|
394
969
|
const planCandidates: PublicationPlanEntry[] = [];
|
|
@@ -419,7 +994,7 @@ export async function pushFlow(
|
|
|
419
994
|
for (const { line } of publishable) {
|
|
420
995
|
const dir = line.paths[0]!;
|
|
421
996
|
if (!(await markerIsValid(join(primary, dir, "forge.generated.yaml"), io))) {
|
|
422
|
-
return
|
|
997
|
+
return refuseChecked(
|
|
423
998
|
"FLOW-PUSH-06",
|
|
424
999
|
`package line ${line.id} has no valid forge.generated.yaml in ${dir} — it must not be published`,
|
|
425
1000
|
"re-run flow.install to restore the marker, or remove the line's tags",
|
|
@@ -429,7 +1004,7 @@ export async function pushFlow(
|
|
|
429
1004
|
|
|
430
1005
|
const extractBin = join(primary, "node_modules", ".bin", "repo-extract");
|
|
431
1006
|
if (publishable.length > 0 && !(await io.exists(extractBin))) {
|
|
432
|
-
return
|
|
1007
|
+
return refuseChecked(
|
|
433
1008
|
"FLOW-PUSH-07",
|
|
434
1009
|
`${extractBin} is missing while ${publishable.length} tag(s) wait to publish`,
|
|
435
1010
|
"install the workspace dependencies so repo-extract is linked",
|
|
@@ -438,10 +1013,11 @@ export async function pushFlow(
|
|
|
438
1013
|
|
|
439
1014
|
// Sha-pinned refspecs — the push ships exactly the reviewed tips; a local
|
|
440
1015
|
// branch that moved since the digest stays local instead of sneaking in.
|
|
441
|
-
// Refspecs cover
|
|
442
|
-
// treat as publishable is pushed in the same atomic push — a
|
|
443
|
-
// journal `push` record can never make an unpushed tag look
|
|
444
|
-
|
|
1016
|
+
// Refspecs cover the effective tag set in full (R13-C): every tag this
|
|
1017
|
+
// run will treat as publishable is pushed in the same atomic push — a
|
|
1018
|
+
// fabricated journal `push` record can never make an unpushed tag look
|
|
1019
|
+
// remote.
|
|
1020
|
+
const pushedTagNames = effectiveTags;
|
|
445
1021
|
const refspecs = [
|
|
446
1022
|
`${digest.develop.local}:refs/heads/develop`,
|
|
447
1023
|
`${digest.main.local}:refs/heads/main`,
|
|
@@ -451,6 +1027,8 @@ export async function pushFlow(
|
|
|
451
1027
|
if (opts.dryRun) {
|
|
452
1028
|
return {
|
|
453
1029
|
digestId: digest.digestId,
|
|
1030
|
+
attestation,
|
|
1031
|
+
digestComputedAt,
|
|
454
1032
|
fetched: digest.fetched,
|
|
455
1033
|
pushed: false,
|
|
456
1034
|
refs: refspecs,
|
|
@@ -473,7 +1051,8 @@ export async function pushFlow(
|
|
|
473
1051
|
retired: [...retiredTags].sort((a, b) => a.localeCompare(b)),
|
|
474
1052
|
verifierTrailerCommits: trailerHits,
|
|
475
1053
|
verifierTrailersAccepted: opts.acceptVerifierTrailers,
|
|
476
|
-
|
|
1054
|
+
...(verifierReviewBaseline !== undefined ? { verifierReviewBaseline } : {}),
|
|
1055
|
+
diagnostics: [...digest.diagnostics, ...baselineDiags],
|
|
477
1056
|
};
|
|
478
1057
|
}
|
|
479
1058
|
|
|
@@ -490,6 +1069,8 @@ export async function pushFlow(
|
|
|
490
1069
|
if (push.exitCode !== 0) {
|
|
491
1070
|
return {
|
|
492
1071
|
digestId: digest.digestId,
|
|
1072
|
+
attestation,
|
|
1073
|
+
digestComputedAt,
|
|
493
1074
|
fetched: digest.fetched,
|
|
494
1075
|
pushed: false,
|
|
495
1076
|
refs: refspecs,
|
|
@@ -498,7 +1079,9 @@ export async function pushFlow(
|
|
|
498
1079
|
retired: [...retiredTags].sort((a, b) => a.localeCompare(b)),
|
|
499
1080
|
verifierTrailerCommits: trailerHits,
|
|
500
1081
|
verifierTrailersAccepted: opts.acceptVerifierTrailers,
|
|
1082
|
+
...(verifierReviewBaseline !== undefined ? { verifierReviewBaseline } : {}),
|
|
501
1083
|
diagnostics: [
|
|
1084
|
+
...baselineDiags,
|
|
502
1085
|
{
|
|
503
1086
|
ruleId: "FLOW-PUSH-04",
|
|
504
1087
|
severity: "error",
|
|
@@ -566,6 +1149,7 @@ export async function pushFlow(
|
|
|
566
1149
|
// was the invisible half of CX-63.
|
|
567
1150
|
const diagnostics: Diagnostic[] = [
|
|
568
1151
|
...digest.diagnostics,
|
|
1152
|
+
...baselineDiags,
|
|
569
1153
|
...journalWarnings.map((message): Diagnostic => ({
|
|
570
1154
|
ruleId: "FLOW-07",
|
|
571
1155
|
severity: "warning",
|
|
@@ -643,6 +1227,8 @@ export async function pushFlow(
|
|
|
643
1227
|
|
|
644
1228
|
return {
|
|
645
1229
|
digestId: digest.digestId,
|
|
1230
|
+
attestation,
|
|
1231
|
+
digestComputedAt,
|
|
646
1232
|
fetched: digest.fetched,
|
|
647
1233
|
pushed,
|
|
648
1234
|
refs: refspecs,
|
|
@@ -651,6 +1237,7 @@ export async function pushFlow(
|
|
|
651
1237
|
retired: [...freshRetired].sort((a, b) => a.localeCompare(b)),
|
|
652
1238
|
verifierTrailerCommits: trailerHits,
|
|
653
1239
|
verifierTrailersAccepted: opts.acceptVerifierTrailers,
|
|
1240
|
+
...(verifierReviewBaseline !== undefined ? { verifierReviewBaseline } : {}),
|
|
654
1241
|
diagnostics,
|
|
655
1242
|
};
|
|
656
1243
|
}
|
|
@@ -706,6 +1293,7 @@ export async function runFlowPush(
|
|
|
706
1293
|
digest: digestFlag,
|
|
707
1294
|
dryRun: input.flags["dry-run"] === true,
|
|
708
1295
|
acceptVerifierTrailers: acceptVerifierTrailers || undefined,
|
|
1296
|
+
recount: input.flags["recount"] === true,
|
|
709
1297
|
});
|
|
710
1298
|
} catch (error) {
|
|
711
1299
|
if (error instanceof FlowRegistrySchemaError) {
|