@warpgogol/forge 9.3.1 → 9.4.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/AGENTS.md +32 -0
- package/CHANGELOG.md +40 -0
- package/README.md +6 -4
- package/README.uk.md +10 -8
- package/bin/cli.ts +4 -4
- package/dist/bin/cli.js +4 -4
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
- package/dist/os/adr/handlers/list-create.js +23 -2
- package/dist/os/adr/handlers/list-create.js.map +1 -1
- package/dist/os/adr/types.d.ts +2 -0
- package/dist/os/adr/types.d.ts.map +1 -1
- package/dist/os/adr/types.js +2 -2
- package/dist/os/adr/types.js.map +1 -1
- package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
- package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
- package/dist/os/compass/handlers/git-revision.d.ts +2 -0
- package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
- package/dist/os/compass/handlers/git-revision.js +7 -2
- package/dist/os/compass/handlers/git-revision.js.map +1 -1
- package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
- package/dist/os/compass/handlers/summary-record.js +24 -14
- package/dist/os/compass/handlers/summary-record.js.map +1 -1
- package/dist/os/conformance/conformance.module.d.ts.map +1 -1
- package/dist/os/conformance/conformance.module.js +21 -4
- package/dist/os/conformance/conformance.module.js.map +1 -1
- package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
- package/dist/os/conformance/handlers/conformance-validate.js +64 -8
- package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
- package/dist/os/core/archive-regen.d.ts +99 -0
- package/dist/os/core/archive-regen.d.ts.map +1 -0
- package/dist/os/core/archive-regen.js +220 -0
- package/dist/os/core/archive-regen.js.map +1 -0
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +159 -18
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +8 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
- package/dist/os/core/handlers/package-health.d.ts +130 -0
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +548 -7
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +5 -2
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +3 -1
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/dirty-classify.d.ts +51 -0
- package/dist/os/flow/dirty-classify.d.ts.map +1 -0
- package/dist/os/flow/dirty-classify.js +83 -0
- package/dist/os/flow/dirty-classify.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +110 -19
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/gate-engine.d.ts +13 -0
- package/dist/os/flow/gate-engine.d.ts.map +1 -0
- package/dist/os/flow/gate-engine.js +32 -0
- package/dist/os/flow/gate-engine.js.map +1 -0
- package/dist/os/flow/git.d.ts +45 -4
- package/dist/os/flow/git.d.ts.map +1 -1
- package/dist/os/flow/git.js +95 -27
- package/dist/os/flow/git.js.map +1 -1
- package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-backmerge.js +12 -5
- package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +25 -3
- package/dist/os/flow/handlers/flow-check.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +75 -38
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-discard.js +33 -5
- package/dist/os/flow/handlers/flow-discard.js.map +1 -1
- package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-fix.js +13 -10
- package/dist/os/flow/handlers/flow-fix.js.map +1 -1
- package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-hold.js +13 -7
- package/dist/os/flow/handlers/flow-hold.js.map +1 -1
- package/dist/os/flow/handlers/flow-install.d.ts +2 -1
- package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-install.js +56 -13
- package/dist/os/flow/handlers/flow-install.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +54 -2
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +614 -65
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts +14 -0
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +117 -12
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
- package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-peers.js +99 -0
- package/dist/os/flow/handlers/flow-peers.js.map +1 -0
- package/dist/os/flow/handlers/flow-status.d.ts +13 -0
- package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-status.js +35 -14
- package/dist/os/flow/handlers/flow-status.js.map +1 -1
- package/dist/os/flow/index.d.ts +3 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +7 -2
- package/dist/os/flow/index.js.map +1 -1
- package/dist/os/flow/line-version.d.ts.map +1 -1
- package/dist/os/flow/line-version.js +2 -1
- package/dist/os/flow/line-version.js.map +1 -1
- package/dist/os/flow/locks.d.ts +37 -1
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +34 -14
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/flow/ops-registry.d.ts +33 -0
- package/dist/os/flow/ops-registry.d.ts.map +1 -0
- package/dist/os/flow/ops-registry.js +177 -0
- package/dist/os/flow/ops-registry.js.map +1 -0
- package/dist/os/flow/preflight.d.ts +157 -0
- package/dist/os/flow/preflight.d.ts.map +1 -0
- package/dist/os/flow/preflight.js +772 -0
- package/dist/os/flow/preflight.js.map +1 -0
- package/dist/os/flow/publish.d.ts +7 -0
- package/dist/os/flow/publish.d.ts.map +1 -1
- package/dist/os/flow/publish.js +165 -3
- package/dist/os/flow/publish.js.map +1 -1
- package/dist/os/flow/registry.d.ts +26 -1
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +27 -6
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/flow/scripts.d.ts +4 -0
- package/dist/os/flow/scripts.d.ts.map +1 -1
- package/dist/os/flow/scripts.js +8 -2
- package/dist/os/flow/scripts.js.map +1 -1
- package/dist/os/flow/session-checkout.d.ts +33 -0
- package/dist/os/flow/session-checkout.d.ts.map +1 -0
- package/dist/os/flow/session-checkout.js +151 -0
- package/dist/os/flow/session-checkout.js.map +1 -0
- package/dist/os/flow/standalone-invoke.d.ts +11 -0
- package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
- package/dist/os/flow/standalone-invoke.js +75 -0
- package/dist/os/flow/standalone-invoke.js.map +1 -0
- package/dist/os/flow/worktree-path.d.ts.map +1 -1
- package/dist/os/flow/worktree-path.js +9 -3
- package/dist/os/flow/worktree-path.js.map +1 -1
- package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
- package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
- package/dist/os/instructions/handlers/budget-validate.js +12 -4
- package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
- package/dist/os/instructions/instructions.module.d.ts.map +1 -1
- package/dist/os/instructions/instructions.module.js +4 -1
- package/dist/os/instructions/instructions.module.js.map +1 -1
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +12 -8
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/importer-block.d.ts +19 -0
- package/dist/os/mission/importer-block.d.ts.map +1 -0
- package/dist/os/mission/importer-block.js +124 -0
- package/dist/os/mission/importer-block.js.map +1 -0
- package/dist/os/mission/lockfile.d.ts +17 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -1
- package/dist/os/mission/lockfile.js +38 -0
- package/dist/os/mission/lockfile.js.map +1 -1
- package/dist/os/mission/open-missions.d.ts +8 -0
- package/dist/os/mission/open-missions.d.ts.map +1 -0
- package/dist/os/mission/open-missions.js +42 -0
- package/dist/os/mission/open-missions.js.map +1 -0
- package/dist/os/queue/manifest.d.ts.map +1 -1
- package/dist/os/queue/manifest.js +11 -1
- package/dist/os/queue/manifest.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts +14 -0
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +18 -10
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/decision-log.d.ts.map +1 -1
- package/dist/os/rfc/decision-log.js +11 -2
- package/dist/os/rfc/decision-log.js.map +1 -1
- package/dist/os/rfc/frontmatter-io.d.ts +23 -0
- package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
- package/dist/os/rfc/frontmatter-io.js +82 -1
- package/dist/os/rfc/frontmatter-io.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
- package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +16 -3
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
- package/dist/os/rfc/handlers/index-graph.js +5 -4
- package/dist/os/rfc/handlers/index-graph.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +107 -10
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
- package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +77 -5
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate.js +64 -6
- package/dist/os/rfc/handlers/validate.js.map +1 -1
- package/dist/os/rfc/next-id.d.ts +38 -0
- package/dist/os/rfc/next-id.d.ts.map +1 -0
- package/dist/os/rfc/next-id.js +165 -0
- package/dist/os/rfc/next-id.js.map +1 -0
- package/dist/os/rfc/probe-batch.d.ts.map +1 -1
- package/dist/os/rfc/probe-batch.js +6 -1
- package/dist/os/rfc/probe-batch.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +36 -8
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +42 -6
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +6 -6
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +1 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +81 -28
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-origin.d.ts +8 -0
- package/dist/os/rfc/verification-origin.d.ts.map +1 -1
- package/dist/os/rfc/verification-origin.js +47 -0
- package/dist/os/rfc/verification-origin.js.map +1 -1
- package/dist/os/session/handlers/save.d.ts.map +1 -1
- package/dist/os/session/handlers/save.js +31 -7
- package/dist/os/session/handlers/save.js.map +1 -1
- package/dist/os/spec/spec-schema.d.ts +8 -0
- package/dist/os/spec/spec-schema.d.ts.map +1 -1
- package/dist/os/spec/spec-schema.js +1 -0
- package/dist/os/spec/spec-schema.js.map +1 -1
- package/dist/os/spec/spec-status.d.ts +8 -0
- package/dist/os/spec/spec-status.d.ts.map +1 -1
- package/dist/os/spec/spec-status.js +18 -6
- package/dist/os/spec/spec-status.js.map +1 -1
- package/dist/os/spec/spec-validate.d.ts.map +1 -1
- package/dist/os/spec/spec-validate.js +62 -15
- package/dist/os/spec/spec-validate.js.map +1 -1
- package/dist/os/spec/spec.module.d.ts.map +1 -1
- package/dist/os/spec/spec.module.js +13 -5
- package/dist/os/spec/spec.module.js.map +1 -1
- package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
- package/dist/os/system/handlers/system-map-validate.js +2 -1
- package/dist/os/system/handlers/system-map-validate.js.map +1 -1
- package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
- package/dist/os/system/handlers/system-outbox-scan.js +54 -6
- package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-collect.js +11 -5
- package/dist/os/system/handlers/system-task-collect.js.map +1 -1
- package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-create.js +6 -1
- package/dist/os/system/handlers/system-task-create.js.map +1 -1
- package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
- package/dist/os/system/handlers/system-versionset-record.js +246 -6
- package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
- package/dist/os/system/repo.d.ts +1 -1
- package/dist/os/system/repo.d.ts.map +1 -1
- package/dist/os/system/repo.js +53 -3
- package/dist/os/system/repo.js.map +1 -1
- package/dist/os/system/scenario-schemas.d.ts +109 -3
- package/dist/os/system/scenario-schemas.d.ts.map +1 -1
- package/dist/os/system/scenario-schemas.js +66 -10
- package/dist/os/system/scenario-schemas.js.map +1 -1
- package/dist/os/system/system.module.d.ts.map +1 -1
- package/dist/os/system/system.module.js +69 -17
- package/dist/os/system/system.module.js.map +1 -1
- package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
- package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
- package/dist/os/system/tests/contract-fixtures.js +109 -0
- package/dist/os/system/tests/contract-fixtures.js.map +1 -0
- package/dist/src/config/forge-config.d.ts +54 -18
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +41 -9
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/conformance/index.d.ts +6 -0
- package/dist/src/conformance/index.d.ts.map +1 -1
- package/dist/src/conformance/index.js +36 -1
- package/dist/src/conformance/index.js.map +1 -1
- package/dist/src/formal/proof-runner.d.ts.map +1 -1
- package/dist/src/formal/proof-runner.js +10 -2
- package/dist/src/formal/proof-runner.js.map +1 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
- package/dist/src/onboarding/agents-generate.js +4 -4
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.js +3 -1
- package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
- package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
- package/dist/src/onboarding/prettierignore.js +2 -0
- package/dist/src/onboarding/prettierignore.js.map +1 -1
- package/dist/src/onboarding/scaffold-project.js +2 -2
- package/dist/src/onboarding/scaffold-project.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +14 -2
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
- package/dist/src/onboarding/workspace-discovery.js +3 -1
- package/dist/src/onboarding/workspace-discovery.js.map +1 -1
- package/dist/src/skill-schema.d.ts +3 -0
- package/dist/src/skill-schema.d.ts.map +1 -1
- package/dist/src/skill-schema.js +9 -2
- package/dist/src/skill-schema.js.map +1 -1
- package/dist/src/spec/resolve-spec-source.d.ts +45 -0
- package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
- package/dist/src/spec/resolve-spec-source.js +153 -0
- package/dist/src/spec/resolve-spec-source.js.map +1 -0
- package/dist/src/utils/command-inventory.d.ts +28 -0
- package/dist/src/utils/command-inventory.d.ts.map +1 -0
- package/dist/src/utils/command-inventory.js +84 -0
- package/dist/src/utils/command-inventory.js.map +1 -0
- package/dist/src/utils/io.d.ts.map +1 -1
- package/dist/src/utils/io.js +6 -1
- package/dist/src/utils/io.js.map +1 -1
- package/dist/src/utils/repo-path.d.ts +10 -0
- package/dist/src/utils/repo-path.d.ts.map +1 -0
- package/dist/src/utils/repo-path.js +52 -0
- package/dist/src/utils/repo-path.js.map +1 -0
- package/dist/src/utils/spawn.d.ts +23 -0
- package/dist/src/utils/spawn.d.ts.map +1 -0
- package/dist/src/utils/spawn.js +83 -0
- package/dist/src/utils/spawn.js.map +1 -0
- package/docs/branch-model.md +1 -1
- package/docs/guides/existing-project.md +1 -1
- package/docs/maintainers/publishing.md +1 -1
- package/docs/reference/cli.md +8 -2
- package/docs/reference/profiles.md +1 -1
- package/os/adr/handlers/list-create.ts +26 -2
- package/os/adr/types.ts +4 -2
- package/os/compass/handlers/compass-audit-handler.ts +6 -1
- package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
- package/os/compass/handlers/git-revision.ts +8 -2
- package/os/compass/handlers/summary-record.ts +25 -14
- package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
- package/os/conformance/conformance.module.ts +21 -4
- package/os/conformance/handlers/conformance-validate.ts +108 -16
- package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
- package/os/core/archive-regen.ts +279 -0
- package/os/core/core.module.ts +176 -29
- package/os/core/docs-archive.test.ts +413 -3
- package/os/core/handlers/assets-helpers.ts +8 -3
- package/os/core/handlers/forge-autonomy-validate.ts +3 -1
- package/os/core/handlers/package-health.test.ts +418 -4
- package/os/core/handlers/package-health.ts +629 -7
- package/os/core/handlers/release-prepare.ts +5 -2
- package/os/flow/digest.ts +3 -1
- package/os/flow/dirty-classify.ts +120 -0
- package/os/flow/flow.module.ts +119 -24
- package/os/flow/gate-engine.ts +45 -0
- package/os/flow/git.ts +117 -29
- package/os/flow/handlers/flow-backmerge.ts +14 -4
- package/os/flow/handlers/flow-check.ts +27 -2
- package/os/flow/handlers/flow-cut.ts +124 -56
- package/os/flow/handlers/flow-discard.ts +33 -5
- package/os/flow/handlers/flow-fix.ts +22 -10
- package/os/flow/handlers/flow-hold.ts +20 -7
- package/os/flow/handlers/flow-install.ts +59 -12
- package/os/flow/handlers/flow-integrate.ts +933 -180
- package/os/flow/handlers/flow-open.ts +135 -11
- package/os/flow/handlers/flow-peers.ts +142 -0
- package/os/flow/handlers/flow-status.ts +45 -13
- package/os/flow/index.ts +8 -2
- package/os/flow/line-version.ts +2 -1
- package/os/flow/locks.ts +56 -14
- package/os/flow/ops-registry.ts +194 -0
- package/os/flow/preflight.ts +974 -0
- package/os/flow/publish.ts +200 -5
- package/os/flow/registry.ts +43 -7
- package/os/flow/scripts.ts +13 -2
- package/os/flow/session-checkout.ts +186 -0
- package/os/flow/standalone-invoke.ts +85 -0
- package/os/flow/tests/dirty-classify.test.ts +251 -0
- package/os/flow/tests/fixtures/branch-names.yaml +40 -40
- package/os/flow/tests/flow-cut.test.ts +21 -0
- package/os/flow/tests/flow-discard.test.ts +32 -0
- package/os/flow/tests/flow-guard-parity.test.ts +10 -2
- package/os/flow/tests/flow-install.test.ts +7 -3
- package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
- package/os/flow/tests/flow-integrate.preflight.test.ts +565 -0
- package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
- package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
- package/os/flow/tests/flow-integrate.test.ts +698 -17
- package/os/flow/tests/flow-open.pending.test.ts +277 -0
- package/os/flow/tests/flow-open.test.ts +52 -9
- package/os/flow/tests/flow-push-publish.test.ts +124 -0
- package/os/flow/tests/flow-status.test.ts +31 -1
- package/os/flow/tests/locks.test.ts +39 -3
- package/os/flow/tests/ops-registry.test.ts +136 -0
- package/os/flow/tests/scripts.test.ts +5 -2
- package/os/flow/tests/state-roots.test.ts +8 -5
- package/os/flow/worktree-path.ts +9 -3
- package/os/formal/handlers/proof-check.test.ts +6 -3
- package/os/instructions/budget.test.ts +31 -0
- package/os/instructions/handlers/budget-validate.ts +13 -4
- package/os/instructions/instructions.module.ts +4 -1
- package/os/mission/handlers/archive.ts +22 -14
- package/os/mission/importer-block.ts +119 -0
- package/os/mission/lockfile.ts +41 -0
- package/os/mission/open-missions.ts +50 -0
- package/os/queue/decision-ledger.test.ts +18 -0
- package/os/queue/manifest.ts +17 -1
- package/os/rfc/acceptance.ts +30 -10
- package/os/rfc/decision-log.ts +13 -2
- package/os/rfc/frontmatter-io.ts +89 -1
- package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
- package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
- package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
- package/os/rfc/handlers/implement-stamp.ts +16 -3
- package/os/rfc/handlers/index-graph.ts +5 -4
- package/os/rfc/handlers/lifecycle.test.ts +136 -0
- package/os/rfc/handlers/list-create.test.ts +126 -0
- package/os/rfc/handlers/list-create.ts +130 -10
- package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
- package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
- package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
- package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
- package/os/rfc/handlers/validate-rules.ts +103 -7
- package/os/rfc/handlers/validate.ts +68 -4
- package/os/rfc/next-id.ts +232 -0
- package/os/rfc/probe-batch.ts +6 -1
- package/os/rfc/rfc.module.ts +41 -8
- package/os/rfc/types.ts +31 -6
- package/os/rfc/verification-emit-freshness.test.ts +5 -1
- package/os/rfc/verification-emit.test.ts +5 -1
- package/os/rfc/verification-evidence.ts +99 -33
- package/os/rfc/verification-origin.ts +59 -0
- package/os/rfc/verification-refresh.test.ts +5 -1
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
- package/os/session/handlers/save.ts +35 -7
- package/os/session/tests/session-save.test.ts +154 -0
- package/os/spec/spec-schema.ts +3 -0
- package/os/spec/spec-status.ts +22 -6
- package/os/spec/spec-validate.package-source.test.ts +187 -0
- package/os/spec/spec-validate.ts +65 -14
- package/os/spec/spec.module.ts +13 -5
- package/os/system/handlers/system-map-validate.ts +4 -2
- package/os/system/handlers/system-outbox-scan.ts +65 -21
- package/os/system/handlers/system-task-collect.ts +11 -5
- package/os/system/handlers/system-task-create.ts +6 -1
- package/os/system/handlers/system-versionset-record.ts +301 -16
- package/os/system/repo.ts +59 -18
- package/os/system/scenario-schemas.ts +91 -12
- package/os/system/system.module.ts +70 -17
- package/os/system/tests/contract-fixtures.ts +139 -0
- package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
- package/os/system/tests/scenario-validator-check.test.ts +96 -0
- package/os/system/tests/system-task-collect.test.ts +16 -0
- package/os/system/tests/system-task-dispatch.test.ts +4 -1
- package/os/system/tests/system-versionset.test.ts +7 -3
- package/os/system/tests/version-set-v2.test.ts +78 -0
- package/package.json +9 -1
- package/skills/fo/fo-doctor/SKILL.md +151 -0
- package/skills/fo/fo-handoff/SKILL.md +22 -0
- package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
- package/skills/fo/fo-idea-implement/SKILL.md +5 -2
- package/skills/fo/fo-idea-plan/SKILL.md +5 -5
- package/skills/fo/fo-session-retro/SKILL.md +45 -13
- package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
- package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
- package/skills/meta/skill-create/SKILL.md +2 -1
- package/src/bin-entry.test.ts +3 -1
- package/src/config/forge-config.ts +57 -13
- package/src/conformance/index.ts +46 -1
- package/src/formal/proof-runner.ts +10 -2
- package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
- package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
- package/src/onboarding/agents-generate.ts +4 -4
- package/src/onboarding/nested-agents-generate.ts +3 -1
- package/src/onboarding/prettierignore.ts +2 -0
- package/src/onboarding/scaffold-project.ts +2 -2
- package/src/onboarding/upgrade.ts +13 -2
- package/src/onboarding/workspace-discovery.ts +3 -1
- package/src/pipeline-status.test.ts +1 -1
- package/src/skill-schema.ts +9 -2
- package/src/spec/resolve-spec-source.ts +184 -0
- package/src/tests/acceptance-probe-kinds.test.ts +3 -1
- package/src/tests/agents-generate-domain.test.ts +3 -2
- package/src/tests/agents-generate.test.ts +2 -1
- package/src/tests/create-flow.test.ts +3 -1
- package/src/tests/create.test.ts +12 -2
- package/src/tests/editable-generated-region.test.ts +2 -2
- package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
- package/src/tests/implement-stamp.test.ts +5 -2
- package/src/tests/prettierignore-manage.test.ts +11 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
- package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
- package/src/tests/scaffold-project.test.ts +3 -1
- package/src/tests/upgrade.test.ts +79 -3
- package/src/tests/workspace-discovery.test.ts +4 -3
- package/src/utils/command-inventory.ts +105 -0
- package/src/utils/io.ts +6 -1
- package/src/utils/repo-path.ts +49 -0
- package/src/utils/spawn.ts +88 -0
- package/src/tests/rfc-evidence-sync.test.ts +0 -369
- package/src/tests/skill-agents-sync.test.ts +0 -192
|
@@ -11,22 +11,17 @@ and a held integration lock is waited out.</purpose>
|
|
|
11
11
|
</non-goals>
|
|
12
12
|
</MODULE_CONTRACT>
|
|
13
13
|
<CHANGE_SUMMARY>
|
|
14
|
-
<item>RFC-
|
|
15
|
-
<item>RFC-
|
|
16
|
-
<item>RFC-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
the primary-clean gate keeps tracked-only semantics because it predicts
|
|
21
|
-
'merge --ff-only'. Lock release verifies the held payload before
|
|
22
|
-
unlinking. Registry/journal failures map to FLOW-07 in every handler.
|
|
23
|
-
The final branch-name collision reports FLOW-OPEN-04, flow.discard
|
|
24
|
-
propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
|
|
25
|
-
and integrate exposes teardown as its own field.</item>
|
|
14
|
+
<item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
|
|
15
|
+
<item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
|
|
16
|
+
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
17
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
18
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
19
|
+
<history>RFC-1487, RFC-1515, RFC-1528, RFC-1537</history>
|
|
26
20
|
</CHANGE_SUMMARY>
|
|
27
21
|
*/
|
|
28
22
|
|
|
29
23
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
24
|
+
import { hostname } from "node:os";
|
|
30
25
|
import { join } from "node:path";
|
|
31
26
|
|
|
32
27
|
import { afterEach, describe, expect, it } from "vitest";
|
|
@@ -34,7 +29,8 @@ import { afterEach, describe, expect, it } from "vitest";
|
|
|
34
29
|
import { ambientIo } from "../../../src/utils/io.ts";
|
|
35
30
|
import { integrateFlowBranch } from "../handlers/flow-integrate.ts";
|
|
36
31
|
import { openFlowBranch } from "../handlers/flow-open.ts";
|
|
37
|
-
import {
|
|
32
|
+
import { collectFlowStatus } from "../handlers/flow-status.ts";
|
|
33
|
+
import { commonGitDir, INTEGRATE_LOCK_RELATIVE_PATH, readJournal } from "../registry.ts";
|
|
38
34
|
import { gitExec, initRepo } from "./helpers.ts";
|
|
39
35
|
|
|
40
36
|
const NOW = new Date("2026-11-02T12:00:00Z");
|
|
@@ -103,7 +99,9 @@ describe("flow.integrate", () => {
|
|
|
103
99
|
expect(merges.stdout.trim()).toBe("");
|
|
104
100
|
expect((await gitExec(repo, ["cat-file", "-e", "develop:a.txt"])).exitCode).toBe(0);
|
|
105
101
|
expect((await gitExec(repo, ["cat-file", "-e", "develop:c.txt"])).exitCode).toBe(0);
|
|
106
|
-
expect(
|
|
102
|
+
expect(
|
|
103
|
+
(await gitExec(repo, ["rev-parse", "--verify", `refs/heads/${session.branch}`])).exitCode,
|
|
104
|
+
).not.toBe(0);
|
|
107
105
|
}, 20_000);
|
|
108
106
|
|
|
109
107
|
it("refuses FLOW-INT-02 on a rebase conflict and leaves both refs unchanged (AC-4)", async () => {
|
|
@@ -137,7 +135,10 @@ describe("flow.integrate", () => {
|
|
|
137
135
|
await mkdir(join(session.worktree!, "hooks"), { recursive: true });
|
|
138
136
|
await commitIn(session.worktree!, "hooks/integration-gate.sh", "#!/bin/sh\nexit 0\n");
|
|
139
137
|
await mkdir(join(repo, "hooks"), { recursive: true });
|
|
140
|
-
await writeFile(
|
|
138
|
+
await writeFile(
|
|
139
|
+
join(repo, "hooks", "integration-gate.sh"),
|
|
140
|
+
"#!/bin/sh\necho gated >&2\nexit 1\n",
|
|
141
|
+
);
|
|
141
142
|
const developSha = await sha(repo, "develop");
|
|
142
143
|
|
|
143
144
|
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
@@ -151,7 +152,7 @@ describe("flow.integrate", () => {
|
|
|
151
152
|
expect(await sha(repo, "develop")).toBe(developSha);
|
|
152
153
|
}, 20_000);
|
|
153
154
|
|
|
154
|
-
it("refuses FLOW-INT-03
|
|
155
|
+
it("refuses FLOW-INT-03 before the rebase when the primary is dirty", async () => {
|
|
155
156
|
const repo = await governedRepo();
|
|
156
157
|
const session = await openSession(repo, "dirty-primary");
|
|
157
158
|
await commitIn(session.worktree!, "x.txt", "x");
|
|
@@ -165,8 +166,9 @@ describe("flow.integrate", () => {
|
|
|
165
166
|
now: NOW,
|
|
166
167
|
});
|
|
167
168
|
|
|
169
|
+
// RFC-1528: the preflight's early primary check refuses before the rebase.
|
|
168
170
|
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-03");
|
|
169
|
-
expect(data.rebased).toBe(
|
|
171
|
+
expect(data.rebased).toBe(false);
|
|
170
172
|
expect(await sha(repo, "develop")).toBe(developSha);
|
|
171
173
|
await gitExec(repo, ["checkout", "--", "seed.txt"]);
|
|
172
174
|
}, 20_000);
|
|
@@ -227,3 +229,682 @@ describe("flow.integrate", () => {
|
|
|
227
229
|
expect((await gitExec(repo, ["cat-file", "-e", "develop:w.txt"])).exitCode).toBe(0);
|
|
228
230
|
}, 20_000);
|
|
229
231
|
});
|
|
232
|
+
|
|
233
|
+
describe("flow.integrate — RFC-1515 lifecycle hardening", () => {
|
|
234
|
+
it("tolerates FORGE_STATE_FILES-only untracked state — journaled, never FLOW-INT-01 (AC-2)", async () => {
|
|
235
|
+
const repo = await governedRepo();
|
|
236
|
+
const session = await openSession(repo, "tolerated");
|
|
237
|
+
await commitIn(session.worktree!, "t.txt", "t");
|
|
238
|
+
await mkdir(join(session.worktree!, ".forge", "task"), { recursive: true });
|
|
239
|
+
await writeFile(join(session.worktree!, ".forge", "knowledge-conflicts.txt"), "conflict\n");
|
|
240
|
+
await writeFile(join(session.worktree!, ".forge", "task", "notes.md"), "n\n");
|
|
241
|
+
|
|
242
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
243
|
+
branch: session.branch!,
|
|
244
|
+
dryRun: false,
|
|
245
|
+
now: NOW,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(data.diagnostics).toEqual([]);
|
|
249
|
+
expect(data.toleratedState).toEqual(
|
|
250
|
+
expect.arrayContaining([".forge/knowledge-conflicts.txt", ".forge/task/notes.md"]),
|
|
251
|
+
);
|
|
252
|
+
expect(data.integrated).toBe(true);
|
|
253
|
+
// The tolerated paths are declared-disposable: cleanup deleted them so
|
|
254
|
+
// `git worktree remove` could complete — no FLOW-INT-04 wedge.
|
|
255
|
+
expect(data.cleanedUp).toBe(true);
|
|
256
|
+
expect(await ambientIo.exists(session.worktree!)).toBe(false);
|
|
257
|
+
expect((await gitExec(repo, ["rev-parse", "--verify", session.branch!])).exitCode).not.toBe(0);
|
|
258
|
+
}, 20_000);
|
|
259
|
+
|
|
260
|
+
it("still refuses FLOW-INT-01 on non-allowlisted untracked paths — including other .forge entries (AC-7)", async () => {
|
|
261
|
+
const repo = await governedRepo();
|
|
262
|
+
const session = await openSession(repo, "mixed-dirt");
|
|
263
|
+
await commitIn(session.worktree!, "u.txt", "u");
|
|
264
|
+
await mkdir(join(session.worktree!, ".forge"), { recursive: true });
|
|
265
|
+
await writeFile(join(session.worktree!, ".forge", "knowledge-conflicts.txt"), "conflict\n");
|
|
266
|
+
await writeFile(join(session.worktree!, ".forge", "other-state.yaml"), "s\n");
|
|
267
|
+
await writeFile(join(session.worktree!, "scratch.log"), "scratch\n");
|
|
268
|
+
const developSha = await sha(repo, "develop");
|
|
269
|
+
|
|
270
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
271
|
+
branch: session.branch!,
|
|
272
|
+
dryRun: false,
|
|
273
|
+
now: NOW,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const diag = data.diagnostics.find((d) => d.ruleId === "FLOW-INT-01");
|
|
277
|
+
expect(diag).toBeDefined();
|
|
278
|
+
expect(diag?.message).toContain("scratch.log");
|
|
279
|
+
expect(diag?.message).toContain("other-state.yaml");
|
|
280
|
+
// The allowlisted path is journal data on the diagnostic — never a
|
|
281
|
+
// suppressed blocker and never inside entries[].
|
|
282
|
+
expect(diag?.data?.["toleratedState"]).toEqual([".forge/knowledge-conflicts.txt"]);
|
|
283
|
+
expect(diag?.message).toContain("tolerated forge-local state: .forge/knowledge-conflicts.txt");
|
|
284
|
+
expect(data.integrated).toBe(false);
|
|
285
|
+
expect(await sha(repo, "develop")).toBe(developSha);
|
|
286
|
+
}, 20_000);
|
|
287
|
+
|
|
288
|
+
it("journals every refusal as integrate-refusal {branch, rule, summary, at} — flow.status exposes lastRefusal/orphaned (RFC-1537 AC-4)", async () => {
|
|
289
|
+
const repo = await governedRepo();
|
|
290
|
+
const session = await openSession(repo, "refused");
|
|
291
|
+
await commitIn(session.worktree!, "k.txt", "k");
|
|
292
|
+
await writeFile(join(session.worktree!, "scratch.log"), "scratch\n");
|
|
293
|
+
|
|
294
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
295
|
+
branch: session.branch!,
|
|
296
|
+
dryRun: false,
|
|
297
|
+
now: NOW,
|
|
298
|
+
});
|
|
299
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-01");
|
|
300
|
+
|
|
301
|
+
const common = await commonGitDir(ambientIo, repo);
|
|
302
|
+
const journal = await readJournal(ambientIo, common);
|
|
303
|
+
const refusal = [...journal]
|
|
304
|
+
.reverse()
|
|
305
|
+
.find((e) => e.event === "integrate-refusal" && e.branch === session.branch);
|
|
306
|
+
expect(refusal).toBeDefined();
|
|
307
|
+
expect(refusal?.rule).toBe("FLOW-INT-01");
|
|
308
|
+
expect(refusal?.sha).toBe(await sha(repo, session.branch!));
|
|
309
|
+
expect(refusal?.detail).toContain("scratch.log");
|
|
310
|
+
expect(refusal?.at).toBeDefined();
|
|
311
|
+
|
|
312
|
+
const status = await collectFlowStatus(repo, ambientIo);
|
|
313
|
+
const b = status.data.branches.find((x) => x.name === session.branch);
|
|
314
|
+
expect(b?.orphaned).toBe(true);
|
|
315
|
+
expect(b?.lastRefusal?.rule).toBe("FLOW-INT-01");
|
|
316
|
+
expect(b?.lastRefusal?.summary).toContain("scratch.log");
|
|
317
|
+
}, 20_000);
|
|
318
|
+
|
|
319
|
+
it("a later non-refusal event clears orphaned while lastRefusal stays (RFC-1537)", async () => {
|
|
320
|
+
const repo = await governedRepo();
|
|
321
|
+
const session = await openSession(repo, "later");
|
|
322
|
+
await commitIn(session.worktree!, "k.txt", "k");
|
|
323
|
+
await writeFile(join(session.worktree!, "scratch.log"), "scratch\n");
|
|
324
|
+
await integrateFlowBranch(repo, ambientIo, {
|
|
325
|
+
branch: session.branch!,
|
|
326
|
+
dryRun: false,
|
|
327
|
+
now: NOW,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const common = await commonGitDir(ambientIo, repo);
|
|
331
|
+
await (
|
|
332
|
+
await import("../registry.ts")
|
|
333
|
+
).appendJournal(ambientIo, common, {
|
|
334
|
+
event: "hold",
|
|
335
|
+
branch: session.branch!,
|
|
336
|
+
sha: await sha(repo, session.branch!),
|
|
337
|
+
detail: "held",
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const status = await collectFlowStatus(repo, ambientIo);
|
|
341
|
+
const b = status.data.branches.find((x) => x.name === session.branch);
|
|
342
|
+
expect(b?.orphaned).toBe(false);
|
|
343
|
+
expect(b?.lastRefusal?.rule).toBe("FLOW-INT-01");
|
|
344
|
+
}, 20_000);
|
|
345
|
+
|
|
346
|
+
it("a held-lock refusal carries the holder payload — pid, host, at, heldMs, disposition (AC-4)", async () => {
|
|
347
|
+
const repo = await governedRepo();
|
|
348
|
+
const session = await openSession(repo, "locked");
|
|
349
|
+
await commitIn(session.worktree!, "w.txt", "w");
|
|
350
|
+
const common = await commonGitDir(ambientIo, repo);
|
|
351
|
+
const lockPath = join(common, INTEGRATE_LOCK_RELATIVE_PATH);
|
|
352
|
+
await mkdir(join(common, "forge"), { recursive: true });
|
|
353
|
+
const at = new Date().toISOString();
|
|
354
|
+
// A live holder on this host — pid is this process so holderIsDead
|
|
355
|
+
// reports live and the wait budget must elapse to refuse.
|
|
356
|
+
await writeFile(lockPath, JSON.stringify({ pid: process.pid, host: hostname(), at }));
|
|
357
|
+
|
|
358
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
359
|
+
branch: session.branch!,
|
|
360
|
+
dryRun: false,
|
|
361
|
+
now: NOW,
|
|
362
|
+
lockWaitMs: 300,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-08");
|
|
366
|
+
expect(data.lock).toMatchObject({
|
|
367
|
+
pid: process.pid,
|
|
368
|
+
host: hostname(),
|
|
369
|
+
at,
|
|
370
|
+
disposition: "live",
|
|
371
|
+
});
|
|
372
|
+
expect(typeof data.lock?.heldMs).toBe("number");
|
|
373
|
+
expect(data.integrated).toBe(false);
|
|
374
|
+
await rm(lockPath, { force: true });
|
|
375
|
+
}, 20_000);
|
|
376
|
+
|
|
377
|
+
it("a vanished worktree with an unmerged branch still refuses — with the vanished classification and the flow.discard hint (AC-6)", async () => {
|
|
378
|
+
const repo = await governedRepo();
|
|
379
|
+
const session = await openSession(repo, "ghost");
|
|
380
|
+
await commitIn(session.worktree!, "gone.txt", "gone");
|
|
381
|
+
await rm(session.worktree!, { recursive: true, force: true });
|
|
382
|
+
|
|
383
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
384
|
+
branch: session.branch!,
|
|
385
|
+
dryRun: false,
|
|
386
|
+
now: NOW,
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
expect(data.integrated).toBe(false);
|
|
390
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-15");
|
|
391
|
+
expect(data.diagnostics[0]?.message).toContain("vanished");
|
|
392
|
+
expect(data.diagnostics[0]?.data?.["vanished"]).toBe(true);
|
|
393
|
+
expect(data.diagnostics[0]?.fixHint).toContain("flow.discard");
|
|
394
|
+
}, 20_000);
|
|
395
|
+
|
|
396
|
+
it("a dry-run classify a vanished worktree without touching it — same FLOW-07 shape (RFC-1515)", async () => {
|
|
397
|
+
const repo = await governedRepo();
|
|
398
|
+
const session = await openSession(repo, "ghost-dry");
|
|
399
|
+
await commitIn(session.worktree!, "gone.txt", "gone");
|
|
400
|
+
await rm(session.worktree!, { recursive: true, force: true });
|
|
401
|
+
|
|
402
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
403
|
+
branch: session.branch!,
|
|
404
|
+
dryRun: true,
|
|
405
|
+
now: NOW,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-07");
|
|
409
|
+
expect(data.diagnostics[0]?.data?.["vanished"]).toBe(true);
|
|
410
|
+
expect(data.diagnostics[0]?.fixHint).toContain("flow.discard");
|
|
411
|
+
}, 20_000);
|
|
412
|
+
|
|
413
|
+
it("a held-lock refusal with an unreadable holder file reports holder unknown (RFC-1515 AC-4)", async () => {
|
|
414
|
+
const repo = await governedRepo();
|
|
415
|
+
const session = await openSession(repo, "unknown-holder");
|
|
416
|
+
await commitIn(session.worktree!, "w.txt", "w");
|
|
417
|
+
const common = await commonGitDir(ambientIo, repo);
|
|
418
|
+
const lockPath = join(common, INTEGRATE_LOCK_RELATIVE_PATH);
|
|
419
|
+
await mkdir(join(common, "forge"), { recursive: true });
|
|
420
|
+
await writeFile(lockPath, "not-json{{");
|
|
421
|
+
|
|
422
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
423
|
+
branch: session.branch!,
|
|
424
|
+
dryRun: false,
|
|
425
|
+
now: NOW,
|
|
426
|
+
lockWaitMs: 300,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-08");
|
|
430
|
+
expect(data.diagnostics[0]?.message).toContain("holder unknown");
|
|
431
|
+
expect(data.lock).toBeUndefined();
|
|
432
|
+
expect(data.integrated).toBe(false);
|
|
433
|
+
await rm(lockPath, { force: true });
|
|
434
|
+
}, 20_000);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
describe("flow.integrate — RFC-1538 post-lock revalidation, session engine, auto-resolve", () => {
|
|
438
|
+
it("a second integrate on an already-integrated branch exits idempotently (AC-1/AC-5)", async () => {
|
|
439
|
+
const repo = await governedRepo();
|
|
440
|
+
const session = await openSession(repo, "again");
|
|
441
|
+
await commitIn(session.worktree!, "a.txt", "a");
|
|
442
|
+
|
|
443
|
+
const first = await integrateFlowBranch(repo, ambientIo, {
|
|
444
|
+
branch: session.branch!,
|
|
445
|
+
dryRun: false,
|
|
446
|
+
now: NOW,
|
|
447
|
+
});
|
|
448
|
+
expect(first.integrated).toBe(true);
|
|
449
|
+
|
|
450
|
+
const second = await integrateFlowBranch(repo, ambientIo, {
|
|
451
|
+
branch: session.branch!,
|
|
452
|
+
dryRun: false,
|
|
453
|
+
now: NOW,
|
|
454
|
+
});
|
|
455
|
+
expect(second.disposition).toBe("already-integrated");
|
|
456
|
+
expect(second.integrated).toBe(true);
|
|
457
|
+
expect(second.diagnostics).toEqual([]);
|
|
458
|
+
expect(second.cleanedUp).toBe(true);
|
|
459
|
+
expect(await ambientIo.exists(session.worktree!)).toBe(false);
|
|
460
|
+
}, 20_000);
|
|
461
|
+
|
|
462
|
+
it("an unregistered branch never contained still refuses FLOW-INT-06", async () => {
|
|
463
|
+
const repo = await governedRepo();
|
|
464
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
465
|
+
branch: "auto/session-261108-99-never",
|
|
466
|
+
dryRun: false,
|
|
467
|
+
now: NOW,
|
|
468
|
+
});
|
|
469
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-06");
|
|
470
|
+
expect(data.disposition).toBeUndefined();
|
|
471
|
+
}, 20_000);
|
|
472
|
+
|
|
473
|
+
it("an unregistered branch fully contained in develop reports already-integrated — nothing to do", async () => {
|
|
474
|
+
const repo = await governedRepo();
|
|
475
|
+
await gitExec(repo, ["branch", "auto/session-261108-99-merged"]);
|
|
476
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
477
|
+
branch: "auto/session-261108-99-merged",
|
|
478
|
+
dryRun: false,
|
|
479
|
+
now: NOW,
|
|
480
|
+
});
|
|
481
|
+
expect(data.disposition).toBe("already-integrated");
|
|
482
|
+
expect(data.integrated).toBe(true);
|
|
483
|
+
expect(data.diagnostics).toEqual([]);
|
|
484
|
+
}, 20_000);
|
|
485
|
+
|
|
486
|
+
it("the gate binds the session engine build when the worktree has node_modules (AC-2)", async () => {
|
|
487
|
+
const repo = await governedRepo();
|
|
488
|
+
const session = await openSession(repo, "engine");
|
|
489
|
+
await commitIn(session.worktree!, "e.txt", "e");
|
|
490
|
+
await mkdir(join(session.worktree!, "node_modules"), { recursive: true });
|
|
491
|
+
|
|
492
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
493
|
+
branch: session.branch!,
|
|
494
|
+
dryRun: false,
|
|
495
|
+
now: NOW,
|
|
496
|
+
});
|
|
497
|
+
expect(data.integrated).toBe(true);
|
|
498
|
+
expect(data.gateEngine).toBe("session");
|
|
499
|
+
}, 20_000);
|
|
500
|
+
|
|
501
|
+
it("a generated-only conflict auto-resolves via the owner command and lands (AC-3)", async () => {
|
|
502
|
+
const repo = await governedRepo();
|
|
503
|
+
const session = await openSession(repo, "genconf");
|
|
504
|
+
await mkdir(join(session.worktree!, "docs", "rfcs"), { recursive: true });
|
|
505
|
+
await mkdir(join(repo, "docs", "rfcs"), { recursive: true });
|
|
506
|
+
const sessionIndex = "command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 2\n";
|
|
507
|
+
const developIndex = "command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 9\n";
|
|
508
|
+
await commitIn(session.worktree!, "docs/rfcs/index.yaml", sessionIndex);
|
|
509
|
+
await commitIn(repo, "docs/rfcs/index.yaml", developIndex);
|
|
510
|
+
|
|
511
|
+
const resolved = "command: rfc.index.generate\ngeneratedAt: 2026-11-09\ncount: 10\n";
|
|
512
|
+
const invoked: string[] = [];
|
|
513
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
514
|
+
branch: session.branch!,
|
|
515
|
+
dryRun: false,
|
|
516
|
+
now: NOW,
|
|
517
|
+
invoke: async (name, flags) => {
|
|
518
|
+
invoked.push(`${name} ${JSON.stringify(flags ?? {})}`);
|
|
519
|
+
await writeFile(join(session.worktree!, "docs/rfcs/index.yaml"), resolved);
|
|
520
|
+
return { ok: true, exitCode: 0 };
|
|
521
|
+
},
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
expect(data.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
525
|
+
expect(data.integrated).toBe(true);
|
|
526
|
+
expect(data.autoResolved).toEqual(["docs/rfcs/index.yaml"]);
|
|
527
|
+
expect(invoked).toEqual(['rfc.index.generate {"write":true}']);
|
|
528
|
+
expect((await gitExec(repo, ["cat-file", "-e", "develop:docs/rfcs/index.yaml"])).exitCode).toBe(
|
|
529
|
+
0,
|
|
530
|
+
);
|
|
531
|
+
}, 20_000);
|
|
532
|
+
|
|
533
|
+
it("a generated-only conflict without an invoke port engages the standalone adapter — spawn failure escalates FLOW-INT-02 (RFC-1545 AC-2/AC-4)", async () => {
|
|
534
|
+
const repo = await governedRepo();
|
|
535
|
+
const session = await openSession(repo, "standalone");
|
|
536
|
+
await mkdir(join(session.worktree!, "docs", "rfcs"), { recursive: true });
|
|
537
|
+
await mkdir(join(repo, "docs", "rfcs"), { recursive: true });
|
|
538
|
+
await commitIn(
|
|
539
|
+
session.worktree!,
|
|
540
|
+
"docs/rfcs/index.yaml",
|
|
541
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 2\n",
|
|
542
|
+
);
|
|
543
|
+
await commitIn(
|
|
544
|
+
repo,
|
|
545
|
+
"docs/rfcs/index.yaml",
|
|
546
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 9\n",
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
// No invoke port — the adapter spawns `pnpm exec werkstatt run …` in the
|
|
550
|
+
// bare fixture worktree where no werkstatt binary resolves; the failure
|
|
551
|
+
// escalates as FLOW-INT-02, proving the standalone path engaged.
|
|
552
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
553
|
+
branch: session.branch!,
|
|
554
|
+
dryRun: false,
|
|
555
|
+
now: NOW,
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
expect(data.integrated).toBe(false);
|
|
559
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-02");
|
|
560
|
+
expect(data.diagnostics[0]?.message).toContain("auto-resolve of generated conflict");
|
|
561
|
+
}, 20_000);
|
|
562
|
+
|
|
563
|
+
it("a failing generator escalates to FLOW-INT-02 with its stderr in diagnostics (RFC-1545 AC-4)", async () => {
|
|
564
|
+
const repo = await governedRepo();
|
|
565
|
+
const session = await openSession(repo, "genfail");
|
|
566
|
+
await mkdir(join(session.worktree!, "docs", "rfcs"), { recursive: true });
|
|
567
|
+
await mkdir(join(repo, "docs", "rfcs"), { recursive: true });
|
|
568
|
+
await commitIn(
|
|
569
|
+
session.worktree!,
|
|
570
|
+
"docs/rfcs/index.yaml",
|
|
571
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 2\n",
|
|
572
|
+
);
|
|
573
|
+
await commitIn(
|
|
574
|
+
repo,
|
|
575
|
+
"docs/rfcs/index.yaml",
|
|
576
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 9\n",
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
580
|
+
branch: session.branch!,
|
|
581
|
+
dryRun: false,
|
|
582
|
+
now: NOW,
|
|
583
|
+
invoke: async () => ({
|
|
584
|
+
ok: false,
|
|
585
|
+
exitCode: 1,
|
|
586
|
+
summary: "rfc.index.generate crashed: schema error at docs/rfcs/rfc-0001.md",
|
|
587
|
+
}),
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
expect(data.integrated).toBe(false);
|
|
591
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-02");
|
|
592
|
+
expect(data.diagnostics[0]?.message).toContain("auto-resolve of generated conflict");
|
|
593
|
+
expect(data.diagnostics[0]?.message).toContain("schema error");
|
|
594
|
+
}, 20_000);
|
|
595
|
+
|
|
596
|
+
it("a generator that leaves residual conflict markers escalates to FLOW-INT-02 (RFC-1545 AC-4)", async () => {
|
|
597
|
+
const repo = await governedRepo();
|
|
598
|
+
const session = await openSession(repo, "genmarkers");
|
|
599
|
+
await mkdir(join(session.worktree!, "docs", "rfcs"), { recursive: true });
|
|
600
|
+
await mkdir(join(repo, "docs", "rfcs"), { recursive: true });
|
|
601
|
+
await commitIn(
|
|
602
|
+
session.worktree!,
|
|
603
|
+
"docs/rfcs/index.yaml",
|
|
604
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 2\n",
|
|
605
|
+
);
|
|
606
|
+
await commitIn(
|
|
607
|
+
repo,
|
|
608
|
+
"docs/rfcs/index.yaml",
|
|
609
|
+
"command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 9\n",
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
613
|
+
branch: session.branch!,
|
|
614
|
+
dryRun: false,
|
|
615
|
+
now: NOW,
|
|
616
|
+
invoke: async () => {
|
|
617
|
+
// A "successful" regen that writes marker-laden output must not land.
|
|
618
|
+
await writeFile(
|
|
619
|
+
join(session.worktree!, "docs/rfcs/index.yaml"),
|
|
620
|
+
"command: rfc.index.generate\n<<<<<<< HEAD\ncount: 9\n=======\ncount: 2\n>>>>>>> branch\n",
|
|
621
|
+
);
|
|
622
|
+
return { ok: true, exitCode: 0 };
|
|
623
|
+
},
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
expect(data.integrated).toBe(false);
|
|
627
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-02");
|
|
628
|
+
expect(data.diagnostics[0]?.message).toContain("conflict markers");
|
|
629
|
+
}, 20_000);
|
|
630
|
+
|
|
631
|
+
it("primary dirt held only by a live foreign claim waits, then refuses FLOW-INT-03 naming the holder (RFC-1543 AC-4)", async () => {
|
|
632
|
+
const repo = await governedRepo();
|
|
633
|
+
const session = await openSession(repo, "foreign");
|
|
634
|
+
await commitIn(session.worktree!, "f.txt", "f");
|
|
635
|
+
await commitIn(repo, "claimed.txt", "base");
|
|
636
|
+
// A live foreign op claims the file it is about to dirty on primary.
|
|
637
|
+
const { claimOp } = await import("../ops-registry.ts");
|
|
638
|
+
const { writeFile: wf } = await import("node:fs/promises");
|
|
639
|
+
await claimOp(repo, ambientIo, {
|
|
640
|
+
opId: "ship-001",
|
|
641
|
+
command: "leitstand.ship",
|
|
642
|
+
workspaceRoot: repo,
|
|
643
|
+
paths: ["claimed.txt"],
|
|
644
|
+
});
|
|
645
|
+
await wf(join(repo, "claimed.txt"), "dirty-in-flight");
|
|
646
|
+
|
|
647
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
648
|
+
branch: session.branch!,
|
|
649
|
+
dryRun: false,
|
|
650
|
+
now: NOW,
|
|
651
|
+
waitForeignSeconds: 1,
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
expect(data.integrated).toBe(false);
|
|
655
|
+
const diag = data.diagnostics.find((d) => d.ruleId === "FLOW-INT-03");
|
|
656
|
+
expect(diag).toBeDefined();
|
|
657
|
+
expect(diag?.message).toContain("leitstand.ship ship-001");
|
|
658
|
+
expect((diag?.data?.["foreignHolders"] as { opId: string }[] | undefined)?.[0]?.opId).toBe(
|
|
659
|
+
"ship-001",
|
|
660
|
+
);
|
|
661
|
+
}, 30_000);
|
|
662
|
+
|
|
663
|
+
it("foreign-held primary dirt clears mid-wait and the integration proceeds (RFC-1543 AC-4)", async () => {
|
|
664
|
+
const repo = await governedRepo();
|
|
665
|
+
const session = await openSession(repo, "foreign2");
|
|
666
|
+
await commitIn(session.worktree!, "f2.txt", "f2");
|
|
667
|
+
await commitIn(repo, "claimed.txt", "base");
|
|
668
|
+
const { claimOp, releaseOp } = await import("../ops-registry.ts");
|
|
669
|
+
const { writeFile: wf } = await import("node:fs/promises");
|
|
670
|
+
await claimOp(repo, ambientIo, {
|
|
671
|
+
opId: "ship-002",
|
|
672
|
+
command: "leitstand.ship",
|
|
673
|
+
workspaceRoot: repo,
|
|
674
|
+
paths: ["claimed.txt"],
|
|
675
|
+
});
|
|
676
|
+
await wf(join(repo, "claimed.txt"), "dirty-in-flight");
|
|
677
|
+
|
|
678
|
+
// The foreign op finishes mid-wait: claim released, dirt committed away.
|
|
679
|
+
const clearer = setTimeout(() => {
|
|
680
|
+
void (async () => {
|
|
681
|
+
await releaseOp(repo, ambientIo, "ship-002");
|
|
682
|
+
await wf(join(repo, "claimed.txt"), "committed-away");
|
|
683
|
+
await gitExec(repo, ["add", "claimed.txt"]);
|
|
684
|
+
await gitExec(repo, ["commit", "-m", "foreign op lands its write"]);
|
|
685
|
+
})();
|
|
686
|
+
}, 1200);
|
|
687
|
+
|
|
688
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
689
|
+
branch: session.branch!,
|
|
690
|
+
dryRun: false,
|
|
691
|
+
now: NOW,
|
|
692
|
+
waitForeignSeconds: 8,
|
|
693
|
+
});
|
|
694
|
+
clearTimeout(clearer);
|
|
695
|
+
|
|
696
|
+
expect(data.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
697
|
+
expect(data.integrated).toBe(true);
|
|
698
|
+
}, 30_000);
|
|
699
|
+
|
|
700
|
+
it("a mixed generated/non-generated conflict set still refuses FLOW-INT-02 (AC-3 boundary)", async () => {
|
|
701
|
+
const repo = await governedRepo();
|
|
702
|
+
const session = await openSession(repo, "mixed");
|
|
703
|
+
await mkdir(join(session.worktree!, "docs", "rfcs"), { recursive: true });
|
|
704
|
+
await mkdir(join(repo, "docs", "rfcs"), { recursive: true });
|
|
705
|
+
const sessionIndex = "command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 2\n";
|
|
706
|
+
const developIndex = "command: rfc.index.generate\ngeneratedAt: 2026-11-08\ncount: 9\n";
|
|
707
|
+
await commitIn(session.worktree!, "docs/rfcs/index.yaml", sessionIndex);
|
|
708
|
+
await commitIn(session.worktree!, "real.txt", "session-side");
|
|
709
|
+
await commitIn(repo, "docs/rfcs/index.yaml", developIndex);
|
|
710
|
+
await commitIn(repo, "real.txt", "develop-side");
|
|
711
|
+
|
|
712
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
713
|
+
branch: session.branch!,
|
|
714
|
+
dryRun: false,
|
|
715
|
+
now: NOW,
|
|
716
|
+
invoke: async () => ({ ok: true, exitCode: 0 }),
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
expect(data.integrated).toBe(false);
|
|
720
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-02");
|
|
721
|
+
expect(data.diagnostics[0]?.message).toContain("real.txt");
|
|
722
|
+
}, 20_000);
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
describe("flow.integrate — recoverable manifest drift (RFC-1546 AC-1)", () => {
|
|
726
|
+
it("sole FLOW-INT-12 drift regenerates the manifest and continues", async () => {
|
|
727
|
+
const repo = await governedRepo();
|
|
728
|
+
const session = await openSession(repo, "regen");
|
|
729
|
+
const { runIntegratePreflight } = await import("../preflight.ts");
|
|
730
|
+
const invoked: string[] = [];
|
|
731
|
+
let validateCalls = 0;
|
|
732
|
+
const cmd = (name: string) => ({
|
|
733
|
+
name,
|
|
734
|
+
provider: "workspace" as const,
|
|
735
|
+
description: name,
|
|
736
|
+
scope: "workspace" as const,
|
|
737
|
+
});
|
|
738
|
+
const preflight = await runIntegratePreflight({
|
|
739
|
+
primary: repo,
|
|
740
|
+
branchWorktree: session.worktree!,
|
|
741
|
+
branch: session.branch!,
|
|
742
|
+
io: ambientIo,
|
|
743
|
+
worktreeDirty: { entries: [], toleratedState: [] },
|
|
744
|
+
commands: [
|
|
745
|
+
"ecosystem.manifest.validate",
|
|
746
|
+
"ecosystem.manifest.generate",
|
|
747
|
+
"rfc.validate",
|
|
748
|
+
"friction.validate",
|
|
749
|
+
].map(cmd),
|
|
750
|
+
invoke: async (name) => {
|
|
751
|
+
invoked.push(name);
|
|
752
|
+
if (name === "ecosystem.manifest.validate") {
|
|
753
|
+
validateCalls++;
|
|
754
|
+
return validateCalls === 1
|
|
755
|
+
? { ok: false, exitCode: 1, summary: "stale: docs/ecosystem.generated.yaml" }
|
|
756
|
+
: { ok: true, exitCode: 0 };
|
|
757
|
+
}
|
|
758
|
+
return { ok: true, exitCode: 0 };
|
|
759
|
+
},
|
|
760
|
+
});
|
|
761
|
+
expect(preflight.ok).toBe(true);
|
|
762
|
+
expect(invoked).toEqual([
|
|
763
|
+
"ecosystem.manifest.validate",
|
|
764
|
+
"friction.validate",
|
|
765
|
+
"ecosystem.manifest.generate",
|
|
766
|
+
"ecosystem.manifest.validate",
|
|
767
|
+
]);
|
|
768
|
+
}, 20_000);
|
|
769
|
+
|
|
770
|
+
it("a second violation alongside drift refuses without regenerating", async () => {
|
|
771
|
+
const repo = await governedRepo();
|
|
772
|
+
const session = await openSession(repo, "regen");
|
|
773
|
+
const { runIntegratePreflight } = await import("../preflight.ts");
|
|
774
|
+
const invoked: string[] = [];
|
|
775
|
+
const cmd = (name: string) => ({
|
|
776
|
+
name,
|
|
777
|
+
provider: "workspace" as const,
|
|
778
|
+
description: name,
|
|
779
|
+
scope: "workspace" as const,
|
|
780
|
+
});
|
|
781
|
+
const preflight = await runIntegratePreflight({
|
|
782
|
+
primary: repo,
|
|
783
|
+
branchWorktree: session.worktree!,
|
|
784
|
+
branch: session.branch!,
|
|
785
|
+
io: ambientIo,
|
|
786
|
+
worktreeDirty: { entries: [], toleratedState: [] },
|
|
787
|
+
commands: [
|
|
788
|
+
"ecosystem.manifest.validate",
|
|
789
|
+
"ecosystem.manifest.generate",
|
|
790
|
+
"friction.validate",
|
|
791
|
+
].map(cmd),
|
|
792
|
+
invoke: async (name) => {
|
|
793
|
+
invoked.push(name);
|
|
794
|
+
if (name === "ecosystem.manifest.validate") {
|
|
795
|
+
return { ok: false, exitCode: 1, summary: "stale: docs/ecosystem.generated.yaml" };
|
|
796
|
+
}
|
|
797
|
+
// friction.validate is also red — drift is not the sole violation.
|
|
798
|
+
return { ok: false, exitCode: 1, summary: `${name} failed` };
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
expect(preflight.ok).toBe(false);
|
|
802
|
+
// The coexisting refusal fires; the regeneration never ran.
|
|
803
|
+
expect(preflight.refuse?.ruleId).toBe("FLOW-INT-14");
|
|
804
|
+
expect(invoked).toEqual(["ecosystem.manifest.validate", "friction.validate"]);
|
|
805
|
+
}, 20_000);
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
// RFC-1544 AC-2/AC-4: referent-aware importer-prune resolution inside
|
|
809
|
+
// flow.integrate — a foreign checkout's open mission restores its importer
|
|
810
|
+
// subtree (journaled), a stale prune commits as cleanup, and any prune diff
|
|
811
|
+
// that is not importer-only still refuses FLOW-INT-01.
|
|
812
|
+
const LOCK_WITH_IMPORTER = [
|
|
813
|
+
"importers:",
|
|
814
|
+
"",
|
|
815
|
+
" .:",
|
|
816
|
+
" dependencies: {}",
|
|
817
|
+
"",
|
|
818
|
+
" missions/m-foreign/workpiece:",
|
|
819
|
+
" dependencies:",
|
|
820
|
+
" vite: 5.0.0",
|
|
821
|
+
"",
|
|
822
|
+
"packages:",
|
|
823
|
+
" vite: 5.0.0",
|
|
824
|
+
"",
|
|
825
|
+
].join("\n");
|
|
826
|
+
const LOCK_PRUNED = [
|
|
827
|
+
"importers:",
|
|
828
|
+
"",
|
|
829
|
+
" .:",
|
|
830
|
+
" dependencies: {}",
|
|
831
|
+
"",
|
|
832
|
+
"packages:",
|
|
833
|
+
" vite: 5.0.0",
|
|
834
|
+
"",
|
|
835
|
+
].join("\n");
|
|
836
|
+
|
|
837
|
+
describe("flow.integrate — mission importer referents (RFC-1544)", () => {
|
|
838
|
+
it("AC-2: a foreign-open-mission prune is auto-restored and journaled", async () => {
|
|
839
|
+
const repo = await governedRepo();
|
|
840
|
+
await commitIn(repo, "pnpm-lock.yaml", LOCK_WITH_IMPORTER);
|
|
841
|
+
const session = await openSession(repo, "importer-foreign");
|
|
842
|
+
await commitIn(session.worktree!, "session.txt", "work");
|
|
843
|
+
// The foreign checkout: a detached worktree holding the open mission.
|
|
844
|
+
const foreign = join(repo, "..", `foreign-holder-${Date.now()}`);
|
|
845
|
+
dirs.push(foreign);
|
|
846
|
+
const add = await gitExec(repo, ["worktree", "add", "--detach", foreign, "develop"]);
|
|
847
|
+
expect(add.exitCode).toBe(0);
|
|
848
|
+
await mkdir(join(foreign, "missions", "m-foreign", "workpiece"), { recursive: true });
|
|
849
|
+
await writeFile(join(foreign, "missions", "m-foreign", "mission.yaml"), 'state: "open"\n');
|
|
850
|
+
// The session worktree's install pruned the importer it cannot see.
|
|
851
|
+
await writeFile(join(session.worktree!, "pnpm-lock.yaml"), LOCK_PRUNED);
|
|
852
|
+
|
|
853
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
854
|
+
branch: session.branch!,
|
|
855
|
+
dryRun: false,
|
|
856
|
+
now: NOW,
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
expect(data.diagnostics).toEqual([]);
|
|
860
|
+
expect(data.integrated).toBe(true);
|
|
861
|
+
expect(data.restoredImporters).toEqual(["m-foreign"]);
|
|
862
|
+
// The restored lockfile matched HEAD — no prune commit reached develop.
|
|
863
|
+
const headLock = await gitExec(repo, ["show", "develop:pnpm-lock.yaml"]);
|
|
864
|
+
expect(headLock.stdout).toContain("missions/m-foreign/workpiece:");
|
|
865
|
+
}, 30_000);
|
|
866
|
+
|
|
867
|
+
it("AC-4: a prune diff that is not importer-only still refuses FLOW-INT-01", async () => {
|
|
868
|
+
const repo = await governedRepo();
|
|
869
|
+
await commitIn(repo, "pnpm-lock.yaml", LOCK_WITH_IMPORTER);
|
|
870
|
+
const session = await openSession(repo, "importer-mixed");
|
|
871
|
+
await commitIn(session.worktree!, "session.txt", "work");
|
|
872
|
+
// Importer prune + an unrelated removal — ambiguous, never computed.
|
|
873
|
+
await writeFile(
|
|
874
|
+
join(session.worktree!, "pnpm-lock.yaml"),
|
|
875
|
+
LOCK_PRUNED.replace(" vite: 5.0.0\n", ""),
|
|
876
|
+
);
|
|
877
|
+
|
|
878
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
879
|
+
branch: session.branch!,
|
|
880
|
+
dryRun: false,
|
|
881
|
+
now: NOW,
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
expect(data.integrated).toBe(false);
|
|
885
|
+
expect(data.diagnostics[0]?.ruleId).toBe("FLOW-INT-01");
|
|
886
|
+
expect(data.restoredImporters).toBeUndefined();
|
|
887
|
+
expect(data.staleImporterCommitSha).toBeUndefined();
|
|
888
|
+
}, 30_000);
|
|
889
|
+
|
|
890
|
+
it("a prune whose referent exists nowhere commits as stale cleanup", async () => {
|
|
891
|
+
const repo = await governedRepo();
|
|
892
|
+
await commitIn(repo, "pnpm-lock.yaml", LOCK_WITH_IMPORTER);
|
|
893
|
+
const session = await openSession(repo, "importer-stale");
|
|
894
|
+
await commitIn(session.worktree!, "session.txt", "work");
|
|
895
|
+
await writeFile(join(session.worktree!, "pnpm-lock.yaml"), LOCK_PRUNED);
|
|
896
|
+
|
|
897
|
+
const data = await integrateFlowBranch(repo, ambientIo, {
|
|
898
|
+
branch: session.branch!,
|
|
899
|
+
dryRun: false,
|
|
900
|
+
now: NOW,
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
expect(data.diagnostics).toEqual([]);
|
|
904
|
+
expect(data.integrated).toBe(true);
|
|
905
|
+
expect(data.staleImporterCommitSha).toBeDefined();
|
|
906
|
+
// The prune commit rode the branch into develop — residue is gone.
|
|
907
|
+
const headLock = await gitExec(repo, ["show", "develop:pnpm-lock.yaml"]);
|
|
908
|
+
expect(headLock.stdout).not.toContain("missions/m-foreign/workpiece:");
|
|
909
|
+
}, 30_000);
|
|
910
|
+
});
|