@warpgogol/forge 9.5.0 → 9.6.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/CHANGELOG.md +18 -0
- package/README.md +30 -0
- package/README.uk.md +30 -0
- package/bin/cli.ts +19 -50
- package/dist/bin/cli.js +18 -43
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/codebase/codebase.module.d.ts +3 -0
- package/dist/os/codebase/codebase.module.d.ts.map +1 -0
- package/dist/os/codebase/codebase.module.js +53 -0
- package/dist/os/codebase/codebase.module.js.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts +15 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +97 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure.d.ts +22 -0
- package/dist/os/codebase/handlers/codebase-measure.d.ts.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure.js +435 -0
- package/dist/os/codebase/handlers/codebase-measure.js.map +1 -0
- package/dist/os/codebase/index.d.ts +4 -0
- package/dist/os/codebase/index.d.ts.map +1 -0
- package/dist/os/codebase/index.js +13 -0
- package/dist/os/codebase/index.js.map +1 -0
- package/dist/os/codebase/types.d.ts +35 -0
- package/dist/os/codebase/types.d.ts.map +1 -0
- package/dist/os/codebase/types.js +17 -0
- package/dist/os/codebase/types.js.map +1 -0
- package/dist/os/core/handlers/package-health.d.ts +6 -4
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +15 -20
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/correctness/anchors.d.ts +24 -0
- package/dist/os/correctness/anchors.d.ts.map +1 -0
- package/dist/os/correctness/anchors.js +156 -0
- package/dist/os/correctness/anchors.js.map +1 -0
- package/dist/os/correctness/audit/bindings-verify-substance.d.ts +7 -0
- package/dist/os/correctness/audit/bindings-verify-substance.d.ts.map +1 -0
- package/dist/os/correctness/audit/bindings-verify-substance.js +145 -0
- package/dist/os/correctness/audit/bindings-verify-substance.js.map +1 -0
- package/dist/os/correctness/audit/differential.d.ts +7 -0
- package/dist/os/correctness/audit/differential.d.ts.map +1 -0
- package/dist/os/correctness/audit/differential.js +105 -0
- package/dist/os/correctness/audit/differential.js.map +1 -0
- package/dist/os/correctness/audit/ledger-orphans.d.ts +6 -0
- package/dist/os/correctness/audit/ledger-orphans.d.ts.map +1 -0
- package/dist/os/correctness/audit/ledger-orphans.js +71 -0
- package/dist/os/correctness/audit/ledger-orphans.js.map +1 -0
- package/dist/os/correctness/audit/ledger.d.ts +29 -0
- package/dist/os/correctness/audit/ledger.d.ts.map +1 -0
- package/dist/os/correctness/audit/ledger.js +72 -0
- package/dist/os/correctness/audit/ledger.js.map +1 -0
- package/dist/os/correctness/audit/run.d.ts +27 -0
- package/dist/os/correctness/audit/run.d.ts.map +1 -0
- package/dist/os/correctness/audit/run.js +184 -0
- package/dist/os/correctness/audit/run.js.map +1 -0
- package/dist/os/correctness/audit/schema-db.d.ts +32 -0
- package/dist/os/correctness/audit/schema-db.d.ts.map +1 -0
- package/dist/os/correctness/audit/schema-db.js +166 -0
- package/dist/os/correctness/audit/schema-db.js.map +1 -0
- package/dist/os/correctness/audit/snapshot.d.ts +34 -0
- package/dist/os/correctness/audit/snapshot.d.ts.map +1 -0
- package/dist/os/correctness/audit/snapshot.js +190 -0
- package/dist/os/correctness/audit/snapshot.js.map +1 -0
- package/dist/os/correctness/audit/sql-scanner.d.ts +28 -0
- package/dist/os/correctness/audit/sql-scanner.d.ts.map +1 -0
- package/dist/os/correctness/audit/sql-scanner.js +279 -0
- package/dist/os/correctness/audit/sql-scanner.js.map +1 -0
- package/dist/os/correctness/audit/sql-schema-conform.d.ts +17 -0
- package/dist/os/correctness/audit/sql-schema-conform.d.ts.map +1 -0
- package/dist/os/correctness/audit/sql-schema-conform.js +163 -0
- package/dist/os/correctness/audit/sql-schema-conform.js.map +1 -0
- package/dist/os/correctness/audit/state-transitions-coverage.d.ts +19 -0
- package/dist/os/correctness/audit/state-transitions-coverage.d.ts.map +1 -0
- package/dist/os/correctness/audit/state-transitions-coverage.js +263 -0
- package/dist/os/correctness/audit/state-transitions-coverage.js.map +1 -0
- package/dist/os/correctness/audit/tests/git-fixture.d.ts +15 -0
- package/dist/os/correctness/audit/tests/git-fixture.d.ts.map +1 -0
- package/dist/os/correctness/audit/tests/git-fixture.js +85 -0
- package/dist/os/correctness/audit/tests/git-fixture.js.map +1 -0
- package/dist/os/correctness/audit/types.d.ts +58 -0
- package/dist/os/correctness/audit/types.d.ts.map +1 -0
- package/dist/os/correctness/audit/types.js +34 -0
- package/dist/os/correctness/audit/types.js.map +1 -0
- package/dist/os/correctness/correctness.module.d.ts +3 -0
- package/dist/os/correctness/correctness.module.d.ts.map +1 -0
- package/dist/os/correctness/correctness.module.js +173 -0
- package/dist/os/correctness/correctness.module.js.map +1 -0
- package/dist/os/correctness/gate/frozen.d.ts +52 -0
- package/dist/os/correctness/gate/frozen.d.ts.map +1 -0
- package/dist/os/correctness/gate/frozen.js +322 -0
- package/dist/os/correctness/gate/frozen.js.map +1 -0
- package/dist/os/correctness/gate/origin.d.ts +28 -0
- package/dist/os/correctness/gate/origin.d.ts.map +1 -0
- package/dist/os/correctness/gate/origin.js +139 -0
- package/dist/os/correctness/gate/origin.js.map +1 -0
- package/dist/os/correctness/gate/repo.d.ts +25 -0
- package/dist/os/correctness/gate/repo.d.ts.map +1 -0
- package/dist/os/correctness/gate/repo.js +88 -0
- package/dist/os/correctness/gate/repo.js.map +1 -0
- package/dist/os/correctness/gate/run.d.ts +22 -0
- package/dist/os/correctness/gate/run.d.ts.map +1 -0
- package/dist/os/correctness/gate/run.js +430 -0
- package/dist/os/correctness/gate/run.js.map +1 -0
- package/dist/os/correctness/gate/runner.d.ts +18 -0
- package/dist/os/correctness/gate/runner.d.ts.map +1 -0
- package/dist/os/correctness/gate/runner.js +123 -0
- package/dist/os/correctness/gate/runner.js.map +1 -0
- package/dist/os/correctness/gate/tests/gate-fixture.d.ts +36 -0
- package/dist/os/correctness/gate/tests/gate-fixture.d.ts.map +1 -0
- package/dist/os/correctness/gate/tests/gate-fixture.js +153 -0
- package/dist/os/correctness/gate/tests/gate-fixture.js.map +1 -0
- package/dist/os/correctness/gate/types.d.ts +102 -0
- package/dist/os/correctness/gate/types.d.ts.map +1 -0
- package/dist/os/correctness/gate/types.js +64 -0
- package/dist/os/correctness/gate/types.js.map +1 -0
- package/dist/os/correctness/handlers/audit.d.ts +4 -0
- package/dist/os/correctness/handlers/audit.d.ts.map +1 -0
- package/dist/os/correctness/handlers/audit.js +95 -0
- package/dist/os/correctness/handlers/audit.js.map +1 -0
- package/dist/os/correctness/handlers/gate.d.ts +4 -0
- package/dist/os/correctness/handlers/gate.d.ts.map +1 -0
- package/dist/os/correctness/handlers/gate.js +62 -0
- package/dist/os/correctness/handlers/gate.js.map +1 -0
- package/dist/os/correctness/handlers/validate.d.ts +19 -0
- package/dist/os/correctness/handlers/validate.d.ts.map +1 -0
- package/dist/os/correctness/handlers/validate.js +367 -0
- package/dist/os/correctness/handlers/validate.js.map +1 -0
- package/dist/os/correctness/index.d.ts +8 -0
- package/dist/os/correctness/index.d.ts.map +1 -0
- package/dist/os/correctness/index.js +23 -0
- package/dist/os/correctness/index.js.map +1 -0
- package/dist/os/correctness/manifest-schema.d.ts +155 -0
- package/dist/os/correctness/manifest-schema.d.ts.map +1 -0
- package/dist/os/correctness/manifest-schema.js +110 -0
- package/dist/os/correctness/manifest-schema.js.map +1 -0
- package/dist/os/correctness/references.d.ts +22 -0
- package/dist/os/correctness/references.d.ts.map +1 -0
- package/dist/os/correctness/references.js +129 -0
- package/dist/os/correctness/references.js.map +1 -0
- package/dist/os/correctness/tests/fixture-workspace.d.ts +23 -0
- package/dist/os/correctness/tests/fixture-workspace.d.ts.map +1 -0
- package/dist/os/correctness/tests/fixture-workspace.js +104 -0
- package/dist/os/correctness/tests/fixture-workspace.js.map +1 -0
- package/dist/os/correctness/workspace.d.ts +32 -0
- package/dist/os/correctness/workspace.d.ts.map +1 -0
- package/dist/os/correctness/workspace.js +147 -0
- package/dist/os/correctness/workspace.js.map +1 -0
- package/dist/os/flow/correctness-step.d.ts +19 -0
- package/dist/os/flow/correctness-step.d.ts.map +1 -0
- package/dist/os/flow/correctness-step.js +133 -0
- package/dist/os/flow/correctness-step.js.map +1 -0
- package/dist/os/flow/digest.d.ts +18 -0
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +28 -1
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +17 -3
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +11 -1
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +90 -5
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/post-rebase-regen.d.ts +33 -0
- package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
- package/dist/os/flow/post-rebase-regen.js +120 -0
- package/dist/os/flow/post-rebase-regen.js.map +1 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +11 -15
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/publish.d.ts.map +1 -1
- package/dist/os/flow/publish.js +23 -4
- package/dist/os/flow/publish.js.map +1 -1
- package/dist/os/flow/registry.d.ts +4 -4
- package/dist/os/flow/tests/helpers.d.ts +9 -1
- package/dist/os/flow/tests/helpers.d.ts.map +1 -1
- package/dist/os/flow/tests/helpers.js +36 -2
- package/dist/os/flow/tests/helpers.js.map +1 -1
- package/dist/os/friction/types.d.ts +2 -2
- package/dist/os/gate-run/status.d.ts +12 -0
- package/dist/os/gate-run/status.d.ts.map +1 -1
- package/dist/os/gate-run/status.js +24 -3
- package/dist/os/gate-run/status.js.map +1 -1
- package/dist/os/program/schemas.d.ts +3 -3
- package/dist/os/queue/types.d.ts +2 -2
- package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +15 -2
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +26 -5
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +18 -6
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +12 -3
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +5 -2
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verify-workspace.d.ts +12 -0
- package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
- package/dist/os/rfc/verify-workspace.js +155 -0
- package/dist/os/rfc/verify-workspace.js.map +1 -1
- package/dist/os/system/task-schemas.d.ts +1 -1
- package/dist/os/system/tests/helpers.d.ts.map +1 -1
- package/dist/os/system/tests/helpers.js +6 -1
- package/dist/os/system/tests/helpers.js.map +1 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
- package/dist/src/command-modules.d.ts +4 -0
- package/dist/src/command-modules.d.ts.map +1 -0
- package/dist/src/command-modules.js +42 -0
- package/dist/src/command-modules.js.map +1 -0
- package/dist/src/config/forge-config.d.ts +16 -1
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +27 -11
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/correctness/index.d.ts +32 -0
- package/dist/src/correctness/index.d.ts.map +1 -0
- package/dist/src/correctness/index.js +157 -0
- package/dist/src/correctness/index.js.map +1 -0
- package/dist/src/correctness/schema-hash.d.ts +15 -0
- package/dist/src/correctness/schema-hash.d.ts.map +1 -0
- package/dist/src/correctness/schema-hash.js +44 -0
- package/dist/src/correctness/schema-hash.js.map +1 -0
- package/dist/src/knowledge/schema.d.ts +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +20 -3
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/create.d.ts +7 -0
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +62 -9
- package/dist/src/onboarding/create.js.map +1 -1
- package/docs/reference/correctness-audit.md +91 -0
- package/docs/reference/correctness-gate.md +102 -0
- package/docs/reference/correctness-manifest.md +142 -0
- package/docs/reference/forge-yaml.md +15 -0
- package/os/codebase/codebase.module.ts +57 -0
- package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
- package/os/codebase/handlers/codebase-measure.ts +503 -0
- package/os/codebase/index.ts +21 -0
- package/os/codebase/types.ts +55 -0
- package/os/core/handlers/package-health.test.ts +24 -2
- package/os/core/handlers/package-health.ts +16 -19
- package/os/correctness/anchors.ts +182 -0
- package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
- package/os/correctness/audit/bindings-verify-substance.ts +155 -0
- package/os/correctness/audit/differential.test.ts +113 -0
- package/os/correctness/audit/differential.ts +131 -0
- package/os/correctness/audit/ledger-orphans.test.ts +96 -0
- package/os/correctness/audit/ledger-orphans.ts +84 -0
- package/os/correctness/audit/ledger.test.ts +65 -0
- package/os/correctness/audit/ledger.ts +103 -0
- package/os/correctness/audit/run.ts +220 -0
- package/os/correctness/audit/schema-db.ts +208 -0
- package/os/correctness/audit/snapshot.ts +211 -0
- package/os/correctness/audit/sql-scanner.test.ts +84 -0
- package/os/correctness/audit/sql-scanner.ts +289 -0
- package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
- package/os/correctness/audit/sql-schema-conform.ts +178 -0
- package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
- package/os/correctness/audit/state-transitions-coverage.ts +271 -0
- package/os/correctness/audit/tests/git-fixture.ts +98 -0
- package/os/correctness/audit/types.ts +91 -0
- package/os/correctness/correctness-capture.test.ts +107 -0
- package/os/correctness/correctness-chain.test.ts +232 -0
- package/os/correctness/correctness-coverage.test.ts +86 -0
- package/os/correctness/correctness-mode.test.ts +108 -0
- package/os/correctness/correctness-substrate.test.ts +64 -0
- package/os/correctness/correctness.module.ts +182 -0
- package/os/correctness/gate/anchor-events.test.ts +77 -0
- package/os/correctness/gate/freeze-coverage.test.ts +218 -0
- package/os/correctness/gate/freeze-diff.test.ts +110 -0
- package/os/correctness/gate/frozen.ts +399 -0
- package/os/correctness/gate/gate-mode.test.ts +76 -0
- package/os/correctness/gate/hardening.test.ts +175 -0
- package/os/correctness/gate/oracle-edit.test.ts +83 -0
- package/os/correctness/gate/oracle-origin.test.ts +142 -0
- package/os/correctness/gate/origin.ts +175 -0
- package/os/correctness/gate/repo.ts +102 -0
- package/os/correctness/gate/run.ts +547 -0
- package/os/correctness/gate/runner.ts +136 -0
- package/os/correctness/gate/substrate-attestation.test.ts +71 -0
- package/os/correctness/gate/tests/gate-fixture.ts +205 -0
- package/os/correctness/gate/tier-high.test.ts +92 -0
- package/os/correctness/gate/types.ts +144 -0
- package/os/correctness/handlers/audit.ts +107 -0
- package/os/correctness/handlers/gate.ts +75 -0
- package/os/correctness/handlers/validate.ts +514 -0
- package/os/correctness/index.ts +24 -0
- package/os/correctness/manifest-schema.ts +174 -0
- package/os/correctness/references.ts +143 -0
- package/os/correctness/tests/fixture-workspace.ts +119 -0
- package/os/correctness/workspace.ts +167 -0
- package/os/flow/correctness-step.ts +166 -0
- package/os/flow/digest.ts +40 -1
- package/os/flow/flow.module.ts +18 -3
- package/os/flow/handlers/flow-digest.ts +11 -1
- package/os/flow/handlers/flow-integrate.ts +117 -5
- package/os/flow/post-rebase-regen.ts +170 -0
- package/os/flow/preflight.ts +11 -19
- package/os/flow/publish.ts +23 -4
- package/os/flow/tests/flow-detachable.test.ts +31 -0
- package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
- package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
- package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
- package/os/flow/tests/flow-integrate.test.ts +10 -9
- package/os/flow/tests/helpers.ts +45 -24
- package/os/gate-run/status.ts +36 -3
- package/os/gate-run/tests/gate-run-status.test.ts +114 -0
- package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
- package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
- package/os/rfc/handlers/implement-stamp.ts +16 -2
- package/os/rfc/handlers/validate-rules.ts +43 -5
- package/os/rfc/rfc.module.ts +19 -6
- package/os/rfc/types.ts +16 -2
- package/os/rfc/verify-workspace-manifest.test.ts +55 -0
- package/os/rfc/verify-workspace.ts +167 -0
- package/os/system/tests/helpers.ts +6 -1
- package/package.json +41 -1
- package/profiles/typescript.yaml +16 -0
- package/skills/_shared/agent-operating-model.md +4 -0
- package/skills/fo/fo-idea-audit/SKILL.md +4 -0
- package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
- package/skills/fo/fo-idea-implement/SKILL.md +8 -2
- package/skills/fo/fo-review/SKILL.md +16 -2
- package/src/command-modules.ts +62 -0
- package/src/config/forge-config.ts +37 -11
- package/src/correctness/index.ts +192 -0
- package/src/correctness/schema-hash.ts +59 -0
- package/src/onboarding/agents-generate.ts +20 -3
- package/src/onboarding/create.ts +59 -9
- package/src/tests/agents-generate-detach.test.ts +126 -0
- package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
- package/src/tests/command-modules.test.ts +34 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1574 AC-1, AC-2, AC-3, AC-5 — flow.integrate step (3b): after the rebase, owner commands regenerate docs/*.generated.yaml in the session worktree and the change is committed with the fixed subject before the gate; no drift means no commit; an owner failure or non-owned dirt refuses FLOW-INT-12 without committing. Every case asserts the worktree state — the RFC-1546 tests asserted only invoke order, which is how the uncommitted regeneration shipped (F-0168).</purpose>
|
|
4
|
+
<non-goals>
|
|
5
|
+
<item>No real generators — a stub invoke port rewrites the file.</item>
|
|
6
|
+
</non-goals>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
*/
|
|
9
|
+
// Test-Reason: requirement AC-1, AC-2, AC-3, AC-5 (RFC-1574)
|
|
10
|
+
import { chmod, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
14
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
15
|
+
import type { ForgeInvokeCommand } from "../../../src/types.ts";
|
|
16
|
+
import { integrateFlowBranch } from "../handlers/flow-integrate.ts";
|
|
17
|
+
import { openFlowBranch } from "../handlers/flow-open.ts";
|
|
18
|
+
import { POST_REBASE_REGEN_SUBJECT } from "../post-rebase-regen.ts";
|
|
19
|
+
import { gitExec, initRepo } from "./helpers.ts";
|
|
20
|
+
|
|
21
|
+
const NOW = new Date("2026-11-12T12:00:00Z");
|
|
22
|
+
const MANIFEST = "docs/ecosystem.generated.yaml";
|
|
23
|
+
const dirs: string[] = [];
|
|
24
|
+
|
|
25
|
+
afterEach(async () => {
|
|
26
|
+
for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
async function repoWithManifest(): Promise<string> {
|
|
30
|
+
const dir = await initRepo({ prefix: "flow-regen-" });
|
|
31
|
+
dirs.push(dir);
|
|
32
|
+
await writeFile(join(dir, "forge.yaml"), 'schema: "forge/workspace@1"\n');
|
|
33
|
+
await mkdir(join(dir, "docs"), { recursive: true });
|
|
34
|
+
await writeFile(join(dir, MANIFEST), "contentHash: old\n");
|
|
35
|
+
await gitExec(dir, ["add", "forge.yaml", MANIFEST]);
|
|
36
|
+
await gitExec(dir, ["commit", "-m", "manifest"]);
|
|
37
|
+
await gitExec(dir, ["branch", "develop", "HEAD"]);
|
|
38
|
+
await gitExec(dir, ["switch", "develop"]);
|
|
39
|
+
return dir;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function session(repo: string, slug: string) {
|
|
43
|
+
const data = await openFlowBranch(repo, ambientIo, {
|
|
44
|
+
kind: "session",
|
|
45
|
+
slug,
|
|
46
|
+
brief: null,
|
|
47
|
+
owner: null,
|
|
48
|
+
dryRun: false,
|
|
49
|
+
now: NOW,
|
|
50
|
+
});
|
|
51
|
+
expect(data.diagnostics).toEqual([]);
|
|
52
|
+
dirs.push(data.worktree!);
|
|
53
|
+
await writeFile(join(data.worktree!, "work.txt"), "work\n");
|
|
54
|
+
await gitExec(data.worktree!, ["add", "work.txt"]);
|
|
55
|
+
await gitExec(data.worktree!, ["commit", "-m", "work"]);
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Stub owner port: the generator writes `content` into the manifest; extra writes simulate a misbehaving owner. */
|
|
60
|
+
function stubInvoke(
|
|
61
|
+
worktree: () => string,
|
|
62
|
+
opts: { content?: string; fail?: boolean; extra?: string; validateRed?: boolean },
|
|
63
|
+
): { invoke: ForgeInvokeCommand; calls: string[] } {
|
|
64
|
+
const calls: string[] = [];
|
|
65
|
+
const invoke: ForgeInvokeCommand = async (name) => {
|
|
66
|
+
calls.push(name);
|
|
67
|
+
if (name === "ecosystem.manifest.validate" && opts.validateRed) {
|
|
68
|
+
return { ok: false, exitCode: 1, summary: "regenerated manifest invalid" };
|
|
69
|
+
}
|
|
70
|
+
if (name === "ecosystem.manifest.generate") {
|
|
71
|
+
if (opts.fail) return { ok: false, exitCode: 1, summary: "generator crashed" };
|
|
72
|
+
if (opts.content !== undefined) await writeFile(join(worktree(), MANIFEST), opts.content);
|
|
73
|
+
if (opts.extra !== undefined) await writeFile(join(worktree(), opts.extra), "stray\n");
|
|
74
|
+
}
|
|
75
|
+
return { ok: true, exitCode: 0 };
|
|
76
|
+
};
|
|
77
|
+
return { invoke, calls };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
describe("flow.integrate post-rebase regeneration (RFC-1574)", () => {
|
|
81
|
+
it("AC-1: commits a drifted manifest with the fixed subject before the gate", async () => {
|
|
82
|
+
const repo = await repoWithManifest();
|
|
83
|
+
const s = await session(repo, "drift");
|
|
84
|
+
const stub = stubInvoke(() => s.worktree!, { content: "contentHash: new\n" });
|
|
85
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
86
|
+
branch: s.branch!,
|
|
87
|
+
dryRun: false,
|
|
88
|
+
now: NOW,
|
|
89
|
+
invoke: stub.invoke,
|
|
90
|
+
});
|
|
91
|
+
expect(data.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
92
|
+
expect(data.integrated).toBe(true);
|
|
93
|
+
expect(data.postRebaseRegen?.committed).toEqual([MANIFEST]);
|
|
94
|
+
const subjects = (await gitExec(repo, ["log", "--format=%s", "-3", "develop"])).stdout;
|
|
95
|
+
expect(subjects).toContain(POST_REBASE_REGEN_SUBJECT);
|
|
96
|
+
expect((await gitExec(repo, ["show", `develop:${MANIFEST}`])).stdout).toBe(
|
|
97
|
+
"contentHash: new\n",
|
|
98
|
+
);
|
|
99
|
+
}, 30_000);
|
|
100
|
+
|
|
101
|
+
it("AC-2: no drift means no regeneration commit", async () => {
|
|
102
|
+
const repo = await repoWithManifest();
|
|
103
|
+
const s = await session(repo, "nodrift");
|
|
104
|
+
const stub = stubInvoke(() => s.worktree!, {});
|
|
105
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
106
|
+
branch: s.branch!,
|
|
107
|
+
dryRun: false,
|
|
108
|
+
now: NOW,
|
|
109
|
+
invoke: stub.invoke,
|
|
110
|
+
});
|
|
111
|
+
expect(data.integrated).toBe(true);
|
|
112
|
+
expect(data.postRebaseRegen?.committed).toEqual([]);
|
|
113
|
+
expect(data.postRebaseRegen?.sha).toBeUndefined();
|
|
114
|
+
const subjects = (await gitExec(repo, ["log", "--format=%s", "-3", "develop"])).stdout;
|
|
115
|
+
expect(subjects).not.toContain(POST_REBASE_REGEN_SUBJECT);
|
|
116
|
+
}, 30_000);
|
|
117
|
+
|
|
118
|
+
it("AC-3: an owner failure refuses FLOW-INT-12 without committing", async () => {
|
|
119
|
+
const repo = await repoWithManifest();
|
|
120
|
+
const s = await session(repo, "ownerfail");
|
|
121
|
+
const developBefore = (await gitExec(repo, ["rev-parse", "develop"])).stdout.trim();
|
|
122
|
+
const stub = stubInvoke(() => s.worktree!, { fail: true });
|
|
123
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
124
|
+
branch: s.branch!,
|
|
125
|
+
dryRun: false,
|
|
126
|
+
now: NOW,
|
|
127
|
+
invoke: stub.invoke,
|
|
128
|
+
});
|
|
129
|
+
expect(data.integrated).toBe(false);
|
|
130
|
+
expect(data.diagnostics.map((d) => d.ruleId)).toContain("FLOW-INT-12");
|
|
131
|
+
expect((await gitExec(repo, ["rev-parse", "develop"])).stdout.trim()).toBe(developBefore);
|
|
132
|
+
const subjects = (await gitExec(s.worktree!, ["log", "--format=%s", "-3"])).stdout;
|
|
133
|
+
expect(subjects).not.toContain(POST_REBASE_REGEN_SUBJECT);
|
|
134
|
+
}, 30_000);
|
|
135
|
+
|
|
136
|
+
it("AC-5: a non-owned path dirtied by regeneration refuses FLOW-INT-12 without committing", async () => {
|
|
137
|
+
const repo = await repoWithManifest();
|
|
138
|
+
const s = await session(repo, "stray");
|
|
139
|
+
const stub = stubInvoke(() => s.worktree!, {
|
|
140
|
+
content: "contentHash: new\n",
|
|
141
|
+
extra: "stray.txt",
|
|
142
|
+
});
|
|
143
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
144
|
+
branch: s.branch!,
|
|
145
|
+
dryRun: false,
|
|
146
|
+
now: NOW,
|
|
147
|
+
invoke: stub.invoke,
|
|
148
|
+
});
|
|
149
|
+
expect(data.integrated).toBe(false);
|
|
150
|
+
const diag = data.diagnostics.find((d) => d.ruleId === "FLOW-INT-12");
|
|
151
|
+
expect(diag?.message).toContain("stray.txt");
|
|
152
|
+
const subjects = (await gitExec(s.worktree!, ["log", "--format=%s", "-3"])).stdout;
|
|
153
|
+
expect(subjects).not.toContain(POST_REBASE_REGEN_SUBJECT);
|
|
154
|
+
}, 30_000);
|
|
155
|
+
|
|
156
|
+
// Test-Reason: defect REVIEW-CODE-2026-11-12-05 A-1
|
|
157
|
+
it("pre-existing untracked forge state is not judged as owner-dirtied", async () => {
|
|
158
|
+
const repo = await repoWithManifest();
|
|
159
|
+
const s = await session(repo, "forgestate");
|
|
160
|
+
await mkdir(join(s.worktree!, ".forge"), { recursive: true });
|
|
161
|
+
await writeFile(join(s.worktree!, ".forge", "knowledge-conflicts.txt"), "x\n");
|
|
162
|
+
const stub = stubInvoke(() => s.worktree!, { content: "contentHash: new\n" });
|
|
163
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
164
|
+
branch: s.branch!,
|
|
165
|
+
dryRun: false,
|
|
166
|
+
now: NOW,
|
|
167
|
+
invoke: stub.invoke,
|
|
168
|
+
});
|
|
169
|
+
expect(data.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
170
|
+
expect(data.postRebaseRegen?.committed).toEqual([MANIFEST]);
|
|
171
|
+
}, 30_000);
|
|
172
|
+
|
|
173
|
+
// Test-Reason: defect REVIEW-CODE-2026-11-12-05 A-2
|
|
174
|
+
it("a red validate after regeneration refuses with no regeneration commit", async () => {
|
|
175
|
+
const repo = await repoWithManifest();
|
|
176
|
+
const s = await session(repo, "redvalidate");
|
|
177
|
+
const stub = stubInvoke(() => s.worktree!, {
|
|
178
|
+
content: "contentHash: bad\n",
|
|
179
|
+
validateRed: true,
|
|
180
|
+
});
|
|
181
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
182
|
+
branch: s.branch!,
|
|
183
|
+
dryRun: false,
|
|
184
|
+
now: NOW,
|
|
185
|
+
invoke: stub.invoke,
|
|
186
|
+
});
|
|
187
|
+
expect(data.integrated).toBe(false);
|
|
188
|
+
expect(data.diagnostics.find((d) => d.ruleId === "FLOW-INT-12")?.message).toContain(
|
|
189
|
+
"still red",
|
|
190
|
+
);
|
|
191
|
+
const subjects = (await gitExec(s.worktree!, ["log", "--format=%s", "-3"])).stdout;
|
|
192
|
+
expect(subjects).not.toContain(POST_REBASE_REGEN_SUBJECT);
|
|
193
|
+
}, 30_000);
|
|
194
|
+
|
|
195
|
+
// Test-Reason: defect REVIEW-CODE-2026-11-12-05 A-3
|
|
196
|
+
it("standalone without an engine build skips the owners instead of refusing", async () => {
|
|
197
|
+
const repo = await repoWithManifest();
|
|
198
|
+
const s = await session(repo, "standalone");
|
|
199
|
+
const progress: string[] = [];
|
|
200
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
201
|
+
branch: s.branch!,
|
|
202
|
+
dryRun: false,
|
|
203
|
+
now: NOW,
|
|
204
|
+
onProgress: (l: string) => progress.push(l),
|
|
205
|
+
});
|
|
206
|
+
expect(data.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
207
|
+
expect(data.integrated).toBe(true);
|
|
208
|
+
expect(progress.some((l) => l.includes("not runnable here — skipped"))).toBe(true);
|
|
209
|
+
}, 30_000);
|
|
210
|
+
|
|
211
|
+
// Test-Reason: defect REVIEW-CODE-2026-11-12-06 H-N1
|
|
212
|
+
it("a failing regeneration commit refuses FLOW-INT-12 with no new commit", async () => {
|
|
213
|
+
const repo = await repoWithManifest();
|
|
214
|
+
const s = await session(repo, "commitfail");
|
|
215
|
+
const hooks = await mkdtemp(join(tmpdir(), "flow-regen-hooks-"));
|
|
216
|
+
dirs.push(hooks);
|
|
217
|
+
await writeFile(join(hooks, "pre-commit"), "#!/bin/sh\necho refused >&2\nexit 1\n");
|
|
218
|
+
await chmod(join(hooks, "pre-commit"), 0o755);
|
|
219
|
+
await gitExec(s.worktree!, ["config", "core.hooksPath", hooks]);
|
|
220
|
+
const head = (await gitExec(s.worktree!, ["rev-parse", "HEAD"])).stdout.trim();
|
|
221
|
+
const stub = stubInvoke(() => s.worktree!, { content: "contentHash: new\n" });
|
|
222
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
223
|
+
branch: s.branch!,
|
|
224
|
+
dryRun: false,
|
|
225
|
+
now: NOW,
|
|
226
|
+
invoke: stub.invoke,
|
|
227
|
+
});
|
|
228
|
+
expect(data.integrated).toBe(false);
|
|
229
|
+
const diag = data.diagnostics.find((d) => d.ruleId === "FLOW-INT-12");
|
|
230
|
+
expect(diag?.message).toContain("commit failed");
|
|
231
|
+
const subjects = (await gitExec(s.worktree!, ["log", "--format=%s", `${head}..HEAD`])).stdout;
|
|
232
|
+
expect(subjects).not.toContain(POST_REBASE_REGEN_SUBJECT);
|
|
233
|
+
}, 30_000);
|
|
234
|
+
});
|
|
@@ -11,12 +11,14 @@ and a held integration lock is waited out.</purpose>
|
|
|
11
11
|
</non-goals>
|
|
12
12
|
</MODULE_CONTRACT>
|
|
13
13
|
<CHANGE_SUMMARY>
|
|
14
|
-
<item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
|
|
15
14
|
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
16
15
|
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
17
16
|
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
18
17
|
<item>ADR-0128: FLOW-INT-02 names rebase stderr tail + porcelain status when no unmerged paths; cap path list at 20 (+N more) (ADR-0128 F-0188)</item>
|
|
19
|
-
<
|
|
18
|
+
<item>RFC-1574: regenerate derived manifests after the integrate rebase and commit them
|
|
19
|
+
|
|
20
|
+
flow.integrate step (3b) runs GENERATED_BASENAME_OWNERS owners on the rebased tree (opts.invoke ?? standaloneInvoke), commits only owned paths with the fixed subject before the gate, refuses FLOW-INT-12 on owner failure, non-owned dirt or a still-red validate; the preflight no longer writes and refuses only without a resolvable owner.</item>
|
|
21
|
+
<history>RFC-1487, RFC-1515, RFC-1528, RFC-1537, RFC-1538, RFC-1546</history>
|
|
20
22
|
</CHANGE_SUMMARY>
|
|
21
23
|
*/
|
|
22
24
|
|
|
@@ -789,7 +791,7 @@ describe("flow.integrate — RFC-1538 post-lock revalidation, session engine, au
|
|
|
789
791
|
});
|
|
790
792
|
|
|
791
793
|
describe("flow.integrate — recoverable manifest drift (RFC-1546 AC-1)", () => {
|
|
792
|
-
it("sole FLOW-INT-12 drift
|
|
794
|
+
it("sole FLOW-INT-12 drift defers regeneration to the post-rebase step and writes nothing (RFC-1574 AC-4)", async () => {
|
|
793
795
|
const repo = await governedRepo();
|
|
794
796
|
const session = await openSession(repo, "regen");
|
|
795
797
|
const { runIntegratePreflight } = await import("../preflight.ts");
|
|
@@ -825,12 +827,11 @@ describe("flow.integrate — recoverable manifest drift (RFC-1546 AC-1)", () =>
|
|
|
825
827
|
},
|
|
826
828
|
});
|
|
827
829
|
expect(preflight.ok).toBe(true);
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
]);
|
|
830
|
+
// RFC-1574: the preflight never invokes the generator — step (3b) does,
|
|
831
|
+
// on the rebased tree, and commits the result.
|
|
832
|
+
expect(invoked).toEqual(["ecosystem.manifest.validate", "friction.validate"]);
|
|
833
|
+
const status = await gitExec(session.worktree!, ["status", "--porcelain"]);
|
|
834
|
+
expect(status.stdout.trim(), "the preflight must leave the worktree clean").toBe("");
|
|
834
835
|
}, 20_000);
|
|
835
836
|
|
|
836
837
|
it("a second violation alongside drift refuses without regenerating", async () => {
|
package/os/flow/tests/helpers.ts
CHANGED
|
@@ -13,11 +13,13 @@ flow.install does it (committed hooks dir + core.hooksPath).</purpose>
|
|
|
13
13
|
<item>FORGE_FLOW_OP is always set explicitly ("" for the unset cases) so a leaked outer value cannot make tests non-deterministic.</item>
|
|
14
14
|
</KEY_DECISIONS>
|
|
15
15
|
<CHANGE_SUMMARY>
|
|
16
|
-
<item>RFC-1486: review r1 — committed-state adoption gate, uncommitted-hook committedness, step-failure trail, idempotency declaration, lazy asset resolution</item>
|
|
17
16
|
<item>RFC-1490: pre-merge-commit guard mode + per-mode op vocabulary; amends the wave-1 guard RFC's backmerge escape (AC-11)</item>
|
|
18
17
|
<item>RFC-1491: step 2 — pre-push guard mode, install steps pre-push + markers, FLOW-10</item>
|
|
19
18
|
<item>RFC-1491: step 5 — flow.push atomic outbound path + extract publication</item>
|
|
20
19
|
<item>RFC-1502: steps 1-5 — release-prepare hook, pre-tag extract verification, ordered steps</item>
|
|
20
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
21
|
+
|
|
22
|
+
Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
|
|
21
23
|
<history>RFC-1486</history>
|
|
22
24
|
</CHANGE_SUMMARY>
|
|
23
25
|
*/
|
|
@@ -39,11 +41,7 @@ import {
|
|
|
39
41
|
const PREMERGE_MANAGED_BLOCK = managedBlock("pre-merge-commit");
|
|
40
42
|
const PREPUSH_MANAGED_BLOCK = managedBlock("pre-push");
|
|
41
43
|
|
|
42
|
-
export {
|
|
43
|
-
GUARD_BEGIN_MARKER,
|
|
44
|
-
GUARD_END_MARKER,
|
|
45
|
-
MANAGED_BLOCK,
|
|
46
|
-
};
|
|
44
|
+
export { GUARD_BEGIN_MARKER, GUARD_END_MARKER, MANAGED_BLOCK };
|
|
47
45
|
|
|
48
46
|
/** Absolute path of the shipped guard asset — resolved on first use. */
|
|
49
47
|
export const GUARD_ASSET = resolveGuardAssetPath();
|
|
@@ -61,6 +59,40 @@ export function gitExec(
|
|
|
61
59
|
* git config may leak in). `seedCommit` creates a root commit — skipped for
|
|
62
60
|
* unborn-HEAD cases.
|
|
63
61
|
*/
|
|
62
|
+
/**
|
|
63
|
+
* RFC-1580: flow.integrate spawns `<primary>/node_modules/.bin/forge
|
|
64
|
+
* correctness.gate` and refuses FLOW-INT-18 when it is missing. Test
|
|
65
|
+
* primaries get a stand-in that answers a passing gate (or the verdict in
|
|
66
|
+
* `<primary>/.correctness-gate.json` when a test drops one there). The path
|
|
67
|
+
* is excluded via .git/info/exclude so it never reads as primary dirt.
|
|
68
|
+
*/
|
|
69
|
+
export async function installFakePrimaryForge(repo: string): Promise<void> {
|
|
70
|
+
const bin = join(repo, "node_modules", ".bin");
|
|
71
|
+
await mkdir(bin, { recursive: true });
|
|
72
|
+
const script = join(bin, "forge");
|
|
73
|
+
await writeFile(
|
|
74
|
+
script,
|
|
75
|
+
[
|
|
76
|
+
"#!/bin/sh",
|
|
77
|
+
'if [ "$1" = "correctness.gate" ]; then',
|
|
78
|
+
' primary="$(dirname "$(dirname "$(dirname "$0")")")"',
|
|
79
|
+
' if [ -f "$primary/.correctness-gate.json" ]; then cat "$primary/.correctness-gate.json"; exit "$(cat "$primary/.correctness-gate.exit" 2>/dev/null || echo 0)"; fi',
|
|
80
|
+
' echo \'{"command":"correctness.gate","mode":"warn","status":"pass","bundlePath":null,"violations":[],"weakenings":[],"acceptedWeakening":null}\'',
|
|
81
|
+
" exit 0",
|
|
82
|
+
"fi",
|
|
83
|
+
'echo "fake forge: unsupported $*" >&2',
|
|
84
|
+
"exit 64",
|
|
85
|
+
"",
|
|
86
|
+
].join("\n"),
|
|
87
|
+
);
|
|
88
|
+
await chmod(script, 0o755);
|
|
89
|
+
const exclude = join(repo, ".git", "info", "exclude");
|
|
90
|
+
await mkdir(join(repo, ".git", "info"), { recursive: true });
|
|
91
|
+
await writeFile(exclude, "node_modules/\n.correctness-gate.json\n.correctness-gate.exit\n", {
|
|
92
|
+
flag: "a",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
64
96
|
export async function initRepo(opts?: {
|
|
65
97
|
branch?: string;
|
|
66
98
|
seedCommit?: boolean;
|
|
@@ -72,6 +104,7 @@ export async function initRepo(opts?: {
|
|
|
72
104
|
await gitExec(dir, ["config", "user.email", "flow-test@example.invalid"]);
|
|
73
105
|
await gitExec(dir, ["config", "user.name", "flow-test"]);
|
|
74
106
|
await gitExec(dir, ["config", "commit.gpgsign", "false"]);
|
|
107
|
+
await installFakePrimaryForge(dir);
|
|
75
108
|
if (opts?.seedCommit !== false) {
|
|
76
109
|
await writeFile(join(dir, "seed.txt"), "seed\n");
|
|
77
110
|
await gitExec(dir, ["add", "seed.txt"]);
|
|
@@ -104,18 +137,12 @@ export async function installGuard(repo: string): Promise<void> {
|
|
|
104
137
|
}
|
|
105
138
|
|
|
106
139
|
/** Attempt a commit; env overrides merge over process.env (set "" to neutralize). */
|
|
107
|
-
export function tryCommit(
|
|
108
|
-
repo: string,
|
|
109
|
-
env?: Record<string, string>,
|
|
110
|
-
): Promise<ExecResult> {
|
|
140
|
+
export function tryCommit(repo: string, env?: Record<string, string>): Promise<ExecResult> {
|
|
111
141
|
return gitExec(repo, ["commit", "--allow-empty", "-m", "probe"], env);
|
|
112
142
|
}
|
|
113
143
|
|
|
114
144
|
/** Invoke the installed guard directly with HEAD on the current branch. */
|
|
115
|
-
export function runGuardDirect(
|
|
116
|
-
repo: string,
|
|
117
|
-
env?: Record<string, string>,
|
|
118
|
-
): Promise<ExecResult> {
|
|
145
|
+
export function runGuardDirect(repo: string, env?: Record<string, string>): Promise<ExecResult> {
|
|
119
146
|
return ambientIo.exec("sh", [join(repo, "hooks", "flow-guard.sh"), "pre-commit"], {
|
|
120
147
|
cwd: repo,
|
|
121
148
|
env,
|
|
@@ -145,10 +172,7 @@ export async function initRepoWithOrigin(
|
|
|
145
172
|
await gitExec(repo, ["config", "user.name", "flow-test"]);
|
|
146
173
|
await gitExec(repo, ["config", "commit.gpgsign", "false"]);
|
|
147
174
|
await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
|
|
148
|
-
await writeFile(
|
|
149
|
-
join(repo, "pnpm-workspace.yaml"),
|
|
150
|
-
"packages:\n - packages/*\n",
|
|
151
|
-
);
|
|
175
|
+
await writeFile(join(repo, "pnpm-workspace.yaml"), "packages:\n - packages/*\n");
|
|
152
176
|
await writeFile(join(repo, "seed.txt"), "seed\n");
|
|
153
177
|
await gitExec(repo, ["add", "-A"]);
|
|
154
178
|
const seed = await gitExec(repo, ["commit", "-m", "seed"]);
|
|
@@ -162,6 +186,7 @@ export async function initRepoWithOrigin(
|
|
|
162
186
|
const push = await gitExec(repo, ["push", "-u", "origin", "develop", "main"]);
|
|
163
187
|
if (push.exitCode !== 0) throw new Error(`initial push failed: ${push.stderr}`);
|
|
164
188
|
|
|
189
|
+
await installFakePrimaryForge(repo);
|
|
165
190
|
if (opts?.fakeExtract) await installFakeRepoExtract(repo, extractLog);
|
|
166
191
|
return { repo, origin, extractLog, parent };
|
|
167
192
|
}
|
|
@@ -176,10 +201,7 @@ export async function initRepoWithOrigin(
|
|
|
176
201
|
* env — or drop a `.fail-extract` marker in the caller's cwd — to make it
|
|
177
202
|
* exit 3 (FLOW-PUSH-05 / FLOW-CUT-13 tests).
|
|
178
203
|
*/
|
|
179
|
-
export async function installFakeRepoExtract(
|
|
180
|
-
repo: string,
|
|
181
|
-
log: string,
|
|
182
|
-
): Promise<string> {
|
|
204
|
+
export async function installFakeRepoExtract(repo: string, log: string): Promise<string> {
|
|
183
205
|
const bin = join(repo, "node_modules", ".bin");
|
|
184
206
|
await mkdir(bin, { recursive: true });
|
|
185
207
|
const script = join(bin, "repo-extract");
|
|
@@ -228,8 +250,7 @@ git -C "$dest" remote add origin "$dorigin"
|
|
|
228
250
|
|
|
229
251
|
/** Switch to a branch, creating it when it does not exist yet. */
|
|
230
252
|
export async function checkoutOrCreate(repo: string, name: string): Promise<void> {
|
|
231
|
-
const exists =
|
|
232
|
-
(await gitExec(repo, ["branch", "--list", name])).stdout.trim().length > 0;
|
|
253
|
+
const exists = (await gitExec(repo, ["branch", "--list", name])).stdout.trim().length > 0;
|
|
233
254
|
const result = exists
|
|
234
255
|
? await gitExec(repo, ["switch", name])
|
|
235
256
|
: await gitExec(repo, ["switch", "-c", name]);
|
package/os/gate-run/status.ts
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
<item>RFC-1568: step 4 — gate.run.status handler</item>
|
|
15
15
|
<item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
|
|
16
16
|
<item>RFC-1562: rfc-1562 acceptance evidence, regenerated manifests, gate contract tag</item>
|
|
17
|
+
<item>RFC-1575: gate.run.status uncacheable, --wait ends with a verdict
|
|
18
|
+
|
|
19
|
+
cacheable: false keeps live gate-run state out of the kernel result cache; --id --wait returns data.wait {requestedSeconds, waitedMs, outcome: completed|budget-expired} and a summary suffix. CMD-MAN-06 dropped after its live census (~100 warnings, no true positive): falsified route in the plan, ledger Q-8.</item>
|
|
17
20
|
</CHANGE_SUMMARY>
|
|
18
21
|
*/
|
|
19
22
|
|
|
@@ -30,10 +33,23 @@ import type { GateRunRecord, GateRunStatus } from "./types.ts";
|
|
|
30
33
|
const WAIT_MAX_SECONDS = 600;
|
|
31
34
|
const WAIT_POLL_MS = 2_000;
|
|
32
35
|
|
|
36
|
+
/** RFC-1575: terminal verdict of a `--wait` — whether the run left `running` or the budget ran out. */
|
|
37
|
+
export interface GateRunWaitVerdict {
|
|
38
|
+
requestedSeconds: number;
|
|
39
|
+
waitedMs: number;
|
|
40
|
+
/** completed: the run left `running` during or before the wait; budget-expired: still running at the deadline */
|
|
41
|
+
outcome: "completed" | "budget-expired";
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
export interface GateRunStatusData {
|
|
34
45
|
runs: Array<GateRunRecord & { status: GateRunStatus }>;
|
|
46
|
+
/** RFC-1575: present only for `--id` with `--wait` > 0. */
|
|
47
|
+
wait?: GateRunWaitVerdict;
|
|
35
48
|
}
|
|
36
49
|
|
|
50
|
+
/** RFC-1575 FI-1 — summary suffix when the wait budget expires. */
|
|
51
|
+
export const WAIT_EXPIRED_SUFFIX = "wait budget expired, still running";
|
|
52
|
+
|
|
37
53
|
function flag(input: ForgeCommandInput, name: string): string | undefined {
|
|
38
54
|
const v = input.flags[name];
|
|
39
55
|
return typeof v === "string" ? v : undefined;
|
|
@@ -79,7 +95,8 @@ export async function runGateRunStatus(
|
|
|
79
95
|
const waitSeconds = waitRaw === undefined ? 0 : Math.min(Number(waitRaw) || 0, WAIT_MAX_SECONDS);
|
|
80
96
|
|
|
81
97
|
if (id !== undefined) {
|
|
82
|
-
const
|
|
98
|
+
const waitStarted = Date.now();
|
|
99
|
+
const deadline = waitStarted + waitSeconds * 1_000;
|
|
83
100
|
for (;;) {
|
|
84
101
|
const all = await listGateRuns(common, io);
|
|
85
102
|
const found = all.find((r) => r.runId === id);
|
|
@@ -95,10 +112,23 @@ export async function runGateRunStatus(
|
|
|
95
112
|
}
|
|
96
113
|
const classified = withClassified(found);
|
|
97
114
|
if (classified.status !== "running" || Date.now() >= deadline) {
|
|
115
|
+
if (waitSeconds <= 0) {
|
|
116
|
+
return { exitCode: 0, summary: formatRunLine(classified), data: { runs: [classified] } };
|
|
117
|
+
}
|
|
118
|
+
const waitedMs = Date.now() - waitStarted;
|
|
119
|
+
const wait: GateRunWaitVerdict = {
|
|
120
|
+
requestedSeconds: waitSeconds,
|
|
121
|
+
waitedMs,
|
|
122
|
+
outcome: classified.status === "running" ? "budget-expired" : "completed",
|
|
123
|
+
};
|
|
124
|
+
const suffix =
|
|
125
|
+
wait.outcome === "budget-expired"
|
|
126
|
+
? ` — ${WAIT_EXPIRED_SUFFIX} (${waitSeconds} s)`
|
|
127
|
+
: ` — left running after ${Math.round(waitedMs / 1000)} s`;
|
|
98
128
|
return {
|
|
99
129
|
exitCode: 0,
|
|
100
|
-
summary: formatRunLine(classified),
|
|
101
|
-
data: { runs: [classified] },
|
|
130
|
+
summary: formatRunLine(classified) + suffix,
|
|
131
|
+
data: { runs: [classified], wait },
|
|
102
132
|
};
|
|
103
133
|
}
|
|
104
134
|
await new Promise((r) =>
|
|
@@ -151,6 +181,9 @@ export const gateRunStatusCommand = {
|
|
|
151
181
|
],
|
|
152
182
|
mutatesState: false,
|
|
153
183
|
execOnReadOnly: true,
|
|
184
|
+
// RFC-1575: live process state — never served from the kernel result cache
|
|
185
|
+
// (the records live under the git common dir, outside any cache digest).
|
|
186
|
+
cacheable: false,
|
|
154
187
|
reads: ["forge/gate-runs/**"],
|
|
155
188
|
flags: {
|
|
156
189
|
id: { kind: "string" as const, description: "One run id." },
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1575 AC-1..AC-3 — gate.run.status is excluded from the kernel result cache, and `--id --wait` ends with a verdict: `completed` when the run leaves `running`, `budget-expired` when the deadline passes first.</purpose>
|
|
4
|
+
<non-goals>
|
|
5
|
+
<item>No detached child — records are written by hand under a temp repo's common dir.</item>
|
|
6
|
+
</non-goals>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
*/
|
|
9
|
+
// Test-Reason: requirement AC-1, AC-2, AC-3 (RFC-1575)
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
|
|
12
|
+
import { mkdtemp, realpath, rm } from "node:fs/promises";
|
|
13
|
+
import { hostname, tmpdir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
16
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
17
|
+
import { saveGateRun } from "../record.ts";
|
|
18
|
+
import { WAIT_EXPIRED_SUFFIX, gateRunStatusCommand, runGateRunStatus } from "../status.ts";
|
|
19
|
+
import { GATE_RUN_SCHEMA, type GateRunRecord } from "../types.ts";
|
|
20
|
+
|
|
21
|
+
const dirs: string[] = [];
|
|
22
|
+
afterEach(async () => {
|
|
23
|
+
for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
async function repo(): Promise<string> {
|
|
27
|
+
const dir = await realpath(await mkdtemp(join(tmpdir(), "gate-run-status-")));
|
|
28
|
+
dirs.push(dir);
|
|
29
|
+
const init = spawnSync("git", ["init", "-q", dir]);
|
|
30
|
+
if (init.status !== 0) throw new Error(`git init failed: ${init.stderr}`);
|
|
31
|
+
return dir;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function record(runId: string, over: Partial<GateRunRecord> = {}): GateRunRecord {
|
|
35
|
+
return {
|
|
36
|
+
schema: GATE_RUN_SCHEMA,
|
|
37
|
+
runId,
|
|
38
|
+
command: "flow.integrate",
|
|
39
|
+
argv: [],
|
|
40
|
+
cwd: ".",
|
|
41
|
+
detached: true,
|
|
42
|
+
pid: process.pid,
|
|
43
|
+
host: hostname(),
|
|
44
|
+
startedAt: new Date().toISOString(),
|
|
45
|
+
status: "running",
|
|
46
|
+
...over,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const silent = { section() {}, info() {}, warn() {}, error() {}, success() {} };
|
|
51
|
+
const ctx = (root: string) =>
|
|
52
|
+
({ workspaceRoot: root, logger: silent, dryRun: false, outputFormat: "json" }) as never;
|
|
53
|
+
|
|
54
|
+
describe("gate.run.status (RFC-1575)", () => {
|
|
55
|
+
it("AC-1: declares cacheable: false", () => {
|
|
56
|
+
expect(gateRunStatusCommand.cacheable, "live state must never come from the result cache").toBe(
|
|
57
|
+
false,
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("AC-2: --wait reports completed when the run leaves running", async () => {
|
|
62
|
+
const root = await repo();
|
|
63
|
+
const io = resolveIo(undefined);
|
|
64
|
+
const common = join(root, ".git");
|
|
65
|
+
await saveGateRun(common, record("gr-a"), io);
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
void saveGateRun(
|
|
68
|
+
common,
|
|
69
|
+
record("gr-a", { status: "succeeded", exitCode: 0, endedAt: new Date().toISOString() }),
|
|
70
|
+
io,
|
|
71
|
+
);
|
|
72
|
+
}, 300);
|
|
73
|
+
const result = await runGateRunStatus(
|
|
74
|
+
{ argv: [], flags: { id: "gr-a", wait: "10" } },
|
|
75
|
+
ctx(root),
|
|
76
|
+
);
|
|
77
|
+
expect(result.data?.runs[0]?.status).toBe("succeeded");
|
|
78
|
+
expect(result.data?.wait?.outcome).toBe("completed");
|
|
79
|
+
expect(result.summary).toContain("left running after");
|
|
80
|
+
}, 20_000);
|
|
81
|
+
|
|
82
|
+
it("AC-3: --wait reports budget-expired when the run is still running at the deadline", async () => {
|
|
83
|
+
const root = await repo();
|
|
84
|
+
const io = resolveIo(undefined);
|
|
85
|
+
await saveGateRun(join(root, ".git"), record("gr-b"), io);
|
|
86
|
+
const result = await runGateRunStatus(
|
|
87
|
+
{ argv: [], flags: { id: "gr-b", wait: "1" } },
|
|
88
|
+
ctx(root),
|
|
89
|
+
);
|
|
90
|
+
expect(result.data?.runs[0]?.status).toBe("running");
|
|
91
|
+
expect(result.data?.wait?.outcome).toBe("budget-expired");
|
|
92
|
+
expect(result.summary).toContain(WAIT_EXPIRED_SUFFIX);
|
|
93
|
+
}, 20_000);
|
|
94
|
+
|
|
95
|
+
it("no --wait means no verdict field", async () => {
|
|
96
|
+
const root = await repo();
|
|
97
|
+
await saveGateRun(join(root, ".git"), record("gr-c"), resolveIo(undefined));
|
|
98
|
+
const result = await runGateRunStatus({ argv: [], flags: { id: "gr-c" } }, ctx(root));
|
|
99
|
+
expect(result.data?.wait).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Test-Reason: regression lost-run wait mapping (REVIEW-CODE-2026-11-12-05 E-2)
|
|
103
|
+
it("a dead-holder (lost) run ends the wait as completed — it left running", async () => {
|
|
104
|
+
const root = await repo();
|
|
105
|
+
const dead = spawnSync(process.execPath, ["-e", ""]).pid!;
|
|
106
|
+
await saveGateRun(join(root, ".git"), record("gr-d", { pid: dead }), resolveIo(undefined));
|
|
107
|
+
const result = await runGateRunStatus(
|
|
108
|
+
{ argv: [], flags: { id: "gr-d", wait: "5" } },
|
|
109
|
+
ctx(root),
|
|
110
|
+
);
|
|
111
|
+
expect(result.data?.runs[0]?.status).toBe("lost");
|
|
112
|
+
expect(result.data?.wait?.outcome).toBe("completed");
|
|
113
|
+
}, 20_000);
|
|
114
|
+
});
|