@warpgogol/forge 9.7.0 → 9.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -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/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 +5 -0
- package/dist/os/core/core.module.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/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-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/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +4 -2
- 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/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +3 -7
- package/dist/os/mission/handlers/archive.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/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/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/profiles/stack-profile.js +2 -2
- package/dist/src/types.js +2 -2
- 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/core/archive-regen.ts +33 -7
- package/os/core/core.module.ts +7 -0
- package/os/core/docs-archive.test.ts +25 -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/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-push.ts +725 -137
- package/os/flow/locks.ts +24 -7
- package/os/flow/preflight.ts +4 -2
- 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/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/mission/handlers/archive.ts +3 -11
- 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/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 +1 -1
- package/profiles/root-agents-system.md +82 -0
- package/profiles/system.yaml +1 -0
- package/src/config/forge-config.ts +16 -11
- package/src/onboarding/create-superfolder-guard.test.ts +73 -0
- package/src/onboarding/create.ts +28 -2
- 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/profile-flow-hooks.test.ts +1 -0
- package/src/tests/profile-schema.test.ts +1 -0
- package/src/tests/stack-profile.test.ts +1 -0
- package/src/types.ts +2 -2
- package/src/utils/verifier-git.ts +53 -5
package/dist/os/flow/digest.js
CHANGED
|
@@ -8,7 +8,7 @@ Journal records are suppressor-only (R13-C): they can hide a tag from
|
|
|
8
8
|
digest.tags but never mint pending/superseded publication entries, which
|
|
9
9
|
stay empty by construction.</purpose>
|
|
10
10
|
<non-goals>
|
|
11
|
-
<item>No mutation — the only write is the
|
|
11
|
+
<item>No git mutation — the only write is the RFC-1638 persisted digest record under .git/forge/digests/.</item>
|
|
12
12
|
<item>No push or publish policy — handlers/flow-push.ts owns outbound execution.</item>
|
|
13
13
|
</non-goals>
|
|
14
14
|
</MODULE_CONTRACT>
|
|
@@ -20,55 +20,11 @@ stay empty by construction.</purpose>
|
|
|
20
20
|
<item>tagTriggers feeds digestId — a workflow change between digest and push invalidates the quoted id; unparseable patterns warn never block.</item>
|
|
21
21
|
</KEY_DECISIONS>
|
|
22
22
|
<CHANGE_SUMMARY>
|
|
23
|
-
<item>RFC-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- remote.<name>.fetch is value-judged: only the clone-default
|
|
30
|
-
+?refs/heads/*:refs/remotes/<name>/* shape stays KEEP, because git
|
|
31
|
-
UNIONs configured refspecs with the pinned fetch argv and a session
|
|
32
|
-
spec writes arbitrary local refs inside the trusted fetch (CX-94).
|
|
33
|
-
remote.<name>.tagopt|promirror|followremotehead|prunetags|
|
|
34
|
-
skipfetchall|mirror move to REFUSE for the same reason.
|
|
35
|
-
- Alternates/shape comment lexing is col-0 `#` only — git's parser does
|
|
36
|
-
not treat whitespace-led `#` as a comment, so ` # forged` is a real
|
|
37
|
-
alternates path the shape check must count (CX-95).
|
|
38
|
-
- config reads forbid the alternate-source selectors --file/-f, --blob,
|
|
39
|
-
--worktree (reaches config.worktree even under the disabled-extension
|
|
40
|
-
pin), --system/--global, --default and --includes, plus the
|
|
41
|
-
write-action spellings, on both the evidence and shared read-only
|
|
42
|
-
tables (CX-96).
|
|
43
|
-
- verifierGit judges fabrication argv on the runner/policy channel:
|
|
44
|
-
@{...}, -g, --reflog, --walk-reflogs and --fork-point return
|
|
45
|
-
EVIDENCE-REFUSED before the spawn — policy.digest --base 'HEAD@{0}'
|
|
46
|
-
can no longer verify an unattested advance (CX-97).
|
|
47
|
-
- --use-bitmap-index/--test-bitmap are forbidden on rev-list/log in
|
|
48
|
-
both tables — the flag opts the trusted walk into the session-
|
|
49
|
-
writable pack bitmap cache the commitGraph/MIDX pins closed (CX-98).
|
|
50
|
-
- for-each-ref/show-ref/ls-remote forbid --stdin and --exclude-existing
|
|
51
|
-
on both tables — they block on input the no-stdin spawn never
|
|
52
|
-
supplies (CX-101).
|
|
53
|
-
- The workflow-adoption heredoc lexer is bash-faithful: openers are
|
|
54
|
-
scanned on the raw line before the # comment strip (quoted-#
|
|
55
|
-
delimiters, CX-99a), bare delimiters accept digits/./- (CX-99b), and
|
|
56
|
-
the terminator match is strict — << wants the delimiter alone, <<-/
|
|
57
|
-
<<~ skip leading tabs only (CX-100).
|
|
58
|
-
- Trailer scans read %e beside %(trailers): a commit declaring a
|
|
59
|
-
non-UTF-8 encoding header recodes every trusted message read, so the
|
|
60
|
-
digest trail and the push-time scan flag it as unverifiable and the
|
|
61
|
-
policy attestation scan skips it (CX-102).
|
|
62
|
-
|
|
63
|
-
Probe premise updates for the tightened contract: CX-61's decoy
|
|
64
|
-
remote.origin.fetch (cx4 and cx5 R5-R1) now asserts the wholesale
|
|
65
|
-
EVIDENCE-REFUSED plus FLOW-PUSH-13 refuse — strictly stronger than the
|
|
66
|
-
decoy-namespace guard it replaces. The independent r7 probe file and
|
|
67
|
-
acceptance report land in the follow-up port commit.</item>
|
|
68
|
-
<item>RFC-1616: close RFC-1616 r12 trust-boundary counterexamples</item>
|
|
69
|
-
<item>RFC-1616: close RFC-1616 r13 trust-boundary counterexamples</item>
|
|
70
|
-
<item>RFC-1616: close RFC-1616 r16 trust-boundary counterexamples</item>
|
|
71
|
-
<item>RFC-1616: close r20 counterexamples CX-173 through CX-177</item>
|
|
23
|
+
<item>RFC-1633: serialize evidence consults + bestEffort reader mode (RFC-1633)</item>
|
|
24
|
+
<item>RFC-1633: review round 1 — digest envInputs, package-wide bestEffort scan, holder command, serialized standalone preflight</item>
|
|
25
|
+
<item>RFC-1638: persist reviewed digests + attest pushed state by input hash</item>
|
|
26
|
+
<item>RFC-1638: review round 1 — payload preimage binding, fail-closed coverage scan, FLOW-PUSH-15</item>
|
|
27
|
+
<item>RFC-1643: committed verifier-review baseline for flow.push</item>
|
|
72
28
|
<history>RFC-1491, RFC-1498, RFC-1503, RFC-1580, RFC-1616</history>
|
|
73
29
|
</CHANGE_SUMMARY>
|
|
74
30
|
*/
|
|
@@ -78,7 +34,9 @@ import { parse as parseYaml } from "yaml";
|
|
|
78
34
|
import { listRfcFiles, readRfcFrontmatter, rfcFileMatchesId } from "../rfc/frontmatter-io.js";
|
|
79
35
|
import { EVIDENCE_REFUSED_PREFIX } from "../../src/utils/verifier-git.js";
|
|
80
36
|
import { git, gitEvidence, evidencePreflight, parseGitTrailers } from "./git.js";
|
|
81
|
-
import {
|
|
37
|
+
import { describeEvidenceLockError, withEvidenceConsultLock } from "./evidence-lock.js";
|
|
38
|
+
import { LockTimeoutError } from "./locks.js";
|
|
39
|
+
import { commonGitDir, JOURNAL_RELATIVE_PATH, readJournal, readRegistry, RISK_CATEGORIES, } from "./registry.js";
|
|
82
40
|
import { discoverReleaseLines } from "./release-lines.js";
|
|
83
41
|
import { parseVersion } from "./semver.js";
|
|
84
42
|
import { listLineTags } from "./release-tags.js";
|
|
@@ -320,7 +278,9 @@ async function rfcFacts(repoRoot, ids) {
|
|
|
320
278
|
}
|
|
321
279
|
/** `git show <ref>:<path>` → parsed JSON, null when absent/unparseable. */
|
|
322
280
|
async function jsonAtRef(repoRoot, io, ref, path) {
|
|
323
|
-
const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`]
|
|
281
|
+
const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`], {
|
|
282
|
+
mode: "bestEffort",
|
|
283
|
+
});
|
|
324
284
|
if (result.exitCode !== 0)
|
|
325
285
|
return null;
|
|
326
286
|
try {
|
|
@@ -383,7 +343,9 @@ async function classifyItem(repoRoot, io, base, tip, rfcs, specsDir, invariantsF
|
|
|
383
343
|
// files a later commit reverted). A refused names read must never
|
|
384
344
|
// degrade to files=[] — that silently narrows the classification
|
|
385
345
|
// (CX-155: a contract-touching item labelled "other").
|
|
386
|
-
const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip]
|
|
346
|
+
const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip], {
|
|
347
|
+
mode: "bestEffort",
|
|
348
|
+
});
|
|
387
349
|
const splitNames = (stdout) => stdout
|
|
388
350
|
.split("\n")
|
|
389
351
|
.map((l) => l.trim())
|
|
@@ -431,15 +393,9 @@ async function classifyItem(repoRoot, io, base, tip, rfcs, specsDir, invariantsF
|
|
|
431
393
|
// the scan tight. --no-textconv/--no-ext-diff: a repo-config filter must
|
|
432
394
|
// not rewrite what the diff reports (CX-50 class — config channels are
|
|
433
395
|
// scrubbed, this closes the repo-config half too).
|
|
434
|
-
const diff = await gitEvidence(repoRoot, [
|
|
435
|
-
"
|
|
436
|
-
|
|
437
|
-
"--no-color",
|
|
438
|
-
"--no-textconv",
|
|
439
|
-
"--no-ext-diff",
|
|
440
|
-
base,
|
|
441
|
-
tip,
|
|
442
|
-
]);
|
|
396
|
+
const diff = await gitEvidence(repoRoot, ["diff", "--unified=0", "--no-color", "--no-textconv", "--no-ext-diff", base, tip], {
|
|
397
|
+
mode: "bestEffort",
|
|
398
|
+
});
|
|
443
399
|
let diffOut = diff.exitCode === 0 ? diff.stdout : null;
|
|
444
400
|
if (diffOut === null) {
|
|
445
401
|
// Same refused-diff fallback as the names read — per-commit patches
|
|
@@ -666,13 +622,252 @@ function canonicalJson(value) {
|
|
|
666
622
|
}
|
|
667
623
|
return JSON.stringify(value);
|
|
668
624
|
}
|
|
625
|
+
// --- persisted digests (RFC-1638) -------------------------------------------
|
|
626
|
+
export const PERSISTED_DIGEST_SCHEMA = "forge/persisted-digest@1";
|
|
627
|
+
/** `.git/forge/` subdir carrying one persisted digest per file. */
|
|
628
|
+
export const PERSISTED_DIGESTS_DIR = "forge/digests";
|
|
629
|
+
/** gate-runs precedent (RFC-1568): the newest 50 persisted digests survive. */
|
|
630
|
+
const PERSISTED_DIGEST_RETENTION = 50;
|
|
631
|
+
/** sha256 over canonicalJson(DigestInputs) — full hex, internal attestation. */
|
|
632
|
+
export function digestInputHash(inputs) {
|
|
633
|
+
return createHash("sha256").update(canonicalJson(inputs)).digest("hex");
|
|
634
|
+
}
|
|
635
|
+
function computeDigestId(preimage) {
|
|
636
|
+
return createHash("sha256")
|
|
637
|
+
.update(canonicalJson({
|
|
638
|
+
develop: { local: preimage.developLocal },
|
|
639
|
+
main: { local: preimage.mainLocal },
|
|
640
|
+
releaseTags: preimage.releaseTags,
|
|
641
|
+
tagTriggers: preimage.tagTriggers,
|
|
642
|
+
correctnessTrail: preimage.correctnessTrail,
|
|
643
|
+
items: preimage.items.map((i) => ({ id: i.id, tip: i.tip })),
|
|
644
|
+
}))
|
|
645
|
+
.digest("hex")
|
|
646
|
+
.slice(0, 12);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Recompute the digestId a persisted record's own payload preimages —
|
|
650
|
+
* `null` when the record's fields cannot re-derive the preimage. A forged
|
|
651
|
+
* `.git/forge/digests/*.json` (session-writable) then needs a 48-bit
|
|
652
|
+
* sha256 preimage to move a push, not just a plausible-looking file.
|
|
653
|
+
*/
|
|
654
|
+
export function recomputePersistedDigestId(persisted) {
|
|
655
|
+
const d = persisted.digest;
|
|
656
|
+
if (typeof d.develop?.local !== "string" ||
|
|
657
|
+
typeof d.main?.local !== "string" ||
|
|
658
|
+
!Array.isArray(d.tagTriggers) ||
|
|
659
|
+
!Array.isArray(d.items) ||
|
|
660
|
+
!Array.isArray(persisted.releaseTags)) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
return computeDigestId({
|
|
664
|
+
developLocal: d.develop.local,
|
|
665
|
+
mainLocal: d.main.local,
|
|
666
|
+
releaseTags: persisted.releaseTags,
|
|
667
|
+
tagTriggers: d.tagTriggers,
|
|
668
|
+
correctnessTrail: d.correctnessTrail,
|
|
669
|
+
items: d.items.map((i) => ({ id: i.id, tip: i.tip })),
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
/** Every reachable release-line tag (unsuppressed), sorted — the set both
|
|
673
|
+
* digestId and DigestInputs cover; the journal `push` suppression applies
|
|
674
|
+
* only to the display/push-planning view (RFC-1638 decision 2). */
|
|
675
|
+
async function releaseTagSet(repoRoot, io, lines) {
|
|
676
|
+
const set = new Set();
|
|
677
|
+
for (const line of lines) {
|
|
678
|
+
const { reachable } = await listLineTags(repoRoot, line, io);
|
|
679
|
+
for (const tag of reachable)
|
|
680
|
+
set.add(tag);
|
|
681
|
+
}
|
|
682
|
+
return [...set].sort((a, b) => a.localeCompare(b));
|
|
683
|
+
}
|
|
684
|
+
/** sha256 over every `.github/workflows/*.y{ml,aml}` name + content on `dir` —
|
|
685
|
+
* the same file set workflowTagPatterns parses (RFC-1498 read surface). */
|
|
686
|
+
async function workflowFilesSha256(dir, io) {
|
|
687
|
+
const hash = createHash("sha256");
|
|
688
|
+
if (!(await io.exists(dir)))
|
|
689
|
+
return hash.digest("hex");
|
|
690
|
+
const entries = await io
|
|
691
|
+
.readdir(dir)
|
|
692
|
+
.catch(() => []);
|
|
693
|
+
const names = entries
|
|
694
|
+
.filter((e) => e.isFile && /\.ya?ml$/.test(e.name))
|
|
695
|
+
.map((e) => e.name)
|
|
696
|
+
.sort();
|
|
697
|
+
for (const name of names) {
|
|
698
|
+
const text = await io.readFile(join(dir, name)).catch(() => null);
|
|
699
|
+
hash.update(name);
|
|
700
|
+
hash.update("\0");
|
|
701
|
+
hash.update(text ?? "<unreadable>");
|
|
702
|
+
hash.update("\0");
|
|
703
|
+
}
|
|
704
|
+
return hash.digest("hex");
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Re-observe every cheap digest input through the judged channel (RFC-1638:
|
|
708
|
+
* attestation feeds a refusal decision — a verdict input, never bestEffort).
|
|
709
|
+
* `null` means some input is unprovable — the caller falls back to recount.
|
|
710
|
+
*/
|
|
711
|
+
export async function observeDigestInputs(repoRoot, io) {
|
|
712
|
+
try {
|
|
713
|
+
const urlSet = async (args) => {
|
|
714
|
+
const r = await gitEvidence(repoRoot, args);
|
|
715
|
+
if (r.exitCode === -1)
|
|
716
|
+
throw new Error(r.stderr);
|
|
717
|
+
return r.exitCode === 0 ? r.stdout : "";
|
|
718
|
+
};
|
|
719
|
+
const [head, developLocal, mainLocal, developRemote, mainRemote] = await Promise.all([
|
|
720
|
+
revParse(repoRoot, io, "HEAD"),
|
|
721
|
+
// RFC-1643: fully qualified — a shadow `refs/tags/develop` or
|
|
722
|
+
// `refs/develop` wins a bare-name lookup and would plant the tip.
|
|
723
|
+
revParse(repoRoot, io, "refs/heads/develop"),
|
|
724
|
+
revParse(repoRoot, io, "refs/heads/main"),
|
|
725
|
+
revParse(repoRoot, io, "refs/remotes/origin/develop"),
|
|
726
|
+
revParse(repoRoot, io, "refs/remotes/origin/main"),
|
|
727
|
+
]);
|
|
728
|
+
const remoteConfigSha256 = createHash("sha256")
|
|
729
|
+
.update(canonicalJson({
|
|
730
|
+
configured: await urlSet(["config", "--get-all", "remote.origin.url"]),
|
|
731
|
+
fetch: await urlSet(["remote", "get-url", "--all", "origin"]),
|
|
732
|
+
push: await urlSet(["remote", "get-url", "--push", "--all", "origin"]),
|
|
733
|
+
}))
|
|
734
|
+
.digest("hex");
|
|
735
|
+
const { lines } = await discoverReleaseLines(repoRoot, io);
|
|
736
|
+
const releaseTags = await releaseTagSet(repoRoot, io, lines);
|
|
737
|
+
const common = await commonGitDir(io, repoRoot);
|
|
738
|
+
let primary = repoRoot;
|
|
739
|
+
try {
|
|
740
|
+
primary = await primaryWorktree(io, repoRoot);
|
|
741
|
+
}
|
|
742
|
+
catch {
|
|
743
|
+
primary = repoRoot;
|
|
744
|
+
}
|
|
745
|
+
const journalBytes = (await io.exists(join(common, JOURNAL_RELATIVE_PATH)))
|
|
746
|
+
? await io.readFile(join(common, JOURNAL_RELATIVE_PATH))
|
|
747
|
+
: "";
|
|
748
|
+
const journalTailSha256 = createHash("sha256").update(journalBytes).digest("hex");
|
|
749
|
+
const sessions = (await readRegistry(io, common)).branches
|
|
750
|
+
.map((b) => b.name)
|
|
751
|
+
.sort((a, b) => a.localeCompare(b));
|
|
752
|
+
const repoStatus = await gitEvidence(repoRoot, ["status", "--porcelain=v1", "-z"]);
|
|
753
|
+
const primaryStatus = primary === repoRoot
|
|
754
|
+
? repoStatus
|
|
755
|
+
: await gitEvidence(primary, ["status", "--porcelain=v1", "-z"]);
|
|
756
|
+
// A refused status consult cannot prove worktree state — attestation is
|
|
757
|
+
// a verdict input, so the observation itself is unprovable (CX-174).
|
|
758
|
+
if (repoStatus.exitCode !== 0 || primaryStatus.exitCode !== 0)
|
|
759
|
+
return null;
|
|
760
|
+
return {
|
|
761
|
+
head,
|
|
762
|
+
developLocal,
|
|
763
|
+
mainLocal,
|
|
764
|
+
developRemote,
|
|
765
|
+
mainRemote,
|
|
766
|
+
remoteConfigSha256,
|
|
767
|
+
releaseTags,
|
|
768
|
+
tagTriggerFilesSha256: await workflowFilesSha256(join(primary, WORKFLOWS_DIR), io),
|
|
769
|
+
journalTailSha256,
|
|
770
|
+
sessions,
|
|
771
|
+
statusPorcelainSha256: createHash("sha256")
|
|
772
|
+
.update(canonicalJson({ repo: repoStatus.stdout, primary: primaryStatus.stdout }))
|
|
773
|
+
.digest("hex"),
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
catch {
|
|
777
|
+
return null;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Load `.git/forge/digests/<digestId>.json`. "missing" names an absent file;
|
|
782
|
+
* "unknown" names an unreadable or wrong-schema record — both refuse
|
|
783
|
+
* FLOW-PUSH-15 upstream, never silently downgrade (RFC-1638).
|
|
784
|
+
*/
|
|
785
|
+
export async function loadPersistedDigest(io, common, digestId) {
|
|
786
|
+
// The id becomes a path segment — a crafted `--digest ../…` must not walk
|
|
787
|
+
// out of the digests dir.
|
|
788
|
+
if (!/^[a-z0-9-]{1,80}$/.test(digestId))
|
|
789
|
+
return "unknown";
|
|
790
|
+
const file = join(common, PERSISTED_DIGESTS_DIR, `${digestId}.json`);
|
|
791
|
+
if (!(await io.exists(file)))
|
|
792
|
+
return "missing";
|
|
793
|
+
let raw;
|
|
794
|
+
try {
|
|
795
|
+
raw = JSON.parse(await io.readFile(file));
|
|
796
|
+
}
|
|
797
|
+
catch {
|
|
798
|
+
return "unknown";
|
|
799
|
+
}
|
|
800
|
+
const rec = raw;
|
|
801
|
+
const d = rec?.digest;
|
|
802
|
+
if (rec === null ||
|
|
803
|
+
rec.schema !== PERSISTED_DIGEST_SCHEMA ||
|
|
804
|
+
rec.digestId !== digestId ||
|
|
805
|
+
typeof rec.inputHash !== "string" ||
|
|
806
|
+
typeof rec.computedAt !== "string" ||
|
|
807
|
+
!Array.isArray(rec.releaseTags) ||
|
|
808
|
+
!rec.releaseTags.every((t) => typeof t === "string") ||
|
|
809
|
+
typeof d !== "object" ||
|
|
810
|
+
d === null ||
|
|
811
|
+
typeof d.digestId !== "string" ||
|
|
812
|
+
!Array.isArray(d.diagnostics) ||
|
|
813
|
+
typeof d.develop?.local !== "string" ||
|
|
814
|
+
typeof d.main?.local !== "string" ||
|
|
815
|
+
!Array.isArray(d.items) ||
|
|
816
|
+
!Array.isArray(d.tagTriggers)) {
|
|
817
|
+
return "unknown";
|
|
818
|
+
}
|
|
819
|
+
return rec;
|
|
820
|
+
}
|
|
821
|
+
/** Write the persisted digest atomically (tmp + rename) and sweep to the
|
|
822
|
+
* 50-newest retention (RFC-1568 precedent); `.tmp-<pid>` orphans of a dead
|
|
823
|
+
* writer older than a minute are reclaimed in the same pass. */
|
|
824
|
+
async function persistDigest(io, common, persisted) {
|
|
825
|
+
const dir = join(common, PERSISTED_DIGESTS_DIR);
|
|
826
|
+
await io.mkdir(dir);
|
|
827
|
+
const file = join(dir, `${persisted.digestId}.json`);
|
|
828
|
+
const tmp = `${file}.tmp-${process.pid}`;
|
|
829
|
+
await io.writeFile(tmp, `${JSON.stringify(persisted, null, 2)}\n`);
|
|
830
|
+
await io.rename(tmp, file);
|
|
831
|
+
const entries = await io
|
|
832
|
+
.readdir(dir)
|
|
833
|
+
.catch(() => []);
|
|
834
|
+
const names = entries.filter((e) => e.isFile).map((e) => e.name);
|
|
835
|
+
const orphans = names.filter((n) => n.endsWith(".json") === false && n.includes(".tmp-"));
|
|
836
|
+
const digests = names.filter((n) => n.endsWith(".json") && !n.includes(".tmp-"));
|
|
837
|
+
const now = Date.now();
|
|
838
|
+
for (const n of orphans) {
|
|
839
|
+
const t = await io
|
|
840
|
+
.stat(join(dir, n))
|
|
841
|
+
.then((s) => s.mtimeMs)
|
|
842
|
+
.catch(() => 0);
|
|
843
|
+
if (now - t > 60_000)
|
|
844
|
+
await io.rm(join(dir, n)).catch(() => { });
|
|
845
|
+
}
|
|
846
|
+
if (digests.length <= PERSISTED_DIGEST_RETENTION)
|
|
847
|
+
return;
|
|
848
|
+
const aged = await Promise.all(digests.map(async (n) => ({
|
|
849
|
+
n,
|
|
850
|
+
t: await io
|
|
851
|
+
.stat(join(dir, n))
|
|
852
|
+
.then((s) => s.mtimeMs)
|
|
853
|
+
.catch(() => 0),
|
|
854
|
+
})));
|
|
855
|
+
const keep = new Set(aged
|
|
856
|
+
.sort((a, b) => b.t - a.t)
|
|
857
|
+
.slice(0, PERSISTED_DIGEST_RETENTION)
|
|
858
|
+
.map((e) => e.n));
|
|
859
|
+
for (const n of digests) {
|
|
860
|
+
if (!keep.has(n))
|
|
861
|
+
await io.rm(join(dir, n)).catch(() => { });
|
|
862
|
+
}
|
|
863
|
+
}
|
|
669
864
|
/**
|
|
670
865
|
* Collect the outbound digest of repoRoot. The `fetch` flag is retained for
|
|
671
866
|
* call-site compatibility but is inert — the trusted channel refuses every
|
|
672
867
|
* transport (CX-132), so a digest never contacts a remote and `fetched` is
|
|
673
868
|
* structurally false.
|
|
674
869
|
*/
|
|
675
|
-
export async function collectDigest(repoRoot, io,
|
|
870
|
+
export async function collectDigest(repoRoot, io, opts) {
|
|
676
871
|
const diagnostics = [];
|
|
677
872
|
// --- trust-boundary preflight ------------------------------------------
|
|
678
873
|
// The evidence channel refuses when the session-writable repo surface
|
|
@@ -681,8 +876,32 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
681
876
|
// read resolves (CX-79). Emitting the reasons here keeps the digest's
|
|
682
877
|
// diagnostics honest instead of cascading "no origin"/"fetch failed"
|
|
683
878
|
// secondaries on top of the refused channel.
|
|
684
|
-
|
|
685
|
-
|
|
879
|
+
// RFC-1633 (review DEV-4): the standalone surface preflight is itself a
|
|
880
|
+
// heavy judged reader (~47k openat on this repo) — it serializes on the
|
|
881
|
+
// consult lock like every other judged read, so a parallel digest's
|
|
882
|
+
// fingerprint capture cannot interleave mid-sweep.
|
|
883
|
+
let preflight;
|
|
884
|
+
try {
|
|
885
|
+
preflight = await withEvidenceConsultLock(repoRoot, { command: "flow.digest preflight" }, () =>
|
|
886
|
+
// RFC-1644: diagnostic-only — read for refusedKeys/shapeViolations,
|
|
887
|
+
// never armed against, so the worktree baseline is skipped.
|
|
888
|
+
evidencePreflight(repoRoot, undefined, { worktreeSurface: "skip" }));
|
|
889
|
+
}
|
|
890
|
+
catch (error) {
|
|
891
|
+
if (error instanceof LockTimeoutError) {
|
|
892
|
+
diagnostics.push({
|
|
893
|
+
ruleId: "FLOW-PUSH-13",
|
|
894
|
+
severity: "error",
|
|
895
|
+
message: await describeEvidenceLockError(repoRoot, error),
|
|
896
|
+
fixHint: `a parallel judged consult held the evidence lock past the wait budget — re-run flow.digest`,
|
|
897
|
+
});
|
|
898
|
+
preflight = null;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
throw error;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
if (preflight === null && !diagnostics.some((d) => d.ruleId === "FLOW-PUSH-13")) {
|
|
686
905
|
diagnostics.push({
|
|
687
906
|
ruleId: "FLOW-PUSH-13",
|
|
688
907
|
severity: "error",
|
|
@@ -849,8 +1068,11 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
849
1068
|
// false and the verifier-trailer scan always covers the full local
|
|
850
1069
|
// branch — the strictly stronger judgment.
|
|
851
1070
|
const fetched = false;
|
|
852
|
-
|
|
853
|
-
|
|
1071
|
+
// RFC-1643: branch tips resolve fully qualified — git's bare-name order
|
|
1072
|
+
// (`refs/<name>`, `refs/tags/<name>`, then `refs/heads/<name>`) lets a
|
|
1073
|
+
// shadow ref plant an unintegrated commit as the reviewed tip.
|
|
1074
|
+
const developLocal = await revParse(repoRoot, io, "refs/heads/develop");
|
|
1075
|
+
const mainLocal = await revParse(repoRoot, io, "refs/heads/main");
|
|
854
1076
|
// The "remote" tips are always the session-mutable tracking refs —
|
|
855
1077
|
// verified remote tips cannot exist (CX-132). A planted
|
|
856
1078
|
// `refs/remotes/origin/*` can hide commits from the tail exactly like
|
|
@@ -864,15 +1086,17 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
864
1086
|
// keeps the tracking-ref-relative view.
|
|
865
1087
|
const developTailRead = developLocal === null
|
|
866
1088
|
? []
|
|
867
|
-
: await unpushedCommits(repoRoot, io,
|
|
868
|
-
const mainTailRead = mainLocal === null
|
|
1089
|
+
: await unpushedCommits(repoRoot, io, developLocal, developRemote, false, null);
|
|
1090
|
+
const mainTailRead = mainLocal === null
|
|
1091
|
+
? []
|
|
1092
|
+
: await unpushedCommits(repoRoot, io, mainLocal, mainRemote, false, null);
|
|
869
1093
|
// --- items: journal-attributed segments of the develop tail ---------------
|
|
870
1094
|
// Segments follow develop's first-parent chain: a back-merge brings main's
|
|
871
1095
|
// commits in through its second parent, and a fix cut's range lives on
|
|
872
1096
|
// main — index spans over the full (date-ordered) list would misattribute.
|
|
873
1097
|
const developChainRead = developLocal === null
|
|
874
1098
|
? []
|
|
875
|
-
: await unpushedCommits(repoRoot, io,
|
|
1099
|
+
: await unpushedCommits(repoRoot, io, developLocal, developRemote, true, null);
|
|
876
1100
|
// A null tail/chain means the enumeration itself is unverifiable —
|
|
877
1101
|
// degrading to [] would run the verifier trailer scan over NOTHING
|
|
878
1102
|
// (CX-174). Fail the digest as unverifiable; the lists stay empty so
|
|
@@ -989,15 +1213,13 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
989
1213
|
// corroborated into one (R13-C) — flow.push publishes only what this
|
|
990
1214
|
// run itself pushes.
|
|
991
1215
|
const { lines } = await discoverReleaseLines(repoRoot, io);
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
}
|
|
1000
|
-
tags.sort((a, b) => a.localeCompare(b));
|
|
1216
|
+
// RFC-1638 decision 2: the hashed set is the UNSUPPRESSED reachable set —
|
|
1217
|
+
// `pushedTags` suppression derives from journal `push` records, and a
|
|
1218
|
+
// foreign push record must not move digestId. The display/push view keeps
|
|
1219
|
+
// the suppression; flow.push re-applies it from the journal at planning
|
|
1220
|
+
// time so records appended after the digest still hide their tags.
|
|
1221
|
+
const releaseTags = await releaseTagSet(repoRoot, io, lines);
|
|
1222
|
+
const tags = releaseTags.filter((t) => !pushedTags.has(t));
|
|
1001
1223
|
const pendingPublications = [];
|
|
1002
1224
|
const supersededPublications = [];
|
|
1003
1225
|
// --- CI workflows a tag push would trigger (RFC-1498) --------------------
|
|
@@ -1012,7 +1234,9 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
1012
1234
|
}
|
|
1013
1235
|
const tagPatterns = await workflowTagPatterns(join(primary, WORKFLOWS_DIR), io, diagnostics);
|
|
1014
1236
|
const tagTriggers = [];
|
|
1015
|
-
|
|
1237
|
+
// Triggers compute over the unsuppressed set — a journal `push` record
|
|
1238
|
+
// hiding a tag must not shrink the hashed trigger surface (RFC-1638).
|
|
1239
|
+
for (const tag of releaseTags) {
|
|
1016
1240
|
const workflows = tagPatterns
|
|
1017
1241
|
.filter((w) => w.patterns.some((p) => tagPatternRegex(p)?.test(tag) === true))
|
|
1018
1242
|
.map((w) => w.file);
|
|
@@ -1023,20 +1247,22 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
1023
1247
|
const byCategory = Object.fromEntries(RISK_CATEGORIES.map((c) => [c, []]));
|
|
1024
1248
|
for (const item of items)
|
|
1025
1249
|
byCategory[item.category].push(item.id);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1250
|
+
// RFC-1638 decision 2: the hashed contract covers judgment inputs only —
|
|
1251
|
+
// local branch tips, the unsuppressed release-tag set, triggers, the
|
|
1252
|
+
// correctness trail and the item tips. `*.remote` (session-mutable
|
|
1253
|
+
// tracking refs), the derived `ahead` counts and the display-only
|
|
1254
|
+
// publication fields stay in the returned object as preview data but
|
|
1255
|
+
// leave the hash: a foreign push or journal `push` record can no longer
|
|
1256
|
+
// move a digest the operator already reviewed.
|
|
1257
|
+
const digestId = computeDigestId({
|
|
1258
|
+
developLocal,
|
|
1259
|
+
mainLocal,
|
|
1260
|
+
releaseTags,
|
|
1031
1261
|
tagTriggers,
|
|
1032
1262
|
correctnessTrail,
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
}))
|
|
1037
|
-
.digest("hex")
|
|
1038
|
-
.slice(0, 12);
|
|
1039
|
-
return {
|
|
1263
|
+
items,
|
|
1264
|
+
});
|
|
1265
|
+
const data = {
|
|
1040
1266
|
digestId,
|
|
1041
1267
|
remote: "origin",
|
|
1042
1268
|
fetched,
|
|
@@ -1053,5 +1279,31 @@ export async function collectDigest(repoRoot, io, _opts) {
|
|
|
1053
1279
|
correctnessTrail,
|
|
1054
1280
|
diagnostics,
|
|
1055
1281
|
};
|
|
1282
|
+
// RFC-1638 persist — the reviewed digest + its input hash, so flow.push
|
|
1283
|
+
// attests staleness in seconds instead of recounting. Best-effort: a
|
|
1284
|
+
// failed persist degrades to the recount path (FLOW-PUSH-15 upstream),
|
|
1285
|
+
// never blocks the digest itself. `persist:false` (dry-run callers)
|
|
1286
|
+
// leaves the digests dir untouched.
|
|
1287
|
+
try {
|
|
1288
|
+
const inputs = opts?.persist === false ? null : await observeDigestInputs(repoRoot, io);
|
|
1289
|
+
if (inputs !== null) {
|
|
1290
|
+
await persistDigest(io, common, {
|
|
1291
|
+
schema: PERSISTED_DIGEST_SCHEMA,
|
|
1292
|
+
digestId,
|
|
1293
|
+
inputHash: digestInputHash(inputs),
|
|
1294
|
+
computedAt: new Date().toISOString(),
|
|
1295
|
+
releaseTags,
|
|
1296
|
+
digest: data,
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
catch (error) {
|
|
1301
|
+
diagnostics.push({
|
|
1302
|
+
ruleId: "FLOW-DIGEST-01",
|
|
1303
|
+
severity: "warning",
|
|
1304
|
+
message: `the persisted digest could not be written — flow.push will recount instead of attesting: ${error instanceof Error ? error.message : String(error)}`,
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
return data;
|
|
1056
1308
|
}
|
|
1057
1309
|
//# sourceMappingURL=digest.js.map
|