@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/os/flow/digest.ts
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
|
*/
|
|
@@ -80,10 +36,13 @@ import { parse as parseYaml } from "yaml";
|
|
|
80
36
|
|
|
81
37
|
import { listRfcFiles, readRfcFrontmatter, rfcFileMatchesId } from "../rfc/frontmatter-io.ts";
|
|
82
38
|
import type { Diagnostic, WorkspaceIO } from "../../src/types.ts";
|
|
83
|
-
import { EVIDENCE_REFUSED_PREFIX } from "../../src/utils/verifier-git.ts";
|
|
39
|
+
import { EVIDENCE_REFUSED_PREFIX, type EvidencePreflight } from "../../src/utils/verifier-git.ts";
|
|
84
40
|
import { git, gitEvidence, evidencePreflight, parseGitTrailers } from "./git.ts";
|
|
41
|
+
import { describeEvidenceLockError, withEvidenceConsultLock } from "./evidence-lock.ts";
|
|
42
|
+
import { LockTimeoutError } from "./locks.ts";
|
|
85
43
|
import {
|
|
86
44
|
commonGitDir,
|
|
45
|
+
JOURNAL_RELATIVE_PATH,
|
|
87
46
|
readJournal,
|
|
88
47
|
readRegistry,
|
|
89
48
|
RISK_CATEGORIES,
|
|
@@ -448,7 +407,9 @@ async function jsonAtRef(
|
|
|
448
407
|
ref: string,
|
|
449
408
|
path: string,
|
|
450
409
|
): Promise<Record<string, unknown> | null> {
|
|
451
|
-
const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`]
|
|
410
|
+
const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`], {
|
|
411
|
+
mode: "bestEffort",
|
|
412
|
+
});
|
|
452
413
|
if (result.exitCode !== 0) return null;
|
|
453
414
|
try {
|
|
454
415
|
const parsed = JSON.parse(result.stdout) as unknown;
|
|
@@ -531,7 +492,9 @@ async function classifyItem(
|
|
|
531
492
|
// files a later commit reverted). A refused names read must never
|
|
532
493
|
// degrade to files=[] — that silently narrows the classification
|
|
533
494
|
// (CX-155: a contract-touching item labelled "other").
|
|
534
|
-
const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip]
|
|
495
|
+
const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip], {
|
|
496
|
+
mode: "bestEffort",
|
|
497
|
+
});
|
|
535
498
|
const splitNames = (stdout: string) =>
|
|
536
499
|
stdout
|
|
537
500
|
.split("\n")
|
|
@@ -583,15 +546,13 @@ async function classifyItem(
|
|
|
583
546
|
// the scan tight. --no-textconv/--no-ext-diff: a repo-config filter must
|
|
584
547
|
// not rewrite what the diff reports (CX-50 class — config channels are
|
|
585
548
|
// scrubbed, this closes the repo-config half too).
|
|
586
|
-
const diff = await gitEvidence(
|
|
587
|
-
|
|
588
|
-
"--unified=0",
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
tip,
|
|
594
|
-
]);
|
|
549
|
+
const diff = await gitEvidence(
|
|
550
|
+
repoRoot,
|
|
551
|
+
["diff", "--unified=0", "--no-color", "--no-textconv", "--no-ext-diff", base, tip],
|
|
552
|
+
{
|
|
553
|
+
mode: "bestEffort",
|
|
554
|
+
},
|
|
555
|
+
);
|
|
595
556
|
let diffOut: string | null = diff.exitCode === 0 ? diff.stdout : null;
|
|
596
557
|
if (diffOut === null) {
|
|
597
558
|
// Same refused-diff fallback as the names read — per-commit patches
|
|
@@ -819,6 +780,330 @@ function canonicalJson(value: unknown): string {
|
|
|
819
780
|
return JSON.stringify(value);
|
|
820
781
|
}
|
|
821
782
|
|
|
783
|
+
// --- persisted digests (RFC-1638) -------------------------------------------
|
|
784
|
+
|
|
785
|
+
export const PERSISTED_DIGEST_SCHEMA = "forge/persisted-digest@1";
|
|
786
|
+
/** `.git/forge/` subdir carrying one persisted digest per file. */
|
|
787
|
+
export const PERSISTED_DIGESTS_DIR = "forge/digests";
|
|
788
|
+
/** gate-runs precedent (RFC-1568): the newest 50 persisted digests survive. */
|
|
789
|
+
const PERSISTED_DIGEST_RETENTION = 50;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Every input the digest reads that is cheap to re-observe (RFC-1638). The
|
|
793
|
+
* mapping is the exhaustiveness contract — a collector read that maps to no
|
|
794
|
+
* field is a false-negative hole (a stale digest attesting clean); the reads
|
|
795
|
+
* → inputs table lives in the RFC and the coverage assertion in
|
|
796
|
+
* os/flow/tests/digest-persist.test.ts.
|
|
797
|
+
*/
|
|
798
|
+
export interface DigestInputs {
|
|
799
|
+
/** HEAD position — pins every `git show HEAD:*` and HEAD-anchored tag read. */
|
|
800
|
+
head: string | null;
|
|
801
|
+
developLocal: string | null;
|
|
802
|
+
mainLocal: string | null;
|
|
803
|
+
/** Drift detection only — excluded from digestId (decision 2, CX-82). */
|
|
804
|
+
developRemote: string | null;
|
|
805
|
+
mainRemote: string | null;
|
|
806
|
+
/**
|
|
807
|
+
* sha256 over the remote-identity consults (configured/fetch/push url
|
|
808
|
+
* sets) — `.git/config` is outside every other input's coverage.
|
|
809
|
+
*/
|
|
810
|
+
remoteConfigSha256: string;
|
|
811
|
+
/** All reachable release-line tags — the unsuppressed set. */
|
|
812
|
+
releaseTags: string[];
|
|
813
|
+
/** sha256 over `.github/workflows` file names + bytes on the primary checkout. */
|
|
814
|
+
tagTriggerFilesSha256: string;
|
|
815
|
+
/** sha256 over the whole journal file — catches record appends and rewrites. */
|
|
816
|
+
journalTailSha256: string;
|
|
817
|
+
/** Registered branch set, sorted. */
|
|
818
|
+
sessions: string[];
|
|
819
|
+
/** sha256 over `git status --porcelain=v1 -z` on the calling worktree and the primary. */
|
|
820
|
+
statusPorcelainSha256: string;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** `.git/forge/digests/<digestId>.json` — the reviewed digest plus the input hash that attests it (RFC-1638). */
|
|
824
|
+
export interface PersistedDigest {
|
|
825
|
+
schema: typeof PERSISTED_DIGEST_SCHEMA;
|
|
826
|
+
digestId: string;
|
|
827
|
+
inputHash: string;
|
|
828
|
+
computedAt: string; // ISO-8601 — outside the hashed surfaces
|
|
829
|
+
/**
|
|
830
|
+
* The UNSUPPRESSED release-tag set — a digestId preimage member that the
|
|
831
|
+
* suppressed `digest.tags` view cannot reconstruct. Carried so flow.push
|
|
832
|
+
* can recompute the digestId from the file's own contents and bind the
|
|
833
|
+
* payload to the quoted id (RFC-1638 review round 1: a session-writable
|
|
834
|
+
* file must not mint a push payload it never preimages).
|
|
835
|
+
*/
|
|
836
|
+
releaseTags: string[];
|
|
837
|
+
digest: FlowDigestData;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/** sha256 over canonicalJson(DigestInputs) — full hex, internal attestation. */
|
|
841
|
+
export function digestInputHash(inputs: DigestInputs): string {
|
|
842
|
+
return createHash("sha256").update(canonicalJson(inputs)).digest("hex");
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/** The digestId preimage — judgment inputs only (RFC-1638 decision 2). */
|
|
846
|
+
interface DigestIdPreimage {
|
|
847
|
+
developLocal: string | null;
|
|
848
|
+
mainLocal: string | null;
|
|
849
|
+
releaseTags: string[];
|
|
850
|
+
tagTriggers: FlowDigestData["tagTriggers"];
|
|
851
|
+
correctnessTrail: FlowDigestData["correctnessTrail"];
|
|
852
|
+
items: ReadonlyArray<{ id: string; tip: string }>;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function computeDigestId(preimage: DigestIdPreimage): string {
|
|
856
|
+
return createHash("sha256")
|
|
857
|
+
.update(
|
|
858
|
+
canonicalJson({
|
|
859
|
+
develop: { local: preimage.developLocal },
|
|
860
|
+
main: { local: preimage.mainLocal },
|
|
861
|
+
releaseTags: preimage.releaseTags,
|
|
862
|
+
tagTriggers: preimage.tagTriggers,
|
|
863
|
+
correctnessTrail: preimage.correctnessTrail,
|
|
864
|
+
items: preimage.items.map((i) => ({ id: i.id, tip: i.tip })),
|
|
865
|
+
}),
|
|
866
|
+
)
|
|
867
|
+
.digest("hex")
|
|
868
|
+
.slice(0, 12);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Recompute the digestId a persisted record's own payload preimages —
|
|
873
|
+
* `null` when the record's fields cannot re-derive the preimage. A forged
|
|
874
|
+
* `.git/forge/digests/*.json` (session-writable) then needs a 48-bit
|
|
875
|
+
* sha256 preimage to move a push, not just a plausible-looking file.
|
|
876
|
+
*/
|
|
877
|
+
export function recomputePersistedDigestId(persisted: PersistedDigest): string | null {
|
|
878
|
+
const d = persisted.digest;
|
|
879
|
+
if (
|
|
880
|
+
typeof d.develop?.local !== "string" ||
|
|
881
|
+
typeof d.main?.local !== "string" ||
|
|
882
|
+
!Array.isArray(d.tagTriggers) ||
|
|
883
|
+
!Array.isArray(d.items) ||
|
|
884
|
+
!Array.isArray(persisted.releaseTags)
|
|
885
|
+
) {
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
return computeDigestId({
|
|
889
|
+
developLocal: d.develop.local,
|
|
890
|
+
mainLocal: d.main.local,
|
|
891
|
+
releaseTags: persisted.releaseTags,
|
|
892
|
+
tagTriggers: d.tagTriggers,
|
|
893
|
+
correctnessTrail: d.correctnessTrail,
|
|
894
|
+
items: d.items.map((i) => ({ id: i.id, tip: i.tip })),
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Every reachable release-line tag (unsuppressed), sorted — the set both
|
|
899
|
+
* digestId and DigestInputs cover; the journal `push` suppression applies
|
|
900
|
+
* only to the display/push-planning view (RFC-1638 decision 2). */
|
|
901
|
+
async function releaseTagSet(
|
|
902
|
+
repoRoot: string,
|
|
903
|
+
io: WorkspaceIO,
|
|
904
|
+
lines: ReleaseLine[],
|
|
905
|
+
): Promise<string[]> {
|
|
906
|
+
const set = new Set<string>();
|
|
907
|
+
for (const line of lines) {
|
|
908
|
+
const { reachable } = await listLineTags(repoRoot, line, io);
|
|
909
|
+
for (const tag of reachable) set.add(tag);
|
|
910
|
+
}
|
|
911
|
+
return [...set].sort((a, b) => a.localeCompare(b));
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/** sha256 over every `.github/workflows/*.y{ml,aml}` name + content on `dir` —
|
|
915
|
+
* the same file set workflowTagPatterns parses (RFC-1498 read surface). */
|
|
916
|
+
async function workflowFilesSha256(dir: string, io: WorkspaceIO): Promise<string> {
|
|
917
|
+
const hash = createHash("sha256");
|
|
918
|
+
if (!(await io.exists(dir))) return hash.digest("hex");
|
|
919
|
+
const entries = await io
|
|
920
|
+
.readdir(dir)
|
|
921
|
+
.catch(() => [] as Awaited<ReturnType<WorkspaceIO["readdir"]>>);
|
|
922
|
+
const names = entries
|
|
923
|
+
.filter((e) => e.isFile && /\.ya?ml$/.test(e.name))
|
|
924
|
+
.map((e) => e.name)
|
|
925
|
+
.sort();
|
|
926
|
+
for (const name of names) {
|
|
927
|
+
const text = await io.readFile(join(dir, name)).catch(() => null);
|
|
928
|
+
hash.update(name);
|
|
929
|
+
hash.update("\0");
|
|
930
|
+
hash.update(text ?? "<unreadable>");
|
|
931
|
+
hash.update("\0");
|
|
932
|
+
}
|
|
933
|
+
return hash.digest("hex");
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Re-observe every cheap digest input through the judged channel (RFC-1638:
|
|
938
|
+
* attestation feeds a refusal decision — a verdict input, never bestEffort).
|
|
939
|
+
* `null` means some input is unprovable — the caller falls back to recount.
|
|
940
|
+
*/
|
|
941
|
+
export async function observeDigestInputs(
|
|
942
|
+
repoRoot: string,
|
|
943
|
+
io: WorkspaceIO,
|
|
944
|
+
): Promise<DigestInputs | null> {
|
|
945
|
+
try {
|
|
946
|
+
const urlSet = async (args: string[]): Promise<string> => {
|
|
947
|
+
const r = await gitEvidence(repoRoot, args);
|
|
948
|
+
if (r.exitCode === -1) throw new Error(r.stderr);
|
|
949
|
+
return r.exitCode === 0 ? r.stdout : "";
|
|
950
|
+
};
|
|
951
|
+
const [head, developLocal, mainLocal, developRemote, mainRemote] = await Promise.all([
|
|
952
|
+
revParse(repoRoot, io, "HEAD"),
|
|
953
|
+
// RFC-1643: fully qualified — a shadow `refs/tags/develop` or
|
|
954
|
+
// `refs/develop` wins a bare-name lookup and would plant the tip.
|
|
955
|
+
revParse(repoRoot, io, "refs/heads/develop"),
|
|
956
|
+
revParse(repoRoot, io, "refs/heads/main"),
|
|
957
|
+
revParse(repoRoot, io, "refs/remotes/origin/develop"),
|
|
958
|
+
revParse(repoRoot, io, "refs/remotes/origin/main"),
|
|
959
|
+
]);
|
|
960
|
+
const remoteConfigSha256 = createHash("sha256")
|
|
961
|
+
.update(
|
|
962
|
+
canonicalJson({
|
|
963
|
+
configured: await urlSet(["config", "--get-all", "remote.origin.url"]),
|
|
964
|
+
fetch: await urlSet(["remote", "get-url", "--all", "origin"]),
|
|
965
|
+
push: await urlSet(["remote", "get-url", "--push", "--all", "origin"]),
|
|
966
|
+
}),
|
|
967
|
+
)
|
|
968
|
+
.digest("hex");
|
|
969
|
+
const { lines } = await discoverReleaseLines(repoRoot, io);
|
|
970
|
+
const releaseTags = await releaseTagSet(repoRoot, io, lines);
|
|
971
|
+
const common = await commonGitDir(io, repoRoot);
|
|
972
|
+
let primary = repoRoot;
|
|
973
|
+
try {
|
|
974
|
+
primary = await primaryWorktree(io, repoRoot);
|
|
975
|
+
} catch {
|
|
976
|
+
primary = repoRoot;
|
|
977
|
+
}
|
|
978
|
+
const journalBytes = (await io.exists(join(common, JOURNAL_RELATIVE_PATH)))
|
|
979
|
+
? await io.readFile(join(common, JOURNAL_RELATIVE_PATH))
|
|
980
|
+
: "";
|
|
981
|
+
const journalTailSha256 = createHash("sha256").update(journalBytes).digest("hex");
|
|
982
|
+
const sessions = (await readRegistry(io, common)).branches
|
|
983
|
+
.map((b) => b.name)
|
|
984
|
+
.sort((a, b) => a.localeCompare(b));
|
|
985
|
+
const repoStatus = await gitEvidence(repoRoot, ["status", "--porcelain=v1", "-z"]);
|
|
986
|
+
const primaryStatus =
|
|
987
|
+
primary === repoRoot
|
|
988
|
+
? repoStatus
|
|
989
|
+
: await gitEvidence(primary, ["status", "--porcelain=v1", "-z"]);
|
|
990
|
+
// A refused status consult cannot prove worktree state — attestation is
|
|
991
|
+
// a verdict input, so the observation itself is unprovable (CX-174).
|
|
992
|
+
if (repoStatus.exitCode !== 0 || primaryStatus.exitCode !== 0) return null;
|
|
993
|
+
return {
|
|
994
|
+
head,
|
|
995
|
+
developLocal,
|
|
996
|
+
mainLocal,
|
|
997
|
+
developRemote,
|
|
998
|
+
mainRemote,
|
|
999
|
+
remoteConfigSha256,
|
|
1000
|
+
releaseTags,
|
|
1001
|
+
tagTriggerFilesSha256: await workflowFilesSha256(join(primary, WORKFLOWS_DIR), io),
|
|
1002
|
+
journalTailSha256,
|
|
1003
|
+
sessions,
|
|
1004
|
+
statusPorcelainSha256: createHash("sha256")
|
|
1005
|
+
.update(canonicalJson({ repo: repoStatus.stdout, primary: primaryStatus.stdout }))
|
|
1006
|
+
.digest("hex"),
|
|
1007
|
+
};
|
|
1008
|
+
} catch {
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Load `.git/forge/digests/<digestId>.json`. "missing" names an absent file;
|
|
1015
|
+
* "unknown" names an unreadable or wrong-schema record — both refuse
|
|
1016
|
+
* FLOW-PUSH-15 upstream, never silently downgrade (RFC-1638).
|
|
1017
|
+
*/
|
|
1018
|
+
export async function loadPersistedDigest(
|
|
1019
|
+
io: WorkspaceIO,
|
|
1020
|
+
common: string,
|
|
1021
|
+
digestId: string,
|
|
1022
|
+
): Promise<PersistedDigest | "missing" | "unknown"> {
|
|
1023
|
+
// The id becomes a path segment — a crafted `--digest ../…` must not walk
|
|
1024
|
+
// out of the digests dir.
|
|
1025
|
+
if (!/^[a-z0-9-]{1,80}$/.test(digestId)) return "unknown";
|
|
1026
|
+
const file = join(common, PERSISTED_DIGESTS_DIR, `${digestId}.json`);
|
|
1027
|
+
if (!(await io.exists(file))) return "missing";
|
|
1028
|
+
let raw: unknown;
|
|
1029
|
+
try {
|
|
1030
|
+
raw = JSON.parse(await io.readFile(file));
|
|
1031
|
+
} catch {
|
|
1032
|
+
return "unknown";
|
|
1033
|
+
}
|
|
1034
|
+
const rec = raw as Partial<PersistedDigest> | null;
|
|
1035
|
+
const d = rec?.digest as Partial<FlowDigestData> | null | undefined;
|
|
1036
|
+
if (
|
|
1037
|
+
rec === null ||
|
|
1038
|
+
rec.schema !== PERSISTED_DIGEST_SCHEMA ||
|
|
1039
|
+
rec.digestId !== digestId ||
|
|
1040
|
+
typeof rec.inputHash !== "string" ||
|
|
1041
|
+
typeof rec.computedAt !== "string" ||
|
|
1042
|
+
!Array.isArray(rec.releaseTags) ||
|
|
1043
|
+
!rec.releaseTags.every((t) => typeof t === "string") ||
|
|
1044
|
+
typeof d !== "object" ||
|
|
1045
|
+
d === null ||
|
|
1046
|
+
typeof d.digestId !== "string" ||
|
|
1047
|
+
!Array.isArray(d.diagnostics) ||
|
|
1048
|
+
typeof d.develop?.local !== "string" ||
|
|
1049
|
+
typeof d.main?.local !== "string" ||
|
|
1050
|
+
!Array.isArray(d.items) ||
|
|
1051
|
+
!Array.isArray(d.tagTriggers)
|
|
1052
|
+
) {
|
|
1053
|
+
return "unknown";
|
|
1054
|
+
}
|
|
1055
|
+
return rec as PersistedDigest;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/** Write the persisted digest atomically (tmp + rename) and sweep to the
|
|
1059
|
+
* 50-newest retention (RFC-1568 precedent); `.tmp-<pid>` orphans of a dead
|
|
1060
|
+
* writer older than a minute are reclaimed in the same pass. */
|
|
1061
|
+
async function persistDigest(
|
|
1062
|
+
io: WorkspaceIO,
|
|
1063
|
+
common: string,
|
|
1064
|
+
persisted: PersistedDigest,
|
|
1065
|
+
): Promise<void> {
|
|
1066
|
+
const dir = join(common, PERSISTED_DIGESTS_DIR);
|
|
1067
|
+
await io.mkdir(dir);
|
|
1068
|
+
const file = join(dir, `${persisted.digestId}.json`);
|
|
1069
|
+
const tmp = `${file}.tmp-${process.pid}`;
|
|
1070
|
+
await io.writeFile(tmp, `${JSON.stringify(persisted, null, 2)}\n`);
|
|
1071
|
+
await io.rename(tmp, file);
|
|
1072
|
+
const entries = await io
|
|
1073
|
+
.readdir(dir)
|
|
1074
|
+
.catch(() => [] as Awaited<ReturnType<WorkspaceIO["readdir"]>>);
|
|
1075
|
+
const names = entries.filter((e) => e.isFile).map((e) => e.name);
|
|
1076
|
+
const orphans = names.filter((n) => n.endsWith(".json") === false && n.includes(".tmp-"));
|
|
1077
|
+
const digests = names.filter((n) => n.endsWith(".json") && !n.includes(".tmp-"));
|
|
1078
|
+
const now = Date.now();
|
|
1079
|
+
for (const n of orphans) {
|
|
1080
|
+
const t = await io
|
|
1081
|
+
.stat(join(dir, n))
|
|
1082
|
+
.then((s) => s.mtimeMs)
|
|
1083
|
+
.catch(() => 0);
|
|
1084
|
+
if (now - t > 60_000) await io.rm(join(dir, n)).catch(() => {});
|
|
1085
|
+
}
|
|
1086
|
+
if (digests.length <= PERSISTED_DIGEST_RETENTION) return;
|
|
1087
|
+
const aged = await Promise.all(
|
|
1088
|
+
digests.map(async (n) => ({
|
|
1089
|
+
n,
|
|
1090
|
+
t: await io
|
|
1091
|
+
.stat(join(dir, n))
|
|
1092
|
+
.then((s) => s.mtimeMs)
|
|
1093
|
+
.catch(() => 0),
|
|
1094
|
+
})),
|
|
1095
|
+
);
|
|
1096
|
+
const keep = new Set(
|
|
1097
|
+
aged
|
|
1098
|
+
.sort((a, b) => b.t - a.t)
|
|
1099
|
+
.slice(0, PERSISTED_DIGEST_RETENTION)
|
|
1100
|
+
.map((e) => e.n),
|
|
1101
|
+
);
|
|
1102
|
+
for (const n of digests) {
|
|
1103
|
+
if (!keep.has(n)) await io.rm(join(dir, n)).catch(() => {});
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
822
1107
|
/**
|
|
823
1108
|
* Collect the outbound digest of repoRoot. The `fetch` flag is retained for
|
|
824
1109
|
* call-site compatibility but is inert — the trusted channel refuses every
|
|
@@ -828,7 +1113,7 @@ function canonicalJson(value: unknown): string {
|
|
|
828
1113
|
export async function collectDigest(
|
|
829
1114
|
repoRoot: string,
|
|
830
1115
|
io: WorkspaceIO,
|
|
831
|
-
|
|
1116
|
+
opts: { fetch: boolean; persist?: boolean },
|
|
832
1117
|
): Promise<FlowDigestData> {
|
|
833
1118
|
const diagnostics: Diagnostic[] = [];
|
|
834
1119
|
|
|
@@ -839,8 +1124,31 @@ export async function collectDigest(
|
|
|
839
1124
|
// read resolves (CX-79). Emitting the reasons here keeps the digest's
|
|
840
1125
|
// diagnostics honest instead of cascading "no origin"/"fetch failed"
|
|
841
1126
|
// secondaries on top of the refused channel.
|
|
842
|
-
|
|
843
|
-
|
|
1127
|
+
// RFC-1633 (review DEV-4): the standalone surface preflight is itself a
|
|
1128
|
+
// heavy judged reader (~47k openat on this repo) — it serializes on the
|
|
1129
|
+
// consult lock like every other judged read, so a parallel digest's
|
|
1130
|
+
// fingerprint capture cannot interleave mid-sweep.
|
|
1131
|
+
let preflight: EvidencePreflight | null;
|
|
1132
|
+
try {
|
|
1133
|
+
preflight = await withEvidenceConsultLock(repoRoot, { command: "flow.digest preflight" }, () =>
|
|
1134
|
+
// RFC-1644: diagnostic-only — read for refusedKeys/shapeViolations,
|
|
1135
|
+
// never armed against, so the worktree baseline is skipped.
|
|
1136
|
+
evidencePreflight(repoRoot, undefined, { worktreeSurface: "skip" }),
|
|
1137
|
+
);
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
if (error instanceof LockTimeoutError) {
|
|
1140
|
+
diagnostics.push({
|
|
1141
|
+
ruleId: "FLOW-PUSH-13",
|
|
1142
|
+
severity: "error",
|
|
1143
|
+
message: await describeEvidenceLockError(repoRoot, error),
|
|
1144
|
+
fixHint: `a parallel judged consult held the evidence lock past the wait budget — re-run flow.digest`,
|
|
1145
|
+
});
|
|
1146
|
+
preflight = null;
|
|
1147
|
+
} else {
|
|
1148
|
+
throw error;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
if (preflight === null && !diagnostics.some((d) => d.ruleId === "FLOW-PUSH-13")) {
|
|
844
1152
|
diagnostics.push({
|
|
845
1153
|
ruleId: "FLOW-PUSH-13",
|
|
846
1154
|
severity: "error",
|
|
@@ -1035,8 +1343,11 @@ export async function collectDigest(
|
|
|
1035
1343
|
// branch — the strictly stronger judgment.
|
|
1036
1344
|
const fetched = false;
|
|
1037
1345
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1346
|
+
// RFC-1643: branch tips resolve fully qualified — git's bare-name order
|
|
1347
|
+
// (`refs/<name>`, `refs/tags/<name>`, then `refs/heads/<name>`) lets a
|
|
1348
|
+
// shadow ref plant an unintegrated commit as the reviewed tip.
|
|
1349
|
+
const developLocal = await revParse(repoRoot, io, "refs/heads/develop");
|
|
1350
|
+
const mainLocal = await revParse(repoRoot, io, "refs/heads/main");
|
|
1040
1351
|
// The "remote" tips are always the session-mutable tracking refs —
|
|
1041
1352
|
// verified remote tips cannot exist (CX-132). A planted
|
|
1042
1353
|
// `refs/remotes/origin/*` can hide commits from the tail exactly like
|
|
@@ -1051,9 +1362,11 @@ export async function collectDigest(
|
|
|
1051
1362
|
const developTailRead =
|
|
1052
1363
|
developLocal === null
|
|
1053
1364
|
? []
|
|
1054
|
-
: await unpushedCommits(repoRoot, io,
|
|
1365
|
+
: await unpushedCommits(repoRoot, io, developLocal, developRemote, false, null);
|
|
1055
1366
|
const mainTailRead =
|
|
1056
|
-
mainLocal === null
|
|
1367
|
+
mainLocal === null
|
|
1368
|
+
? []
|
|
1369
|
+
: await unpushedCommits(repoRoot, io, mainLocal, mainRemote, false, null);
|
|
1057
1370
|
|
|
1058
1371
|
// --- items: journal-attributed segments of the develop tail ---------------
|
|
1059
1372
|
// Segments follow develop's first-parent chain: a back-merge brings main's
|
|
@@ -1062,7 +1375,7 @@ export async function collectDigest(
|
|
|
1062
1375
|
const developChainRead =
|
|
1063
1376
|
developLocal === null
|
|
1064
1377
|
? []
|
|
1065
|
-
: await unpushedCommits(repoRoot, io,
|
|
1378
|
+
: await unpushedCommits(repoRoot, io, developLocal, developRemote, true, null);
|
|
1066
1379
|
// A null tail/chain means the enumeration itself is unverifiable —
|
|
1067
1380
|
// degrading to [] would run the verifier trailer scan over NOTHING
|
|
1068
1381
|
// (CX-174). Fail the digest as unverifiable; the lists stay empty so
|
|
@@ -1190,14 +1503,13 @@ export async function collectDigest(
|
|
|
1190
1503
|
// corroborated into one (R13-C) — flow.push publishes only what this
|
|
1191
1504
|
// run itself pushes.
|
|
1192
1505
|
const { lines } = await discoverReleaseLines(repoRoot, io);
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
tags.sort((a, b) => a.localeCompare(b));
|
|
1506
|
+
// RFC-1638 decision 2: the hashed set is the UNSUPPRESSED reachable set —
|
|
1507
|
+
// `pushedTags` suppression derives from journal `push` records, and a
|
|
1508
|
+
// foreign push record must not move digestId. The display/push view keeps
|
|
1509
|
+
// the suppression; flow.push re-applies it from the journal at planning
|
|
1510
|
+
// time so records appended after the digest still hide their tags.
|
|
1511
|
+
const releaseTags = await releaseTagSet(repoRoot, io, lines);
|
|
1512
|
+
const tags = releaseTags.filter((t) => !pushedTags.has(t));
|
|
1201
1513
|
|
|
1202
1514
|
const pendingPublications: FlowDigestData["pendingPublications"] = [];
|
|
1203
1515
|
const supersededPublications: FlowDigestData["supersededPublications"] = [];
|
|
@@ -1213,7 +1525,9 @@ export async function collectDigest(
|
|
|
1213
1525
|
}
|
|
1214
1526
|
const tagPatterns = await workflowTagPatterns(join(primary, WORKFLOWS_DIR), io, diagnostics);
|
|
1215
1527
|
const tagTriggers: FlowDigestData["tagTriggers"] = [];
|
|
1216
|
-
|
|
1528
|
+
// Triggers compute over the unsuppressed set — a journal `push` record
|
|
1529
|
+
// hiding a tag must not shrink the hashed trigger surface (RFC-1638).
|
|
1530
|
+
for (const tag of releaseTags) {
|
|
1217
1531
|
const workflows = tagPatterns
|
|
1218
1532
|
.filter((w) => w.patterns.some((p) => tagPatternRegex(p)?.test(tag) === true))
|
|
1219
1533
|
.map((w) => w.file);
|
|
@@ -1228,23 +1542,23 @@ export async function collectDigest(
|
|
|
1228
1542
|
>;
|
|
1229
1543
|
for (const item of items) byCategory[item.category].push(item.id);
|
|
1230
1544
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1545
|
+
// RFC-1638 decision 2: the hashed contract covers judgment inputs only —
|
|
1546
|
+
// local branch tips, the unsuppressed release-tag set, triggers, the
|
|
1547
|
+
// correctness trail and the item tips. `*.remote` (session-mutable
|
|
1548
|
+
// tracking refs), the derived `ahead` counts and the display-only
|
|
1549
|
+
// publication fields stay in the returned object as preview data but
|
|
1550
|
+
// leave the hash: a foreign push or journal `push` record can no longer
|
|
1551
|
+
// move a digest the operator already reviewed.
|
|
1552
|
+
const digestId = computeDigestId({
|
|
1553
|
+
developLocal,
|
|
1554
|
+
mainLocal,
|
|
1555
|
+
releaseTags,
|
|
1556
|
+
tagTriggers,
|
|
1557
|
+
correctnessTrail,
|
|
1558
|
+
items,
|
|
1559
|
+
});
|
|
1246
1560
|
|
|
1247
|
-
|
|
1561
|
+
const data: FlowDigestData = {
|
|
1248
1562
|
digestId,
|
|
1249
1563
|
remote: "origin",
|
|
1250
1564
|
fetched,
|
|
@@ -1261,4 +1575,31 @@ export async function collectDigest(
|
|
|
1261
1575
|
correctnessTrail,
|
|
1262
1576
|
diagnostics,
|
|
1263
1577
|
};
|
|
1578
|
+
|
|
1579
|
+
// RFC-1638 persist — the reviewed digest + its input hash, so flow.push
|
|
1580
|
+
// attests staleness in seconds instead of recounting. Best-effort: a
|
|
1581
|
+
// failed persist degrades to the recount path (FLOW-PUSH-15 upstream),
|
|
1582
|
+
// never blocks the digest itself. `persist:false` (dry-run callers)
|
|
1583
|
+
// leaves the digests dir untouched.
|
|
1584
|
+
try {
|
|
1585
|
+
const inputs = opts?.persist === false ? null : await observeDigestInputs(repoRoot, io);
|
|
1586
|
+
if (inputs !== null) {
|
|
1587
|
+
await persistDigest(io, common, {
|
|
1588
|
+
schema: PERSISTED_DIGEST_SCHEMA,
|
|
1589
|
+
digestId,
|
|
1590
|
+
inputHash: digestInputHash(inputs),
|
|
1591
|
+
computedAt: new Date().toISOString(),
|
|
1592
|
+
releaseTags,
|
|
1593
|
+
digest: data,
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
} catch (error) {
|
|
1597
|
+
diagnostics.push({
|
|
1598
|
+
ruleId: "FLOW-DIGEST-01",
|
|
1599
|
+
severity: "warning",
|
|
1600
|
+
message: `the persisted digest could not be written — flow.push will recount instead of attesting: ${error instanceof Error ? error.message : String(error)}`,
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
return data;
|
|
1264
1605
|
}
|