@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
|
@@ -20,25 +20,29 @@ at cleanup without moving develop again.</purpose>
|
|
|
20
20
|
<item>Task-file preservation runs inside the cleanup branch BEFORE the worktree-teardown hook and only for owner.kind task — a `git clean -fdx` teardown would destroy `.forge/task/` first, and a copy failure refuses cleanup (FLOW-INT-04) so the report is never lost with the worktree (RFC-1509 Q-16).</item>
|
|
21
21
|
</KEY_DECISIONS>
|
|
22
22
|
<CHANGE_SUMMARY>
|
|
23
|
-
<item>RFC-
|
|
24
|
-
<item>RFC-
|
|
25
|
-
<item>RFC-
|
|
26
|
-
<item>RFC-
|
|
27
|
-
<item>RFC-
|
|
28
|
-
<history>RFC-1487, RFC-1490, RFC-1491</history>
|
|
23
|
+
<item>RFC-1531: remediation flags --reattach/--auto-clean/--autocommit on the classified dirty set, FLOW-INT-17 remediation-failure refusals, classified FLOW-INT-01 data</item>
|
|
24
|
+
<item>RFC-1532: persist integration-gate reports per attempt and link them from the flow journal</item>
|
|
25
|
+
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
26
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
27
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
28
|
+
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1536, RFC-1537, RFC-1538</history>
|
|
29
29
|
</CHANGE_SUMMARY>
|
|
30
30
|
*/
|
|
31
31
|
import { resolveIo } from "../../../src/utils/io.js";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
32
|
+
import { AUTO_CLEAN_PASS_CLASSES, SWEEP_COMMIT_SUBJECT, classifyDirtyPath, classifyDirtyTree, summarizeClasses, } from "../dirty-classify.js";
|
|
33
|
+
import { branchExists, currentBranch, git, gitCommit, isAncestor, requireGit, statusDirty, statusTracked, topLevel, worktreeAdd, worktreeList, } from "../git.js";
|
|
34
|
+
import { describeHeldLock, LockTimeoutError, withFlowLock, } from "../locks.js";
|
|
35
|
+
import { appendJournal, readJournal, commonGitDir, FlowRegistrySchemaError, INTEGRATE_LOCK_RELATIVE_PATH, readRegistry, registryPath, updateRegistry, } from "../registry.js";
|
|
35
36
|
import { runFlowScript } from "../scripts.js";
|
|
37
|
+
import { standaloneInvoke } from "../standalone-invoke.js";
|
|
36
38
|
import { preserveTaskFiles } from "../task-files.js";
|
|
37
|
-
import { primaryWorktree } from "../worktree-path.js";
|
|
38
|
-
import {
|
|
39
|
+
import { flowWorktreePath, primaryWorktree } from "../worktree-path.js";
|
|
40
|
+
import { pruneReservationsForSession } from "../../rfc/next-id.js";
|
|
41
|
+
import { rm } from "node:fs/promises";
|
|
42
|
+
import { dirname, join } from "node:path";
|
|
39
43
|
export const INTEGRATE_LOCK_WAIT_MS = 30 * 60_000;
|
|
40
44
|
export const INTEGRATE_LOCK_STALE_MS = 2 * 3_600_000;
|
|
41
|
-
function refuse(ruleId, message, fixHint, partial) {
|
|
45
|
+
function refuse(ruleId, message, fixHint, partial, diagData) {
|
|
42
46
|
return {
|
|
43
47
|
branch: partial?.branch ?? null,
|
|
44
48
|
integrated: partial?.integrated ?? false,
|
|
@@ -47,7 +51,21 @@ function refuse(ruleId, message, fixHint, partial) {
|
|
|
47
51
|
rebased: partial?.rebased ?? false,
|
|
48
52
|
gate: partial?.gate ?? null,
|
|
49
53
|
cleanedUp: partial?.cleanedUp ?? false,
|
|
50
|
-
|
|
54
|
+
...(partial?.toleratedState !== undefined ? { toleratedState: partial.toleratedState } : {}),
|
|
55
|
+
...(partial?.toleratedDirt !== undefined ? { toleratedDirt: partial.toleratedDirt } : {}),
|
|
56
|
+
...(partial?.reattachedTo !== undefined ? { reattachedTo: partial.reattachedTo } : {}),
|
|
57
|
+
...(partial?.autoCleaned !== undefined ? { autoCleaned: partial.autoCleaned } : {}),
|
|
58
|
+
...(partial?.autocommitSha !== undefined ? { autocommitSha: partial.autocommitSha } : {}),
|
|
59
|
+
...(partial?.restoredImporters !== undefined
|
|
60
|
+
? { restoredImporters: partial.restoredImporters }
|
|
61
|
+
: {}),
|
|
62
|
+
...(partial?.staleImporterCommitSha !== undefined
|
|
63
|
+
? { staleImporterCommitSha: partial.staleImporterCommitSha }
|
|
64
|
+
: {}),
|
|
65
|
+
...(partial?.lock !== undefined ? { lock: partial.lock } : {}),
|
|
66
|
+
diagnostics: [
|
|
67
|
+
{ ruleId, severity: "error", message, fixHint, ...(diagData ? { data: diagData } : {}) },
|
|
68
|
+
],
|
|
51
69
|
};
|
|
52
70
|
}
|
|
53
71
|
async function resolveEntry(repoRoot, io, branch) {
|
|
@@ -56,9 +74,10 @@ async function resolveEntry(repoRoot, io, branch) {
|
|
|
56
74
|
return { common, entry: registry.branches.find((b) => b.name === branch) ?? null };
|
|
57
75
|
}
|
|
58
76
|
/** Step 6 — teardown, worktree removal, branch delete, registry, journal. */
|
|
59
|
-
async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowIso, journalEvent = "integrate", journalBase) {
|
|
77
|
+
async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowIso, journalEvent = "integrate", journalBase, journalToleratedDirt, journalAutoResolved, journalRemediation, journalGateReport) {
|
|
60
78
|
const branchExistsNow = await branchExists(primary, io, entry.name);
|
|
61
79
|
let teardownRan = null;
|
|
80
|
+
let toleratedPaths = [];
|
|
62
81
|
if (worktree !== null && (await io.exists(worktree))) {
|
|
63
82
|
// RFC-1509 Q-16: preserve BEFORE the teardown hook — a `git clean -fdx`
|
|
64
83
|
// teardown would destroy .forge/task/ with the rest of the worktree.
|
|
@@ -101,6 +120,18 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
101
120
|
],
|
|
102
121
|
};
|
|
103
122
|
}
|
|
123
|
+
// RFC-1515: `statusDirty` predicts `git worktree remove` — allowlisted
|
|
124
|
+
// forge-local state is untracked-not-ignored, so a tolerated-only tree
|
|
125
|
+
// still refuses removal. Delete the tolerated paths first (declared-
|
|
126
|
+
// disposable state; task payloads are already preserved above); a
|
|
127
|
+
// fresh check showing real entries leaves remove to report them.
|
|
128
|
+
const residual = await statusDirty(worktree, io);
|
|
129
|
+
if (residual.entries.length === 0 && residual.toleratedState.length > 0) {
|
|
130
|
+
toleratedPaths = residual.toleratedState;
|
|
131
|
+
for (const rel of residual.toleratedState) {
|
|
132
|
+
await rm(join(worktree, rel), { force: true, recursive: true });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
104
135
|
const remove = await git(primary, io, ["worktree", "remove", worktree]);
|
|
105
136
|
if (remove.exitCode !== 0) {
|
|
106
137
|
return {
|
|
@@ -118,7 +149,15 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
118
149
|
}
|
|
119
150
|
}
|
|
120
151
|
if (branchExistsNow) {
|
|
121
|
-
|
|
152
|
+
// RFC-1515: a vanished worktree leaves a stale `git worktree`
|
|
153
|
+
// registration that pins the branch — prune it before deletion. Merged
|
|
154
|
+
// state is already proven by isAncestor, so `-D` is the verified delete
|
|
155
|
+
// (`-d` re-derives containment in the current worktree context, which
|
|
156
|
+
// the F-0093 *.stale race corrupted).
|
|
157
|
+
if (worktree !== null && !(await io.exists(worktree))) {
|
|
158
|
+
await git(primary, io, ["worktree", "prune"]);
|
|
159
|
+
}
|
|
160
|
+
const del = await git(primary, io, ["branch", "-D", entry.name]);
|
|
122
161
|
if (del.exitCode !== 0) {
|
|
123
162
|
return {
|
|
124
163
|
cleanedUp: false,
|
|
@@ -146,6 +185,30 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
146
185
|
sha,
|
|
147
186
|
detail: journalEvent === "backmerge" ? `back-merged into develop` : `integrated into develop`,
|
|
148
187
|
base: journalBase,
|
|
188
|
+
...(toleratedPaths.length > 0 ? { toleratedState: toleratedPaths } : {}),
|
|
189
|
+
...(journalToleratedDirt !== undefined && journalToleratedDirt.length > 0
|
|
190
|
+
? { toleratedDirt: journalToleratedDirt }
|
|
191
|
+
: {}),
|
|
192
|
+
...(journalAutoResolved !== undefined && journalAutoResolved.length > 0
|
|
193
|
+
? { autoResolved: journalAutoResolved }
|
|
194
|
+
: {}),
|
|
195
|
+
...(journalRemediation?.reattachedTo !== undefined
|
|
196
|
+
? { reattachedTo: journalRemediation.reattachedTo }
|
|
197
|
+
: {}),
|
|
198
|
+
...(journalRemediation?.autoCleaned !== undefined && journalRemediation.autoCleaned.length > 0
|
|
199
|
+
? { autoCleaned: journalRemediation.autoCleaned }
|
|
200
|
+
: {}),
|
|
201
|
+
...(journalRemediation?.autocommitSha !== undefined
|
|
202
|
+
? { autocommitSha: journalRemediation.autocommitSha }
|
|
203
|
+
: {}),
|
|
204
|
+
...(journalRemediation?.restoredImporters !== undefined &&
|
|
205
|
+
journalRemediation.restoredImporters.length > 0
|
|
206
|
+
? { restoredImporters: journalRemediation.restoredImporters }
|
|
207
|
+
: {}),
|
|
208
|
+
...(journalRemediation?.staleImporterCommitSha !== undefined
|
|
209
|
+
? { staleImporterCommitSha: journalRemediation.staleImporterCommitSha }
|
|
210
|
+
: {}),
|
|
211
|
+
...(journalGateReport !== undefined ? { gateReport: journalGateReport } : {}),
|
|
149
212
|
});
|
|
150
213
|
}
|
|
151
214
|
catch (error) {
|
|
@@ -170,8 +233,37 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
170
233
|
/**
|
|
171
234
|
* Core of flow.integrate — callable with an injected clock. Refusal paths
|
|
172
235
|
* return diagnostics; `integrated`/`cleanedUp` report what really happened.
|
|
236
|
+
* The exported wrapper journals every refusal (RFC-1537); this attempt body
|
|
237
|
+
* stays pure.
|
|
173
238
|
*/
|
|
174
239
|
export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
240
|
+
const data = await integrateFlowBranchAttempt(repoRoot, io, opts);
|
|
241
|
+
const error = data.diagnostics.find((d) => d.severity === "error");
|
|
242
|
+
if (error !== undefined && data.branch !== null) {
|
|
243
|
+
// Best-effort bookkeeping — a journal write failure never adds a refusal.
|
|
244
|
+
try {
|
|
245
|
+
const common = await commonGitDir(io, repoRoot);
|
|
246
|
+
const sha = (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/heads/${data.branch}`])).stdout.trim() || "unknown";
|
|
247
|
+
await appendJournal(io, common, {
|
|
248
|
+
event: "integrate-refusal",
|
|
249
|
+
branch: data.branch,
|
|
250
|
+
sha,
|
|
251
|
+
detail: error.message,
|
|
252
|
+
rule: error.ruleId,
|
|
253
|
+
...(data.toleratedState !== undefined ? { toleratedState: data.toleratedState } : {}),
|
|
254
|
+
...(data.toleratedDirt !== undefined ? { toleratedDirt: data.toleratedDirt } : {}),
|
|
255
|
+
// RFC-1532: the refused attempt's report links here too — the journal
|
|
256
|
+
// answers "which gate report belongs to this refusal" in one field.
|
|
257
|
+
...(data.gate?.reportPath ? { gateReport: data.gate.reportPath } : {}),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
/* journal is audit, not gate */
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return data;
|
|
265
|
+
}
|
|
266
|
+
async function integrateFlowBranchAttempt(repoRoot, io, opts) {
|
|
175
267
|
const now = opts.now ?? new Date();
|
|
176
268
|
const branch = opts.branch ?? (await currentBranch(repoRoot, io));
|
|
177
269
|
if (branch === null) {
|
|
@@ -189,6 +281,34 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
189
281
|
}
|
|
190
282
|
const { common, entry } = resolved;
|
|
191
283
|
if (entry === null) {
|
|
284
|
+
// RFC-1538: a second integrate after a successful one finds no entry —
|
|
285
|
+
// report "already-integrated" (exit 0) instead of FLOW-INT-06 when the
|
|
286
|
+
// journal proves the branch landed or develop already contains its tip.
|
|
287
|
+
let contained = false;
|
|
288
|
+
try {
|
|
289
|
+
const journal = await readJournal(io, common);
|
|
290
|
+
contained = journal.some((e) => e.branch === branch && (e.event === "integrate" || e.event === "backmerge"));
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
contained = false;
|
|
294
|
+
}
|
|
295
|
+
if (!contained && (await branchExists(repoRoot, io, branch))) {
|
|
296
|
+
const tip = (await git(repoRoot, io, ["rev-parse", branch])).stdout.trim();
|
|
297
|
+
contained = await isAncestor(repoRoot, io, tip, "develop");
|
|
298
|
+
}
|
|
299
|
+
if (contained) {
|
|
300
|
+
return {
|
|
301
|
+
branch,
|
|
302
|
+
integrated: true,
|
|
303
|
+
developBefore: null,
|
|
304
|
+
developAfter: null,
|
|
305
|
+
rebased: false,
|
|
306
|
+
gate: null,
|
|
307
|
+
cleanedUp: true,
|
|
308
|
+
disposition: "already-integrated",
|
|
309
|
+
diagnostics: [],
|
|
310
|
+
};
|
|
311
|
+
}
|
|
192
312
|
return refuse("FLOW-INT-06", `${branch} is not a registered session/task branch`, "register it with flow.open, or check flow.status for live entries", { branch });
|
|
193
313
|
}
|
|
194
314
|
if (entry.kind === "fix") {
|
|
@@ -203,6 +323,13 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
203
323
|
const live = await worktreeList(primary, io);
|
|
204
324
|
const wtPath = live.find((w) => w.branch === branch)?.path ?? entry.worktree;
|
|
205
325
|
if (wtPath === null || !(await io.exists(wtPath))) {
|
|
326
|
+
// RFC-1531: report the reattach target --reattach would use — nothing
|
|
327
|
+
// is created under --dry-run (AC-7).
|
|
328
|
+
const wouldReattach = opts.reattach === true
|
|
329
|
+
? entry.worktree !== null && (await io.exists(dirname(entry.worktree)))
|
|
330
|
+
? entry.worktree
|
|
331
|
+
: flowWorktreePath(primary, branch)
|
|
332
|
+
: undefined;
|
|
206
333
|
return {
|
|
207
334
|
branch,
|
|
208
335
|
integrated: false,
|
|
@@ -211,17 +338,26 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
211
338
|
rebased: false,
|
|
212
339
|
gate: null,
|
|
213
340
|
cleanedUp: false,
|
|
341
|
+
...(wouldReattach !== undefined ? { wouldReattach } : {}),
|
|
214
342
|
diagnostics: [
|
|
215
343
|
{
|
|
216
344
|
ruleId: "FLOW-07",
|
|
217
345
|
severity: "error",
|
|
218
|
-
message: `registry entry for ${branch} names worktree ${wtPath}, which does not exist
|
|
219
|
-
|
|
346
|
+
message: `registry entry for ${branch} names worktree ${wtPath}, which does not exist (vanished)` +
|
|
347
|
+
(wouldReattach !== undefined
|
|
348
|
+
? ` — --reattach would recreate it at ${wouldReattach}`
|
|
349
|
+
: ""),
|
|
350
|
+
fixHint: "re-run with --reattach to recreate the worktree at its recorded path, or run flow.discard to drop the registry entry and force-delete the branch",
|
|
351
|
+
data: { vanished: true, ...(wouldReattach !== undefined ? { wouldReattach } : {}) },
|
|
220
352
|
},
|
|
221
353
|
],
|
|
222
354
|
};
|
|
223
355
|
}
|
|
224
356
|
const dirty = await statusDirty(wtPath, io);
|
|
357
|
+
// RFC-1531: the dry-run diagnostic carries the classified dirty set so
|
|
358
|
+
// the operator reads the remedy (--auto-clean scope) without mutating.
|
|
359
|
+
const classified = classifyDirtyTree(dirty.entries);
|
|
360
|
+
const disposable = classified.filter((c) => c.class === "disposable").map((c) => c.path);
|
|
225
361
|
return {
|
|
226
362
|
branch,
|
|
227
363
|
integrated: false,
|
|
@@ -230,13 +366,24 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
230
366
|
rebased: false,
|
|
231
367
|
gate: null,
|
|
232
368
|
cleanedUp: false,
|
|
233
|
-
|
|
369
|
+
...(dirty.toleratedState.length > 0 ? { toleratedState: dirty.toleratedState } : {}),
|
|
370
|
+
diagnostics: dirty.entries.length > 0
|
|
234
371
|
? [
|
|
235
372
|
{
|
|
236
373
|
ruleId: "FLOW-INT-01",
|
|
237
374
|
severity: "error",
|
|
238
|
-
message: `worktree ${wtPath} has ${dirty.length} uncommitted change(s)
|
|
239
|
-
|
|
375
|
+
message: `worktree ${wtPath} has ${dirty.entries.length} uncommitted change(s)` +
|
|
376
|
+
(dirty.toleratedState.length > 0
|
|
377
|
+
? ` — tolerated forge-local state: ${dirty.toleratedState.join(", ")}`
|
|
378
|
+
: ""),
|
|
379
|
+
fixHint: "commit or revert the uncommitted changes inside the session worktree, or remediate with --auto-clean / --autocommit, then re-run",
|
|
380
|
+
data: {
|
|
381
|
+
entries: classified,
|
|
382
|
+
classes: summarizeClasses(classified),
|
|
383
|
+
toleratedState: dirty.toleratedState,
|
|
384
|
+
...(opts.autoClean === true ? { wouldAutoClean: disposable } : {}),
|
|
385
|
+
...(opts.autocommit === true ? { wouldAutocommit: true } : {}),
|
|
386
|
+
},
|
|
240
387
|
},
|
|
241
388
|
]
|
|
242
389
|
: [],
|
|
@@ -268,15 +415,267 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
268
415
|
diagnostics: [],
|
|
269
416
|
};
|
|
270
417
|
}
|
|
418
|
+
// RFC-1538: post-lock revalidation — the registry observed pre-lock can
|
|
419
|
+
// have changed while this run waited on the integration lock (F-0138:
|
|
420
|
+
// a racing integrate's teardown deleted entry+worktree under us).
|
|
421
|
+
const liveRegistry = await readRegistry(io, common);
|
|
422
|
+
const liveEntry = liveRegistry.branches.find((b) => b.name === branch);
|
|
423
|
+
if (liveEntry === undefined) {
|
|
424
|
+
// Registration vanished mid-wait. Contained work already landed → the
|
|
425
|
+
// winner completed; report idempotently. Otherwise mid-teardown.
|
|
426
|
+
const liveBranch = await branchExists(primary, io, branch);
|
|
427
|
+
const liveContained = liveBranch &&
|
|
428
|
+
(await isAncestor(primary, io, (await git(primary, io, ["rev-parse", branch])).stdout.trim(), "develop"));
|
|
429
|
+
if (liveContained || !liveBranch) {
|
|
430
|
+
return {
|
|
431
|
+
branch,
|
|
432
|
+
integrated: true,
|
|
433
|
+
developBefore,
|
|
434
|
+
developAfter: developBefore,
|
|
435
|
+
rebased: false,
|
|
436
|
+
gate: null,
|
|
437
|
+
cleanedUp: true,
|
|
438
|
+
disposition: "already-integrated",
|
|
439
|
+
diagnostics: [],
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return refuse("FLOW-INT-15", `registry entry for ${branch} vanished while waiting on the integration lock, but the branch is not contained in develop (mid-teardown state)`, "run flow.status for the live view; recover the orphaned entry with flow.discard", { branch, developBefore });
|
|
443
|
+
}
|
|
271
444
|
// (2) the branch worktree must exist and be clean.
|
|
272
445
|
const worktrees = await worktreeList(primary, io);
|
|
273
|
-
|
|
446
|
+
// `live` is the worktree git currently associates with the branch — a
|
|
447
|
+
// STALE registration keeps naming the dead recorded path until pruned,
|
|
448
|
+
// so `live !== null` does not prove the directory exists.
|
|
449
|
+
const live = worktrees.find((w) => w.branch === branch)?.path ?? null;
|
|
450
|
+
let branchWorktree = live ?? liveEntry.worktree;
|
|
451
|
+
let reattachedTo;
|
|
452
|
+
// Occupied: the recorded path exists on disk but git associates no live
|
|
453
|
+
// worktree with the branch — a foreign tree squats there.
|
|
454
|
+
const occupied = live === null && liveEntry.worktree !== null && (await io.exists(liveEntry.worktree));
|
|
455
|
+
const vanished = !occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
456
|
+
if (opts.reattach === true && occupied) {
|
|
457
|
+
return refuse("FLOW-INT-17", `registry worktree path ${liveEntry.worktree} exists on disk but is not a worktree of ${branch} (occupied)`, "remove or rename the occupant, then re-run flow.integrate --reattach", { branch, developBefore }, { occupied: true });
|
|
458
|
+
}
|
|
459
|
+
if (opts.reattach === true && vanished) {
|
|
460
|
+
// RFC-1531 --reattach: recreate the vanished worktree inside the lock,
|
|
461
|
+
// before the dirty/preflight checks. The recorded registry path is
|
|
462
|
+
// preferred when its parent exists (operators learned that location);
|
|
463
|
+
// the canonical <repo>@<branch> sibling is the fallback.
|
|
464
|
+
const recorded = liveEntry.worktree;
|
|
465
|
+
const target = recorded !== null && (await io.exists(dirname(recorded)))
|
|
466
|
+
? recorded
|
|
467
|
+
: flowWorktreePath(primary, branch);
|
|
468
|
+
// F-0093: a vanished worktree can leave a stale `git worktree`
|
|
469
|
+
// registration that pins the branch — prune before adding (mirrors
|
|
470
|
+
// cleanupIntegrated's ordering).
|
|
471
|
+
await git(primary, io, ["worktree", "prune"]);
|
|
472
|
+
const add = await worktreeAdd(primary, io, target, branch);
|
|
473
|
+
if (add.exitCode !== 0) {
|
|
474
|
+
return refuse("FLOW-INT-17", `git worktree add ${target} ${branch} failed: ${add.stderr.trim()}`, "resolve the git error (stale registration? occupied path?) and re-run flow.integrate --reattach", { branch, developBefore });
|
|
475
|
+
}
|
|
476
|
+
reattachedTo = target;
|
|
477
|
+
branchWorktree = target;
|
|
478
|
+
opts.onProgress?.(`reattached ${branch} at ${target}`);
|
|
479
|
+
}
|
|
274
480
|
if (branchWorktree === null || !(await io.exists(branchWorktree))) {
|
|
275
|
-
return refuse("FLOW-
|
|
481
|
+
return refuse("FLOW-INT-15", `registry entry for ${branch} names worktree ${branchWorktree}, which does not exist (vanished mid-teardown state — the branch is not contained in develop)`, "re-run with --reattach to recreate the worktree, or run flow.status for the live view and flow.discard to drop the entry", { branch, developBefore }, { vanished: true });
|
|
276
482
|
}
|
|
277
|
-
|
|
278
|
-
if (dirty.length > 0) {
|
|
279
|
-
|
|
483
|
+
let dirty = await statusDirty(branchWorktree, io);
|
|
484
|
+
if (dirty.toleratedState.length > 0) {
|
|
485
|
+
opts.onProgress?.(`tolerated forge-local state: ${dirty.toleratedState.join(", ")}`);
|
|
486
|
+
}
|
|
487
|
+
// RFC-1544 AC-2: referent-aware importer-prune resolution — before any
|
|
488
|
+
// remediation, so --autocommit can never sweep a foreign mission's live
|
|
489
|
+
// importer into a commit. `foreign-open-mission` restores the committed
|
|
490
|
+
// importer subtree (never a whole-file checkout — sibling lockfile diffs
|
|
491
|
+
// keep their own classification); `importer-prune-stale` accepts the
|
|
492
|
+
// prune as cleanup and commits it so dead residue stops churning.
|
|
493
|
+
let restoredImporters;
|
|
494
|
+
let staleImporterCommitSha;
|
|
495
|
+
if (dirty.entries.some((line) => line.slice(3).trim() === "pnpm-lock.yaml")) {
|
|
496
|
+
const { classifyDirt, resolveImporterReferents } = await import("../preflight.js");
|
|
497
|
+
const { extractImporterBlock, insertImporterBlock } = await import("../../mission/importer-block.js");
|
|
498
|
+
const pruneVerdict = await classifyDirt(branchWorktree, io, dirty.entries, { runGit: git }, [], (ids) => resolveImporterReferents(branchWorktree, io, ids));
|
|
499
|
+
const lockTolerated = pruneVerdict.tolerated.find((t) => t.path === "pnpm-lock.yaml");
|
|
500
|
+
if (lockTolerated?.class === "foreign-open-mission" &&
|
|
501
|
+
lockTolerated.missionIds !== undefined) {
|
|
502
|
+
const head = await git(branchWorktree, io, ["show", "HEAD:pnpm-lock.yaml"]);
|
|
503
|
+
if (head.exitCode === 0) {
|
|
504
|
+
let next = await io.readFile(join(branchWorktree, "pnpm-lock.yaml"));
|
|
505
|
+
const restored = [];
|
|
506
|
+
for (const id of lockTolerated.missionIds) {
|
|
507
|
+
const key = `missions/${id}/workpiece`;
|
|
508
|
+
const block = extractImporterBlock(head.stdout, key);
|
|
509
|
+
if (block === null)
|
|
510
|
+
continue;
|
|
511
|
+
const spliced = insertImporterBlock(next, key, block);
|
|
512
|
+
if (spliced === null)
|
|
513
|
+
continue;
|
|
514
|
+
next = spliced;
|
|
515
|
+
restored.push(id);
|
|
516
|
+
}
|
|
517
|
+
if (restored.length > 0) {
|
|
518
|
+
await io.writeFile(join(branchWorktree, "pnpm-lock.yaml"), next);
|
|
519
|
+
restoredImporters = restored;
|
|
520
|
+
opts.onProgress?.(`restored foreign mission importer(s): ${restored.map((id) => `missions/${id}/workpiece`).join(", ")}`);
|
|
521
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
else if (lockTolerated?.class === "importer-prune-stale") {
|
|
526
|
+
const add = await git(branchWorktree, io, ["add", "pnpm-lock.yaml"]);
|
|
527
|
+
const commit = add.exitCode === 0
|
|
528
|
+
? await gitCommit(branchWorktree, io, ["commit", "-m", "chore(flow): prune stale mission importer"], "integrate")
|
|
529
|
+
: add;
|
|
530
|
+
if (commit.exitCode === 0) {
|
|
531
|
+
staleImporterCommitSha = (await git(branchWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
532
|
+
opts.onProgress?.(`committed stale importer prune ${staleImporterCommitSha.slice(0, 9)} (${(lockTolerated.missionIds ?? []).map((id) => `missions/${id}/workpiece`).join(", ")})`);
|
|
533
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
// RFC-1531 remediation flags — before the dirty checks: --auto-clean
|
|
538
|
+
// deletes ONLY disposable-class paths (closed allowlist — a work-class
|
|
539
|
+
// member in the set deletes nothing and still refuses FLOW-INT-01, and
|
|
540
|
+
// an importer-prune lockfile refuses too: restoring/committing it is a
|
|
541
|
+
// content decision, AC-4), then --autocommit sweeps the remainder into
|
|
542
|
+
// the fixed-subject commit. Remediation failures refuse FLOW-INT-17.
|
|
543
|
+
let autoCleaned;
|
|
544
|
+
let autocommitSha;
|
|
545
|
+
if (dirty.entries.length > 0 && (opts.autoClean === true || opts.autocommit === true)) {
|
|
546
|
+
const { classifyDirtyEntries } = await import("../preflight.js");
|
|
547
|
+
const classified = await classifyDirtyEntries(branchWorktree, io, dirty.entries);
|
|
548
|
+
// Pass = AUTO_CLEAN_PASS_CLASSES (tolerated family incl. the RFC-1537
|
|
549
|
+
// regenerable classes) or disposable. Blocker = work or importer-prune
|
|
550
|
+
// — AC-4 names importer-prune a refusal class: restoring/committing a
|
|
551
|
+
// lockfile is a content decision, never a cleanup step.
|
|
552
|
+
const blocker = classified.filter((c) => c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class));
|
|
553
|
+
if (opts.autoClean === true) {
|
|
554
|
+
// A blocker refuses only when nothing downstream will commit it:
|
|
555
|
+
// with --autocommit also set, work members sweep into the commit —
|
|
556
|
+
// the RFC's composed order is clean → commit → integrate.
|
|
557
|
+
if (blocker.length > 0 && opts.autocommit !== true) {
|
|
558
|
+
return refuse("FLOW-INT-01", `worktree ${branchWorktree} has ${blocker.length} uncommitted change(s) outside the disposable set: ${blocker
|
|
559
|
+
.slice(0, 10)
|
|
560
|
+
.map((b) => `${b.path} (${b.class})`)
|
|
561
|
+
.join(", ")} — --auto-clean deletes nothing on a mixed set`, "commit or revert the work-class entries inside the session worktree, or re-run with --autocommit to sweep them into a commit", { branch, developBefore, toleratedState: dirty.toleratedState }, {
|
|
562
|
+
entries: classified,
|
|
563
|
+
classes: summarizeClasses(classified),
|
|
564
|
+
toleratedState: dirty.toleratedState,
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const toDelete = classified.filter((c) => c.class === "disposable");
|
|
568
|
+
autoCleaned = [];
|
|
569
|
+
for (const entry of toDelete) {
|
|
570
|
+
try {
|
|
571
|
+
await rm(join(branchWorktree, entry.path), { force: true, recursive: true });
|
|
572
|
+
autoCleaned.push(entry.path);
|
|
573
|
+
opts.onProgress?.(`auto-clean: deleted ${entry.path}`);
|
|
574
|
+
}
|
|
575
|
+
catch (error) {
|
|
576
|
+
return refuse("FLOW-INT-17", `--auto-clean could not delete ${entry.path}: ${error instanceof Error ? error.message : String(error)}`, "delete the path manually inside the session worktree, then re-run flow.integrate", { branch, developBefore, autoCleaned });
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
580
|
+
}
|
|
581
|
+
if (opts.autocommit === true && dirty.entries.length > 0) {
|
|
582
|
+
// Stage exactly the remaining entry paths — never `git add -A`:
|
|
583
|
+
// tolerated FORGE_STATE paths are journaled, never committed.
|
|
584
|
+
const paths = dirty.entries.map((line) => line.slice(3).trim());
|
|
585
|
+
const add = await git(branchWorktree, io, ["add", "-A", "--", ...paths]);
|
|
586
|
+
if (add.exitCode !== 0) {
|
|
587
|
+
return refuse("FLOW-INT-17", `--autocommit staging failed: ${add.stderr.trim()}`, "inspect the session worktree state, then re-run flow.integrate", { branch, developBefore, autoCleaned });
|
|
588
|
+
}
|
|
589
|
+
const commit = await gitCommit(branchWorktree, io, ["commit", "-m", SWEEP_COMMIT_SUBJECT], "integrate");
|
|
590
|
+
if (commit.exitCode !== 0) {
|
|
591
|
+
return refuse("FLOW-INT-17", `--autocommit commit failed: ${commit.stderr.trim()}`, "the staging stays for the operator to inspect — resolve and commit or reset inside the session worktree, then re-run", { branch, developBefore, autoCleaned });
|
|
592
|
+
}
|
|
593
|
+
autocommitSha = (await git(branchWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
594
|
+
opts.onProgress?.(`autocommit: swept ${paths.length} path(s) into ${autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`);
|
|
595
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
// RFC-1537: declared regenerable dirt tolerated on this attempt —
|
|
599
|
+
// surfaced in data + journaled on integrate/refusal, never committed.
|
|
600
|
+
let toleratedDirt = [];
|
|
601
|
+
// RFC-1528: bounded preflight — dirty-tree checks with lockfile
|
|
602
|
+
// classification, then the four validators that used to fire only inside
|
|
603
|
+
// the expensive integration gate. Non-port path only (port entries keep
|
|
604
|
+
// their own FLOW-INT-09/10 semantics); first failure refuses before the
|
|
605
|
+
// rebase and before the gate spawns.
|
|
606
|
+
if (entry.port === null) {
|
|
607
|
+
const { runIntegratePreflight } = await import("../preflight.js");
|
|
608
|
+
const preflight = await runIntegratePreflight({
|
|
609
|
+
primary,
|
|
610
|
+
branchWorktree,
|
|
611
|
+
branch,
|
|
612
|
+
io,
|
|
613
|
+
worktreeDirty: dirty,
|
|
614
|
+
invoke: opts.invoke,
|
|
615
|
+
commandRegistry: opts.commandRegistry,
|
|
616
|
+
waitForeignSeconds: opts.waitForeignSeconds,
|
|
617
|
+
onProgress: opts.onProgress,
|
|
618
|
+
});
|
|
619
|
+
toleratedDirt = preflight.tolerated;
|
|
620
|
+
for (const skipped of preflight.skipped) {
|
|
621
|
+
opts.onProgress?.(skipped.reason === "no-invoke"
|
|
622
|
+
? `preflight: ${skipped.check} skipped — no invoke port (standalone CLI)`
|
|
623
|
+
: `preflight: ${skipped.check} skipped — command not in the live inventory`);
|
|
624
|
+
}
|
|
625
|
+
for (const t of preflight.tolerated) {
|
|
626
|
+
opts.onProgress?.(`tolerated regenerable state: ${t.path} (${t.class})`);
|
|
627
|
+
}
|
|
628
|
+
if (!preflight.ok && preflight.refuse) {
|
|
629
|
+
return refuse(preflight.refuse.ruleId, preflight.refuse.message, preflight.refuse.fixHint, {
|
|
630
|
+
branch,
|
|
631
|
+
developBefore,
|
|
632
|
+
toleratedState: dirty.toleratedState,
|
|
633
|
+
toleratedDirt: preflight.tolerated,
|
|
634
|
+
reattachedTo,
|
|
635
|
+
autoCleaned,
|
|
636
|
+
autocommitSha,
|
|
637
|
+
restoredImporters,
|
|
638
|
+
staleImporterCommitSha,
|
|
639
|
+
}, preflight.refuse.data);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
else if (dirty.entries.length > 0) {
|
|
643
|
+
// Port path keeps its own refusal surface but the same regenerable
|
|
644
|
+
// classes still tolerate (RFC-1537) — an importer-materializing port
|
|
645
|
+
// worktree is no harder to integrate than a session one.
|
|
646
|
+
const { classifyDirt } = await import("../preflight.js");
|
|
647
|
+
const verdict = await classifyDirt(branchWorktree, io, dirty.entries);
|
|
648
|
+
toleratedDirt = verdict.tolerated;
|
|
649
|
+
for (const t of verdict.tolerated) {
|
|
650
|
+
opts.onProgress?.(`tolerated regenerable state: ${t.path} (${t.class})`);
|
|
651
|
+
}
|
|
652
|
+
if (verdict.unattributed.length > 0) {
|
|
653
|
+
const entries = verdict.unattributed.map((line) => {
|
|
654
|
+
const path = line.slice(3).trim();
|
|
655
|
+
return { path, class: classifyDirtyPath(path) };
|
|
656
|
+
});
|
|
657
|
+
return refuse("FLOW-INT-01", `worktree ${branchWorktree} has ${verdict.unattributed.length} uncommitted change(s): ${verdict.unattributed.slice(0, 10).join(", ")}` +
|
|
658
|
+
(verdict.tolerated.length > 0
|
|
659
|
+
? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
|
|
660
|
+
: "") +
|
|
661
|
+
(dirty.toleratedState.length > 0
|
|
662
|
+
? ` — tolerated forge-local state: ${dirty.toleratedState.join(", ")}`
|
|
663
|
+
: ""), "commit or revert the uncommitted changes inside the session worktree, or remediate with --auto-clean / --autocommit, then re-run", {
|
|
664
|
+
branch,
|
|
665
|
+
developBefore,
|
|
666
|
+
toleratedState: dirty.toleratedState,
|
|
667
|
+
toleratedDirt: verdict.tolerated,
|
|
668
|
+
reattachedTo,
|
|
669
|
+
autoCleaned,
|
|
670
|
+
autocommitSha,
|
|
671
|
+
restoredImporters,
|
|
672
|
+
staleImporterCommitSha,
|
|
673
|
+
}, {
|
|
674
|
+
entries,
|
|
675
|
+
classes: summarizeClasses(entries),
|
|
676
|
+
toleratedState: dirty.toleratedState,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
280
679
|
}
|
|
281
680
|
// Port entries (RFC-1490): develop must not have moved since the port
|
|
282
681
|
// opened, and the tip must be the fixed-message merge whose second
|
|
@@ -294,27 +693,96 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
294
693
|
}
|
|
295
694
|
}
|
|
296
695
|
// (3) rebase onto the current develop — never for port entries.
|
|
696
|
+
// RFC-1538: a conflict confined to generated artifacts resolves via its
|
|
697
|
+
// owner command (checkout --theirs + regenerate + continue) — the
|
|
698
|
+
// generated-file doctrine applied inside the rebase path; anything else
|
|
699
|
+
// still refuses FLOW-INT-02 for a human.
|
|
297
700
|
const rebaseBase = (await git(primary, io, ["rev-parse", "develop"])).stdout.trim();
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
"diff",
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
701
|
+
const autoResolved = [];
|
|
702
|
+
if (entry.port === null) {
|
|
703
|
+
let rebase = await git(branchWorktree, io, ["rebase", "develop"]);
|
|
704
|
+
let guard = 0;
|
|
705
|
+
while (rebase.exitCode !== 0 && guard++ < 8) {
|
|
706
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
707
|
+
const paths = conflicts.stdout
|
|
708
|
+
.split("\n")
|
|
709
|
+
.map((l) => l.trim())
|
|
710
|
+
.filter((l) => l.length > 0);
|
|
711
|
+
const { classifyRebaseConflicts } = await import("../preflight.js");
|
|
712
|
+
const verdict = await classifyRebaseConflicts(branchWorktree, io, paths);
|
|
713
|
+
// RFC-1545 AC-2: without a kernel invoke port the standalone adapter
|
|
714
|
+
// spawns the allowlisted owner commands in the worktree — the
|
|
715
|
+
// resolution contract is identical either way.
|
|
716
|
+
const invoker = opts.invoke ??
|
|
717
|
+
standaloneInvoke(io, branchWorktree, verdict.owners.map((o) => o.command));
|
|
718
|
+
const resolvable = paths.length > 0 &&
|
|
719
|
+
verdict.nonGenerated.length === 0 &&
|
|
720
|
+
verdict.owners.length === paths.length;
|
|
721
|
+
if (!resolvable) {
|
|
722
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
723
|
+
return refuse("FLOW-INT-02", `rebase onto develop conflicts in: ${paths.join(", ") || "(unknown paths)"}` +
|
|
724
|
+
(verdict.owners.length > 0 ? " — mixed generated/non-generated conflict set" : ""), "resolve the rebase inside the session worktree, commit, and re-run flow.integrate", { branch, developBefore });
|
|
725
|
+
}
|
|
726
|
+
let failed = false;
|
|
727
|
+
for (const o of verdict.owners) {
|
|
728
|
+
// `git checkout --theirs` is blocked by the agent-session git
|
|
729
|
+
// wrapper — materialize the stage-3 (theirs) blob through the
|
|
730
|
+
// read-only `git show` + io write instead (RFC-1545).
|
|
731
|
+
const theirs = await git(branchWorktree, io, ["show", `:3:${o.path}`]);
|
|
732
|
+
if (theirs.exitCode === 0) {
|
|
733
|
+
await io.writeFile(join(branchWorktree, o.path), theirs.stdout);
|
|
734
|
+
}
|
|
735
|
+
const regen = await invoker(o.command, o.flags);
|
|
736
|
+
if (regen.ok === false || (regen.exitCode !== undefined && regen.exitCode !== 0)) {
|
|
737
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
738
|
+
failed = true;
|
|
739
|
+
return refuse("FLOW-INT-02", `auto-resolve of generated conflict ${o.path} failed: ${o.command} — ${regen.summary ?? `exit ${regen.exitCode}`}`, "resolve the rebase inside the session worktree manually, commit, and re-run flow.integrate", { branch, developBefore });
|
|
740
|
+
}
|
|
741
|
+
// RFC-1545 AC-4: a successful generator that left conflict markers
|
|
742
|
+
// behind must not be committed — escalate like a failure.
|
|
743
|
+
const regenerated = await io.readFile(join(branchWorktree, o.path));
|
|
744
|
+
if (/^(<{7}|={7}|>{7})/m.test(regenerated)) {
|
|
745
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
746
|
+
failed = true;
|
|
747
|
+
return refuse("FLOW-INT-02", `auto-resolve of generated conflict ${o.path} failed: ${o.command} left conflict markers in the regenerated output`, "resolve the rebase inside the session worktree manually, commit, and re-run flow.integrate", { branch, developBefore });
|
|
748
|
+
}
|
|
749
|
+
await git(branchWorktree, io, ["add", "--", o.path]);
|
|
750
|
+
opts.onProgress?.(`conflict: ${o.path} — regenerated via ${o.command}`);
|
|
751
|
+
autoResolved.push(o.path);
|
|
752
|
+
}
|
|
753
|
+
if (failed)
|
|
754
|
+
break;
|
|
755
|
+
rebase = await git(branchWorktree, io, ["-c", "core.editor=true", "rebase", "--continue"]);
|
|
756
|
+
}
|
|
757
|
+
if (rebase.exitCode !== 0) {
|
|
758
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
759
|
+
const paths = conflicts.stdout
|
|
760
|
+
.split("\n")
|
|
761
|
+
.map((l) => l.trim())
|
|
762
|
+
.filter((l) => l.length > 0);
|
|
763
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
764
|
+
return refuse("FLOW-INT-02", `rebase onto develop conflicts in: ${paths.join(", ") || "(unknown paths)"}`, "resolve the rebase inside the session worktree, commit, and re-run flow.integrate", { branch, developBefore });
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
// (4) integration gate — the primary's script, executed by the session
|
|
768
|
+
// engine's build when the worktree carries one (RFC-1538): the code
|
|
769
|
+
// under review judges itself; the checks it faces stay primary-owned.
|
|
770
|
+
const { resolveGateEngine } = await import("../gate-engine.js");
|
|
771
|
+
const engine = await resolveGateEngine(branchWorktree, primary, io);
|
|
772
|
+
const warnings = [];
|
|
773
|
+
if (engine.source === "primary" &&
|
|
774
|
+
(await io.exists(join(primary, "hooks", "integration-gate.sh")))) {
|
|
775
|
+
warnings.push({
|
|
776
|
+
ruleId: "FLOW-INT-16",
|
|
777
|
+
severity: "warning",
|
|
778
|
+
message: `no session engine build under ${branchWorktree} — the integration gate runs the primary engine`,
|
|
779
|
+
fixHint: "run pnpm install inside the session worktree to have its own build judged; the F-0137 self-referential escape is a backport worktree",
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
opts.onProgress?.(`gate engine: ${engine.source} (${engine.root})`);
|
|
315
783
|
const gate = await runFlowScript(io, "integration-gate", {
|
|
316
784
|
primary,
|
|
317
|
-
cwd:
|
|
785
|
+
cwd: engine.root,
|
|
318
786
|
env: {
|
|
319
787
|
FLOW_PRIMARY: primary,
|
|
320
788
|
FLOW_BRANCH: branch,
|
|
@@ -323,15 +791,40 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
323
791
|
},
|
|
324
792
|
});
|
|
325
793
|
if (gate.status === "failed") {
|
|
326
|
-
return refuse("FLOW-INT-05", `hooks/integration-gate.sh refused the integration (exit ${gate.exitCode}): ${gate.stderrTail}`, `fix what ${primary}/hooks/integration-gate.sh demands, then re-run`, { branch, developBefore, rebased: entry.port === null, gate }
|
|
794
|
+
return refuse("FLOW-INT-05", `hooks/integration-gate.sh refused the integration (exit ${gate.exitCode}): ${gate.stderrTail}`, `fix what ${primary}/hooks/integration-gate.sh demands, then re-run`, { branch, developBefore, rebased: entry.port === null, gate },
|
|
795
|
+
// RFC-1532 AC-4: name the persisted report so the fixing agent reads
|
|
796
|
+
// full check rows instead of re-running the gate.
|
|
797
|
+
gate.reportPath ? { reportPath: gate.reportPath } : undefined);
|
|
327
798
|
}
|
|
328
|
-
// (5) primary must sit clean on develop, then fast-forward.
|
|
799
|
+
// (5) primary must sit clean on develop, then fast-forward. Mid-gate
|
|
800
|
+
// importer churn from another session's open mission tolerates here too
|
|
801
|
+
// (RFC-1537) — the same classifier the preflight ran.
|
|
329
802
|
const primaryBranch = await currentBranch(primary, io);
|
|
330
803
|
const primaryDirty = await statusTracked(primary, io);
|
|
331
|
-
if (primaryBranch !== "develop" || primaryDirty.length > 0) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
804
|
+
if (primaryBranch !== "develop" || primaryDirty.entries.length > 0) {
|
|
805
|
+
let unattributed = primaryDirty.entries;
|
|
806
|
+
if (primaryDirty.entries.length > 0) {
|
|
807
|
+
const { classifyDirt } = await import("../preflight.js");
|
|
808
|
+
const verdict = await classifyDirt(primary, io, primaryDirty.entries);
|
|
809
|
+
unattributed = verdict.unattributed;
|
|
810
|
+
if (verdict.tolerated.length > 0) {
|
|
811
|
+
toleratedDirt = [...toleratedDirt, ...verdict.tolerated];
|
|
812
|
+
for (const t of verdict.tolerated) {
|
|
813
|
+
opts.onProgress?.(`tolerated regenerable state on primary: ${t.path} (${t.class})`);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
if (primaryBranch !== "develop" || unattributed.length > 0) {
|
|
818
|
+
return refuse("FLOW-INT-03", primaryBranch !== "develop"
|
|
819
|
+
? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
|
|
820
|
+
: `primary worktree has ${unattributed.length} uncommitted change(s)`, "switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased", {
|
|
821
|
+
branch,
|
|
822
|
+
developBefore,
|
|
823
|
+
rebased: entry.port === null,
|
|
824
|
+
gate,
|
|
825
|
+
...(toleratedDirt.length > 0 ? { toleratedDirt } : {}),
|
|
826
|
+
});
|
|
827
|
+
}
|
|
335
828
|
}
|
|
336
829
|
const developNow = (await git(primary, io, ["rev-parse", "develop"])).stdout.trim();
|
|
337
830
|
if (!(await isAncestor(primary, io, developNow, branch))) {
|
|
@@ -350,38 +843,70 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
350
843
|
rebased: entry.port === null,
|
|
351
844
|
gate,
|
|
352
845
|
cleanedUp: false,
|
|
353
|
-
|
|
846
|
+
...(dirty.toleratedState.length > 0 ? { toleratedState: dirty.toleratedState } : {}),
|
|
847
|
+
...(toleratedDirt.length > 0 ? { toleratedDirt } : {}),
|
|
848
|
+
...(autoResolved.length > 0 ? { autoResolved } : {}),
|
|
849
|
+
...(reattachedTo !== undefined ? { reattachedTo } : {}),
|
|
850
|
+
...(autoCleaned !== undefined && autoCleaned.length > 0 ? { autoCleaned } : {}),
|
|
851
|
+
...(autocommitSha !== undefined ? { autocommitSha } : {}),
|
|
852
|
+
...(restoredImporters !== undefined && restoredImporters.length > 0
|
|
853
|
+
? { restoredImporters }
|
|
854
|
+
: {}),
|
|
855
|
+
...(staleImporterCommitSha !== undefined ? { staleImporterCommitSha } : {}),
|
|
856
|
+
gateEngine: engine.source,
|
|
857
|
+
diagnostics: warnings,
|
|
354
858
|
};
|
|
355
859
|
};
|
|
356
860
|
let inner;
|
|
357
861
|
try {
|
|
358
|
-
inner =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
862
|
+
inner =
|
|
863
|
+
opts.lockHeld === true
|
|
864
|
+
? await integrateInner()
|
|
865
|
+
: await withFlowLock(lockPath, {
|
|
866
|
+
waitMs: opts.lockWaitMs ?? INTEGRATE_LOCK_WAIT_MS,
|
|
867
|
+
staleMs: INTEGRATE_LOCK_STALE_MS,
|
|
868
|
+
progressEveryMs: 60_000,
|
|
869
|
+
onProgress: opts.onProgress,
|
|
870
|
+
onStale: (l) => opts.onProgress?.(l.reason === "dead-holder"
|
|
871
|
+
? `broke dead-holder integration lock (pid ${l.pid ?? "?"} on ${l.host ?? "?"}, held since ${l.at})`
|
|
872
|
+
: `broke stale integration lock (held since ${l.at}, ${Math.round(l.ageMs / 60000)} min old)`),
|
|
873
|
+
}, integrateInner, io);
|
|
369
874
|
}
|
|
370
875
|
catch (error) {
|
|
371
876
|
if (error instanceof LockTimeoutError) {
|
|
372
|
-
|
|
877
|
+
// RFC-1515 AC-4: a refused attempt reports the holder on the first
|
|
878
|
+
// try — the lock payload names pid/host/at/heldMs plus a disposition
|
|
879
|
+
// computed by the same dead-holder classifier withFlowLock uses.
|
|
880
|
+
const holder = error.holder;
|
|
881
|
+
const lock = holder === undefined ? undefined : describeHeldLock(holder, INTEGRATE_LOCK_STALE_MS);
|
|
882
|
+
return refuse("FLOW-INT-08", lock === undefined
|
|
883
|
+
? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
|
|
884
|
+
: `integration lock ${error.lockPath} is held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`, "run forge werkstatt.lock.status for the live view, or forge werkstatt.lock.recover to break a dead holder's lock", { branch, lock });
|
|
373
885
|
}
|
|
374
886
|
if (error instanceof FlowRegistrySchemaError) {
|
|
375
|
-
return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
|
|
887
|
+
return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
|
|
888
|
+
branch,
|
|
889
|
+
});
|
|
376
890
|
}
|
|
377
891
|
throw error;
|
|
378
892
|
}
|
|
379
|
-
|
|
893
|
+
// Only error-severity diagnostics are refusals — warnings (e.g. the
|
|
894
|
+
// FLOW-INT-16 primary-engine notice) must not skip cleanup and journaling.
|
|
895
|
+
if (!inner.integrated || inner.diagnostics.some((d) => d.severity === "error"))
|
|
380
896
|
return inner;
|
|
381
897
|
// (6) cleanup — outside the lock; every git call runs with -C primary.
|
|
898
|
+
// RFC-1536: prune this session's own id reservations once the branch
|
|
899
|
+
// landed — other sessions' entries stay untouched.
|
|
900
|
+
await pruneReservationsForSession(io, primary, branch);
|
|
382
901
|
const worktrees = await worktreeList(primary, io);
|
|
383
902
|
const branchWorktree = worktrees.find((w) => w.branch === branch)?.path ?? entry.worktree;
|
|
384
|
-
const cleanup = await cleanupIntegrated(primary, branchWorktree, entry, common, inner.developAfter ?? inner.developBefore ?? "", io, now.toISOString(), entry.port !== null ? "backmerge" : "integrate", inner.developBefore ?? undefined
|
|
903
|
+
const cleanup = await cleanupIntegrated(primary, branchWorktree, entry, common, inner.developAfter ?? inner.developBefore ?? "", io, now.toISOString(), entry.port !== null ? "backmerge" : "integrate", inner.developBefore ?? undefined, inner.toleratedDirt, inner.autoResolved, {
|
|
904
|
+
reattachedTo: inner.reattachedTo,
|
|
905
|
+
autoCleaned: inner.autoCleaned,
|
|
906
|
+
autocommitSha: inner.autocommitSha,
|
|
907
|
+
restoredImporters: inner.restoredImporters,
|
|
908
|
+
staleImporterCommitSha: inner.staleImporterCommitSha,
|
|
909
|
+
}, inner.gate?.reportPath ?? undefined);
|
|
385
910
|
return {
|
|
386
911
|
...inner,
|
|
387
912
|
gate: inner.gate,
|
|
@@ -403,6 +928,15 @@ export async function runFlowIntegrate(input, context) {
|
|
|
403
928
|
branch: typeof branchFlag === "string" ? branchFlag : null,
|
|
404
929
|
dryRun: context.dryRun || input.flags["dry-run"] === true,
|
|
405
930
|
onProgress: (m) => logger.info(` ${m}`),
|
|
931
|
+
invoke: context.invoke,
|
|
932
|
+
commandRegistry: context.commandRegistry,
|
|
933
|
+
reattach: input.flags["reattach"] === true,
|
|
934
|
+
autoClean: input.flags["auto-clean"] === true,
|
|
935
|
+
autocommit: input.flags["autocommit"] === true,
|
|
936
|
+
waitForeignSeconds: typeof input.flags["wait-foreign"] === "string" ||
|
|
937
|
+
typeof input.flags["wait-foreign"] === "number"
|
|
938
|
+
? Number(input.flags["wait-foreign"])
|
|
939
|
+
: undefined,
|
|
406
940
|
});
|
|
407
941
|
const refused = data.diagnostics.find((d) => d.severity === "error");
|
|
408
942
|
if (outputFormat === "pretty") {
|
|
@@ -415,6 +949,21 @@ export async function runFlowIntegrate(input, context) {
|
|
|
415
949
|
logger.info(` integrated: ${data.integrated}${data.rebased ? " (rebased)" : ""}`);
|
|
416
950
|
logger.info(` develop: ${data.developBefore?.slice(0, 9)} → ${data.developAfter?.slice(0, 9)}`);
|
|
417
951
|
logger.info(` cleanedUp: ${data.cleanedUp}`);
|
|
952
|
+
if (data.toleratedDirt !== undefined && data.toleratedDirt.length > 0) {
|
|
953
|
+
logger.info(` tolerated: ${data.toleratedDirt.map((t) => `${t.path} (${t.class})`).join(", ")}`);
|
|
954
|
+
}
|
|
955
|
+
if (data.toleratedState !== undefined && data.toleratedState.length > 0) {
|
|
956
|
+
logger.info(` tolerated forge state: ${data.toleratedState.join(", ")}`);
|
|
957
|
+
}
|
|
958
|
+
if (data.reattachedTo !== undefined) {
|
|
959
|
+
logger.info(` reattached: ${data.reattachedTo}`);
|
|
960
|
+
}
|
|
961
|
+
if (data.autoCleaned !== undefined && data.autoCleaned.length > 0) {
|
|
962
|
+
logger.info(` auto-cleaned: ${data.autoCleaned.join(", ")}`);
|
|
963
|
+
}
|
|
964
|
+
if (data.autocommitSha !== undefined) {
|
|
965
|
+
logger.info(` autocommit: ${data.autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`);
|
|
966
|
+
}
|
|
418
967
|
}
|
|
419
968
|
}
|
|
420
969
|
return {
|