@warpgogol/forge 9.3.1 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +32 -0
- package/CHANGELOG.md +25 -0
- package/README.md +2 -2
- 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 +48 -0
- package/dist/os/flow/dirty-classify.d.ts.map +1 -0
- package/dist/os/flow/dirty-classify.js +81 -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 +85 -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 +54 -31
- 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 +48 -2
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +536 -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-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 +1 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +3 -1
- 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/preflight.d.ts +114 -0
- package/dist/os/flow/preflight.d.ts.map +1 -0
- package/dist/os/flow/preflight.js +620 -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/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/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 +83 -8
- 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 +35 -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-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/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 +112 -0
- package/os/flow/flow.module.ts +92 -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 +97 -46
- 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 +808 -182
- package/os/flow/handlers/flow-open.ts +135 -11
- package/os/flow/handlers/flow-status.ts +45 -13
- package/os/flow/index.ts +3 -1
- package/os/flow/line-version.ts +2 -1
- package/os/flow/locks.ts +56 -14
- package/os/flow/preflight.ts +763 -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/tests/dirty-classify.test.ts +116 -0
- package/os/flow/tests/fixtures/branch-names.yaml +40 -40
- 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 +561 -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 +348 -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/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/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 +82 -0
- package/os/rfc/handlers/list-create.ts +101 -8
- 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 +28 -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-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-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 +37 -11
- 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/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/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,28 @@ 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-1528: close review findings — manifest-union command inventory for regen/preflight</item>
|
|
24
|
+
<item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
|
|
25
|
+
<item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
|
|
26
|
+
<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>
|
|
27
|
+
<item>RFC-1532: persist integration-gate reports per attempt and link them from the flow journal</item>
|
|
28
|
+
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1537</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";
|
|
36
37
|
import { preserveTaskFiles } from "../task-files.js";
|
|
37
|
-
import { primaryWorktree } from "../worktree-path.js";
|
|
38
|
-
import {
|
|
38
|
+
import { flowWorktreePath, primaryWorktree } from "../worktree-path.js";
|
|
39
|
+
import { pruneReservationsForSession } from "../../rfc/next-id.js";
|
|
40
|
+
import { rm } from "node:fs/promises";
|
|
41
|
+
import { dirname, join } from "node:path";
|
|
39
42
|
export const INTEGRATE_LOCK_WAIT_MS = 30 * 60_000;
|
|
40
43
|
export const INTEGRATE_LOCK_STALE_MS = 2 * 3_600_000;
|
|
41
|
-
function refuse(ruleId, message, fixHint, partial) {
|
|
44
|
+
function refuse(ruleId, message, fixHint, partial, diagData) {
|
|
42
45
|
return {
|
|
43
46
|
branch: partial?.branch ?? null,
|
|
44
47
|
integrated: partial?.integrated ?? false,
|
|
@@ -47,7 +50,15 @@ function refuse(ruleId, message, fixHint, partial) {
|
|
|
47
50
|
rebased: partial?.rebased ?? false,
|
|
48
51
|
gate: partial?.gate ?? null,
|
|
49
52
|
cleanedUp: partial?.cleanedUp ?? false,
|
|
50
|
-
|
|
53
|
+
...(partial?.toleratedState !== undefined ? { toleratedState: partial.toleratedState } : {}),
|
|
54
|
+
...(partial?.toleratedDirt !== undefined ? { toleratedDirt: partial.toleratedDirt } : {}),
|
|
55
|
+
...(partial?.reattachedTo !== undefined ? { reattachedTo: partial.reattachedTo } : {}),
|
|
56
|
+
...(partial?.autoCleaned !== undefined ? { autoCleaned: partial.autoCleaned } : {}),
|
|
57
|
+
...(partial?.autocommitSha !== undefined ? { autocommitSha: partial.autocommitSha } : {}),
|
|
58
|
+
...(partial?.lock !== undefined ? { lock: partial.lock } : {}),
|
|
59
|
+
diagnostics: [
|
|
60
|
+
{ ruleId, severity: "error", message, fixHint, ...(diagData ? { data: diagData } : {}) },
|
|
61
|
+
],
|
|
51
62
|
};
|
|
52
63
|
}
|
|
53
64
|
async function resolveEntry(repoRoot, io, branch) {
|
|
@@ -56,9 +67,10 @@ async function resolveEntry(repoRoot, io, branch) {
|
|
|
56
67
|
return { common, entry: registry.branches.find((b) => b.name === branch) ?? null };
|
|
57
68
|
}
|
|
58
69
|
/** Step 6 — teardown, worktree removal, branch delete, registry, journal. */
|
|
59
|
-
async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowIso, journalEvent = "integrate", journalBase) {
|
|
70
|
+
async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowIso, journalEvent = "integrate", journalBase, journalToleratedDirt, journalAutoResolved, journalRemediation, journalGateReport) {
|
|
60
71
|
const branchExistsNow = await branchExists(primary, io, entry.name);
|
|
61
72
|
let teardownRan = null;
|
|
73
|
+
let toleratedPaths = [];
|
|
62
74
|
if (worktree !== null && (await io.exists(worktree))) {
|
|
63
75
|
// RFC-1509 Q-16: preserve BEFORE the teardown hook — a `git clean -fdx`
|
|
64
76
|
// teardown would destroy .forge/task/ with the rest of the worktree.
|
|
@@ -101,6 +113,18 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
101
113
|
],
|
|
102
114
|
};
|
|
103
115
|
}
|
|
116
|
+
// RFC-1515: `statusDirty` predicts `git worktree remove` — allowlisted
|
|
117
|
+
// forge-local state is untracked-not-ignored, so a tolerated-only tree
|
|
118
|
+
// still refuses removal. Delete the tolerated paths first (declared-
|
|
119
|
+
// disposable state; task payloads are already preserved above); a
|
|
120
|
+
// fresh check showing real entries leaves remove to report them.
|
|
121
|
+
const residual = await statusDirty(worktree, io);
|
|
122
|
+
if (residual.entries.length === 0 && residual.toleratedState.length > 0) {
|
|
123
|
+
toleratedPaths = residual.toleratedState;
|
|
124
|
+
for (const rel of residual.toleratedState) {
|
|
125
|
+
await rm(join(worktree, rel), { force: true, recursive: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
104
128
|
const remove = await git(primary, io, ["worktree", "remove", worktree]);
|
|
105
129
|
if (remove.exitCode !== 0) {
|
|
106
130
|
return {
|
|
@@ -118,7 +142,15 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
118
142
|
}
|
|
119
143
|
}
|
|
120
144
|
if (branchExistsNow) {
|
|
121
|
-
|
|
145
|
+
// RFC-1515: a vanished worktree leaves a stale `git worktree`
|
|
146
|
+
// registration that pins the branch — prune it before deletion. Merged
|
|
147
|
+
// state is already proven by isAncestor, so `-D` is the verified delete
|
|
148
|
+
// (`-d` re-derives containment in the current worktree context, which
|
|
149
|
+
// the F-0093 *.stale race corrupted).
|
|
150
|
+
if (worktree !== null && !(await io.exists(worktree))) {
|
|
151
|
+
await git(primary, io, ["worktree", "prune"]);
|
|
152
|
+
}
|
|
153
|
+
const del = await git(primary, io, ["branch", "-D", entry.name]);
|
|
122
154
|
if (del.exitCode !== 0) {
|
|
123
155
|
return {
|
|
124
156
|
cleanedUp: false,
|
|
@@ -146,6 +178,24 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
146
178
|
sha,
|
|
147
179
|
detail: journalEvent === "backmerge" ? `back-merged into develop` : `integrated into develop`,
|
|
148
180
|
base: journalBase,
|
|
181
|
+
...(toleratedPaths.length > 0 ? { toleratedState: toleratedPaths } : {}),
|
|
182
|
+
...(journalToleratedDirt !== undefined && journalToleratedDirt.length > 0
|
|
183
|
+
? { toleratedDirt: journalToleratedDirt }
|
|
184
|
+
: {}),
|
|
185
|
+
...(journalAutoResolved !== undefined && journalAutoResolved.length > 0
|
|
186
|
+
? { autoResolved: journalAutoResolved }
|
|
187
|
+
: {}),
|
|
188
|
+
...(journalRemediation?.reattachedTo !== undefined
|
|
189
|
+
? { reattachedTo: journalRemediation.reattachedTo }
|
|
190
|
+
: {}),
|
|
191
|
+
...(journalRemediation?.autoCleaned !== undefined &&
|
|
192
|
+
journalRemediation.autoCleaned.length > 0
|
|
193
|
+
? { autoCleaned: journalRemediation.autoCleaned }
|
|
194
|
+
: {}),
|
|
195
|
+
...(journalRemediation?.autocommitSha !== undefined
|
|
196
|
+
? { autocommitSha: journalRemediation.autocommitSha }
|
|
197
|
+
: {}),
|
|
198
|
+
...(journalGateReport !== undefined ? { gateReport: journalGateReport } : {}),
|
|
149
199
|
});
|
|
150
200
|
}
|
|
151
201
|
catch (error) {
|
|
@@ -170,8 +220,38 @@ async function cleanupIntegrated(primary, worktree, entry, common, sha, io, nowI
|
|
|
170
220
|
/**
|
|
171
221
|
* Core of flow.integrate — callable with an injected clock. Refusal paths
|
|
172
222
|
* return diagnostics; `integrated`/`cleanedUp` report what really happened.
|
|
223
|
+
* The exported wrapper journals every refusal (RFC-1537); this attempt body
|
|
224
|
+
* stays pure.
|
|
173
225
|
*/
|
|
174
226
|
export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
227
|
+
const data = await integrateFlowBranchAttempt(repoRoot, io, opts);
|
|
228
|
+
const error = data.diagnostics.find((d) => d.severity === "error");
|
|
229
|
+
if (error !== undefined && data.branch !== null) {
|
|
230
|
+
// Best-effort bookkeeping — a journal write failure never adds a refusal.
|
|
231
|
+
try {
|
|
232
|
+
const common = await commonGitDir(io, repoRoot);
|
|
233
|
+
const sha = (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/heads/${data.branch}`]))
|
|
234
|
+
.stdout.trim() || "unknown";
|
|
235
|
+
await appendJournal(io, common, {
|
|
236
|
+
event: "integrate-refusal",
|
|
237
|
+
branch: data.branch,
|
|
238
|
+
sha,
|
|
239
|
+
detail: error.message,
|
|
240
|
+
rule: error.ruleId,
|
|
241
|
+
...(data.toleratedState !== undefined ? { toleratedState: data.toleratedState } : {}),
|
|
242
|
+
...(data.toleratedDirt !== undefined ? { toleratedDirt: data.toleratedDirt } : {}),
|
|
243
|
+
// RFC-1532: the refused attempt's report links here too — the journal
|
|
244
|
+
// answers "which gate report belongs to this refusal" in one field.
|
|
245
|
+
...(data.gate?.reportPath ? { gateReport: data.gate.reportPath } : {}),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
/* journal is audit, not gate */
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return data;
|
|
253
|
+
}
|
|
254
|
+
async function integrateFlowBranchAttempt(repoRoot, io, opts) {
|
|
175
255
|
const now = opts.now ?? new Date();
|
|
176
256
|
const branch = opts.branch ?? (await currentBranch(repoRoot, io));
|
|
177
257
|
if (branch === null) {
|
|
@@ -189,6 +269,34 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
189
269
|
}
|
|
190
270
|
const { common, entry } = resolved;
|
|
191
271
|
if (entry === null) {
|
|
272
|
+
// RFC-1538: a second integrate after a successful one finds no entry —
|
|
273
|
+
// report "already-integrated" (exit 0) instead of FLOW-INT-06 when the
|
|
274
|
+
// journal proves the branch landed or develop already contains its tip.
|
|
275
|
+
let contained = false;
|
|
276
|
+
try {
|
|
277
|
+
const journal = await readJournal(io, common);
|
|
278
|
+
contained = journal.some((e) => e.branch === branch && (e.event === "integrate" || e.event === "backmerge"));
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
contained = false;
|
|
282
|
+
}
|
|
283
|
+
if (!contained && (await branchExists(repoRoot, io, branch))) {
|
|
284
|
+
const tip = (await git(repoRoot, io, ["rev-parse", branch])).stdout.trim();
|
|
285
|
+
contained = await isAncestor(repoRoot, io, tip, "develop");
|
|
286
|
+
}
|
|
287
|
+
if (contained) {
|
|
288
|
+
return {
|
|
289
|
+
branch,
|
|
290
|
+
integrated: true,
|
|
291
|
+
developBefore: null,
|
|
292
|
+
developAfter: null,
|
|
293
|
+
rebased: false,
|
|
294
|
+
gate: null,
|
|
295
|
+
cleanedUp: true,
|
|
296
|
+
disposition: "already-integrated",
|
|
297
|
+
diagnostics: [],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
192
300
|
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
301
|
}
|
|
194
302
|
if (entry.kind === "fix") {
|
|
@@ -203,6 +311,13 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
203
311
|
const live = await worktreeList(primary, io);
|
|
204
312
|
const wtPath = live.find((w) => w.branch === branch)?.path ?? entry.worktree;
|
|
205
313
|
if (wtPath === null || !(await io.exists(wtPath))) {
|
|
314
|
+
// RFC-1531: report the reattach target --reattach would use — nothing
|
|
315
|
+
// is created under --dry-run (AC-7).
|
|
316
|
+
const wouldReattach = opts.reattach === true
|
|
317
|
+
? entry.worktree !== null && (await io.exists(dirname(entry.worktree)))
|
|
318
|
+
? entry.worktree
|
|
319
|
+
: flowWorktreePath(primary, branch)
|
|
320
|
+
: undefined;
|
|
206
321
|
return {
|
|
207
322
|
branch,
|
|
208
323
|
integrated: false,
|
|
@@ -211,17 +326,24 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
211
326
|
rebased: false,
|
|
212
327
|
gate: null,
|
|
213
328
|
cleanedUp: false,
|
|
329
|
+
...(wouldReattach !== undefined ? { wouldReattach } : {}),
|
|
214
330
|
diagnostics: [
|
|
215
331
|
{
|
|
216
332
|
ruleId: "FLOW-07",
|
|
217
333
|
severity: "error",
|
|
218
|
-
message: `registry entry for ${branch} names worktree ${wtPath}, which does not exist
|
|
219
|
-
|
|
334
|
+
message: `registry entry for ${branch} names worktree ${wtPath}, which does not exist (vanished)` +
|
|
335
|
+
(wouldReattach !== undefined ? ` — --reattach would recreate it at ${wouldReattach}` : ""),
|
|
336
|
+
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",
|
|
337
|
+
data: { vanished: true, ...(wouldReattach !== undefined ? { wouldReattach } : {}) },
|
|
220
338
|
},
|
|
221
339
|
],
|
|
222
340
|
};
|
|
223
341
|
}
|
|
224
342
|
const dirty = await statusDirty(wtPath, io);
|
|
343
|
+
// RFC-1531: the dry-run diagnostic carries the classified dirty set so
|
|
344
|
+
// the operator reads the remedy (--auto-clean scope) without mutating.
|
|
345
|
+
const classified = classifyDirtyTree(dirty.entries);
|
|
346
|
+
const disposable = classified.filter((c) => c.class === "disposable").map((c) => c.path);
|
|
225
347
|
return {
|
|
226
348
|
branch,
|
|
227
349
|
integrated: false,
|
|
@@ -230,13 +352,24 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
230
352
|
rebased: false,
|
|
231
353
|
gate: null,
|
|
232
354
|
cleanedUp: false,
|
|
233
|
-
|
|
355
|
+
...(dirty.toleratedState.length > 0 ? { toleratedState: dirty.toleratedState } : {}),
|
|
356
|
+
diagnostics: dirty.entries.length > 0
|
|
234
357
|
? [
|
|
235
358
|
{
|
|
236
359
|
ruleId: "FLOW-INT-01",
|
|
237
360
|
severity: "error",
|
|
238
|
-
message: `worktree ${wtPath} has ${dirty.length} uncommitted change(s)
|
|
239
|
-
|
|
361
|
+
message: `worktree ${wtPath} has ${dirty.entries.length} uncommitted change(s)` +
|
|
362
|
+
(dirty.toleratedState.length > 0
|
|
363
|
+
? ` — tolerated forge-local state: ${dirty.toleratedState.join(", ")}`
|
|
364
|
+
: ""),
|
|
365
|
+
fixHint: "commit or revert the uncommitted changes inside the session worktree, or remediate with --auto-clean / --autocommit, then re-run",
|
|
366
|
+
data: {
|
|
367
|
+
entries: classified,
|
|
368
|
+
classes: summarizeClasses(classified),
|
|
369
|
+
toleratedState: dirty.toleratedState,
|
|
370
|
+
...(opts.autoClean === true ? { wouldAutoClean: disposable } : {}),
|
|
371
|
+
...(opts.autocommit === true ? { wouldAutocommit: true } : {}),
|
|
372
|
+
},
|
|
240
373
|
},
|
|
241
374
|
]
|
|
242
375
|
: [],
|
|
@@ -268,15 +401,215 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
268
401
|
diagnostics: [],
|
|
269
402
|
};
|
|
270
403
|
}
|
|
404
|
+
// RFC-1538: post-lock revalidation — the registry observed pre-lock can
|
|
405
|
+
// have changed while this run waited on the integration lock (F-0138:
|
|
406
|
+
// a racing integrate's teardown deleted entry+worktree under us).
|
|
407
|
+
const liveRegistry = await readRegistry(io, common);
|
|
408
|
+
const liveEntry = liveRegistry.branches.find((b) => b.name === branch);
|
|
409
|
+
if (liveEntry === undefined) {
|
|
410
|
+
// Registration vanished mid-wait. Contained work already landed → the
|
|
411
|
+
// winner completed; report idempotently. Otherwise mid-teardown.
|
|
412
|
+
const liveBranch = await branchExists(primary, io, branch);
|
|
413
|
+
const liveContained = liveBranch &&
|
|
414
|
+
(await isAncestor(primary, io, (await git(primary, io, ["rev-parse", branch])).stdout.trim(), "develop"));
|
|
415
|
+
if (liveContained || !liveBranch) {
|
|
416
|
+
return {
|
|
417
|
+
branch,
|
|
418
|
+
integrated: true,
|
|
419
|
+
developBefore,
|
|
420
|
+
developAfter: developBefore,
|
|
421
|
+
rebased: false,
|
|
422
|
+
gate: null,
|
|
423
|
+
cleanedUp: true,
|
|
424
|
+
disposition: "already-integrated",
|
|
425
|
+
diagnostics: [],
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
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 });
|
|
429
|
+
}
|
|
271
430
|
// (2) the branch worktree must exist and be clean.
|
|
272
431
|
const worktrees = await worktreeList(primary, io);
|
|
273
|
-
|
|
432
|
+
// `live` is the worktree git currently associates with the branch — a
|
|
433
|
+
// STALE registration keeps naming the dead recorded path until pruned,
|
|
434
|
+
// so `live !== null` does not prove the directory exists.
|
|
435
|
+
const live = worktrees.find((w) => w.branch === branch)?.path ?? null;
|
|
436
|
+
let branchWorktree = live ?? liveEntry.worktree;
|
|
437
|
+
let reattachedTo;
|
|
438
|
+
// Occupied: the recorded path exists on disk but git associates no live
|
|
439
|
+
// worktree with the branch — a foreign tree squats there.
|
|
440
|
+
const occupied = live === null && liveEntry.worktree !== null && (await io.exists(liveEntry.worktree));
|
|
441
|
+
const vanished = !occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
442
|
+
if (opts.reattach === true && occupied) {
|
|
443
|
+
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 });
|
|
444
|
+
}
|
|
445
|
+
if (opts.reattach === true && vanished) {
|
|
446
|
+
// RFC-1531 --reattach: recreate the vanished worktree inside the lock,
|
|
447
|
+
// before the dirty/preflight checks. The recorded registry path is
|
|
448
|
+
// preferred when its parent exists (operators learned that location);
|
|
449
|
+
// the canonical <repo>@<branch> sibling is the fallback.
|
|
450
|
+
const recorded = liveEntry.worktree;
|
|
451
|
+
const target = recorded !== null && (await io.exists(dirname(recorded)))
|
|
452
|
+
? recorded
|
|
453
|
+
: flowWorktreePath(primary, branch);
|
|
454
|
+
// F-0093: a vanished worktree can leave a stale `git worktree`
|
|
455
|
+
// registration that pins the branch — prune before adding (mirrors
|
|
456
|
+
// cleanupIntegrated's ordering).
|
|
457
|
+
await git(primary, io, ["worktree", "prune"]);
|
|
458
|
+
const add = await worktreeAdd(primary, io, target, branch);
|
|
459
|
+
if (add.exitCode !== 0) {
|
|
460
|
+
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 });
|
|
461
|
+
}
|
|
462
|
+
reattachedTo = target;
|
|
463
|
+
branchWorktree = target;
|
|
464
|
+
opts.onProgress?.(`reattached ${branch} at ${target}`);
|
|
465
|
+
}
|
|
274
466
|
if (branchWorktree === null || !(await io.exists(branchWorktree))) {
|
|
275
|
-
return refuse("FLOW-
|
|
467
|
+
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 });
|
|
468
|
+
}
|
|
469
|
+
let dirty = await statusDirty(branchWorktree, io);
|
|
470
|
+
if (dirty.toleratedState.length > 0) {
|
|
471
|
+
opts.onProgress?.(`tolerated forge-local state: ${dirty.toleratedState.join(", ")}`);
|
|
472
|
+
}
|
|
473
|
+
// RFC-1531 remediation flags — before the dirty checks: --auto-clean
|
|
474
|
+
// deletes ONLY disposable-class paths (closed allowlist — a work-class
|
|
475
|
+
// member in the set deletes nothing and still refuses FLOW-INT-01, and
|
|
476
|
+
// an importer-prune lockfile refuses too: restoring/committing it is a
|
|
477
|
+
// content decision, AC-4), then --autocommit sweeps the remainder into
|
|
478
|
+
// the fixed-subject commit. Remediation failures refuse FLOW-INT-17.
|
|
479
|
+
let autoCleaned;
|
|
480
|
+
let autocommitSha;
|
|
481
|
+
if (dirty.entries.length > 0 && (opts.autoClean === true || opts.autocommit === true)) {
|
|
482
|
+
const { classifyDirtyEntries } = await import("../preflight.js");
|
|
483
|
+
const classified = await classifyDirtyEntries(branchWorktree, io, dirty.entries);
|
|
484
|
+
// Pass = AUTO_CLEAN_PASS_CLASSES (tolerated family incl. the RFC-1537
|
|
485
|
+
// regenerable classes) or disposable. Blocker = work or importer-prune
|
|
486
|
+
// — AC-4 names importer-prune a refusal class: restoring/committing a
|
|
487
|
+
// lockfile is a content decision, never a cleanup step.
|
|
488
|
+
const blocker = classified.filter((c) => c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class));
|
|
489
|
+
if (opts.autoClean === true) {
|
|
490
|
+
// A blocker refuses only when nothing downstream will commit it:
|
|
491
|
+
// with --autocommit also set, work members sweep into the commit —
|
|
492
|
+
// the RFC's composed order is clean → commit → integrate.
|
|
493
|
+
if (blocker.length > 0 && opts.autocommit !== true) {
|
|
494
|
+
return refuse("FLOW-INT-01", `worktree ${branchWorktree} has ${blocker.length} uncommitted change(s) outside the disposable set: ${blocker
|
|
495
|
+
.slice(0, 10)
|
|
496
|
+
.map((b) => `${b.path} (${b.class})`)
|
|
497
|
+
.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 }, {
|
|
498
|
+
entries: classified,
|
|
499
|
+
classes: summarizeClasses(classified),
|
|
500
|
+
toleratedState: dirty.toleratedState,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
const toDelete = classified.filter((c) => c.class === "disposable");
|
|
504
|
+
autoCleaned = [];
|
|
505
|
+
for (const entry of toDelete) {
|
|
506
|
+
try {
|
|
507
|
+
await rm(join(branchWorktree, entry.path), { force: true, recursive: true });
|
|
508
|
+
autoCleaned.push(entry.path);
|
|
509
|
+
opts.onProgress?.(`auto-clean: deleted ${entry.path}`);
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
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 });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
516
|
+
}
|
|
517
|
+
if (opts.autocommit === true && dirty.entries.length > 0) {
|
|
518
|
+
// Stage exactly the remaining entry paths — never `git add -A`:
|
|
519
|
+
// tolerated FORGE_STATE paths are journaled, never committed.
|
|
520
|
+
const paths = dirty.entries.map((line) => line.slice(3).trim());
|
|
521
|
+
const add = await git(branchWorktree, io, ["add", "-A", "--", ...paths]);
|
|
522
|
+
if (add.exitCode !== 0) {
|
|
523
|
+
return refuse("FLOW-INT-17", `--autocommit staging failed: ${add.stderr.trim()}`, "inspect the session worktree state, then re-run flow.integrate", { branch, developBefore, autoCleaned });
|
|
524
|
+
}
|
|
525
|
+
const commit = await gitCommit(branchWorktree, io, [
|
|
526
|
+
"commit",
|
|
527
|
+
"-m",
|
|
528
|
+
SWEEP_COMMIT_SUBJECT,
|
|
529
|
+
], "integrate");
|
|
530
|
+
if (commit.exitCode !== 0) {
|
|
531
|
+
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 });
|
|
532
|
+
}
|
|
533
|
+
autocommitSha = (await git(branchWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
534
|
+
opts.onProgress?.(`autocommit: swept ${paths.length} path(s) into ${autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`);
|
|
535
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
536
|
+
}
|
|
276
537
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
538
|
+
// RFC-1537: declared regenerable dirt tolerated on this attempt —
|
|
539
|
+
// surfaced in data + journaled on integrate/refusal, never committed.
|
|
540
|
+
let toleratedDirt = [];
|
|
541
|
+
// RFC-1528: bounded preflight — dirty-tree checks with lockfile
|
|
542
|
+
// classification, then the four validators that used to fire only inside
|
|
543
|
+
// the expensive integration gate. Non-port path only (port entries keep
|
|
544
|
+
// their own FLOW-INT-09/10 semantics); first failure refuses before the
|
|
545
|
+
// rebase and before the gate spawns.
|
|
546
|
+
if (entry.port === null) {
|
|
547
|
+
const { runIntegratePreflight } = await import("../preflight.js");
|
|
548
|
+
const preflight = await runIntegratePreflight({
|
|
549
|
+
primary,
|
|
550
|
+
branchWorktree,
|
|
551
|
+
branch,
|
|
552
|
+
io,
|
|
553
|
+
worktreeDirty: dirty,
|
|
554
|
+
invoke: opts.invoke,
|
|
555
|
+
commandRegistry: opts.commandRegistry,
|
|
556
|
+
});
|
|
557
|
+
toleratedDirt = preflight.tolerated;
|
|
558
|
+
for (const skipped of preflight.skipped) {
|
|
559
|
+
opts.onProgress?.(skipped.reason === "no-invoke"
|
|
560
|
+
? `preflight: ${skipped.check} skipped — no invoke port (standalone CLI)`
|
|
561
|
+
: `preflight: ${skipped.check} skipped — command not in the live inventory`);
|
|
562
|
+
}
|
|
563
|
+
for (const t of preflight.tolerated) {
|
|
564
|
+
opts.onProgress?.(`tolerated regenerable state: ${t.path} (${t.class})`);
|
|
565
|
+
}
|
|
566
|
+
if (!preflight.ok && preflight.refuse) {
|
|
567
|
+
return refuse(preflight.refuse.ruleId, preflight.refuse.message, preflight.refuse.fixHint, {
|
|
568
|
+
branch,
|
|
569
|
+
developBefore,
|
|
570
|
+
toleratedState: dirty.toleratedState,
|
|
571
|
+
toleratedDirt: preflight.tolerated,
|
|
572
|
+
reattachedTo,
|
|
573
|
+
autoCleaned,
|
|
574
|
+
autocommitSha,
|
|
575
|
+
}, preflight.refuse.data);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
else if (dirty.entries.length > 0) {
|
|
579
|
+
// Port path keeps its own refusal surface but the same regenerable
|
|
580
|
+
// classes still tolerate (RFC-1537) — an importer-materializing port
|
|
581
|
+
// worktree is no harder to integrate than a session one.
|
|
582
|
+
const { classifyDirt } = await import("../preflight.js");
|
|
583
|
+
const verdict = await classifyDirt(branchWorktree, io, dirty.entries);
|
|
584
|
+
toleratedDirt = verdict.tolerated;
|
|
585
|
+
for (const t of verdict.tolerated) {
|
|
586
|
+
opts.onProgress?.(`tolerated regenerable state: ${t.path} (${t.class})`);
|
|
587
|
+
}
|
|
588
|
+
if (verdict.unattributed.length > 0) {
|
|
589
|
+
const entries = verdict.unattributed.map((line) => {
|
|
590
|
+
const path = line.slice(3).trim();
|
|
591
|
+
return { path, class: classifyDirtyPath(path) };
|
|
592
|
+
});
|
|
593
|
+
return refuse("FLOW-INT-01", `worktree ${branchWorktree} has ${verdict.unattributed.length} uncommitted change(s): ${verdict.unattributed.slice(0, 10).join(", ")}` +
|
|
594
|
+
(verdict.tolerated.length > 0
|
|
595
|
+
? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
|
|
596
|
+
: "") +
|
|
597
|
+
(dirty.toleratedState.length > 0
|
|
598
|
+
? ` — tolerated forge-local state: ${dirty.toleratedState.join(", ")}`
|
|
599
|
+
: ""), "commit or revert the uncommitted changes inside the session worktree, or remediate with --auto-clean / --autocommit, then re-run", {
|
|
600
|
+
branch,
|
|
601
|
+
developBefore,
|
|
602
|
+
toleratedState: dirty.toleratedState,
|
|
603
|
+
toleratedDirt: verdict.tolerated,
|
|
604
|
+
reattachedTo,
|
|
605
|
+
autoCleaned,
|
|
606
|
+
autocommitSha,
|
|
607
|
+
}, {
|
|
608
|
+
entries,
|
|
609
|
+
classes: summarizeClasses(entries),
|
|
610
|
+
toleratedState: dirty.toleratedState,
|
|
611
|
+
});
|
|
612
|
+
}
|
|
280
613
|
}
|
|
281
614
|
// Port entries (RFC-1490): develop must not have moved since the port
|
|
282
615
|
// opened, and the tip must be the fixed-message merge whose second
|
|
@@ -294,27 +627,94 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
294
627
|
}
|
|
295
628
|
}
|
|
296
629
|
// (3) rebase onto the current develop — never for port entries.
|
|
630
|
+
// RFC-1538: a conflict confined to generated artifacts resolves via its
|
|
631
|
+
// owner command (checkout --theirs + regenerate + continue) — the
|
|
632
|
+
// generated-file doctrine applied inside the rebase path; anything else
|
|
633
|
+
// still refuses FLOW-INT-02 for a human.
|
|
297
634
|
const rebaseBase = (await git(primary, io, ["rev-parse", "develop"])).stdout.trim();
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
635
|
+
const autoResolved = [];
|
|
636
|
+
if (entry.port === null) {
|
|
637
|
+
let rebase = await git(branchWorktree, io, ["rebase", "develop"]);
|
|
638
|
+
let guard = 0;
|
|
639
|
+
while (rebase.exitCode !== 0 && guard++ < 8) {
|
|
640
|
+
const conflicts = await git(branchWorktree, io, [
|
|
641
|
+
"diff",
|
|
642
|
+
"--name-only",
|
|
643
|
+
"--diff-filter=U",
|
|
644
|
+
]);
|
|
645
|
+
const paths = conflicts.stdout
|
|
646
|
+
.split("\n")
|
|
647
|
+
.map((l) => l.trim())
|
|
648
|
+
.filter((l) => l.length > 0);
|
|
649
|
+
const { classifyRebaseConflicts } = await import("../preflight.js");
|
|
650
|
+
const verdict = await classifyRebaseConflicts(branchWorktree, io, paths);
|
|
651
|
+
const resolvable = paths.length > 0 &&
|
|
652
|
+
verdict.nonGenerated.length === 0 &&
|
|
653
|
+
verdict.owners.length === paths.length &&
|
|
654
|
+
opts.invoke !== undefined;
|
|
655
|
+
if (!resolvable) {
|
|
656
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
657
|
+
return refuse("FLOW-INT-02", `rebase onto develop conflicts in: ${paths.join(", ") || "(unknown paths)"}` +
|
|
658
|
+
(verdict.owners.length > 0
|
|
659
|
+
? opts.invoke === undefined
|
|
660
|
+
? " — generated conflicts present but no invoke port is available to regenerate them"
|
|
661
|
+
: " — mixed generated/non-generated conflict set"
|
|
662
|
+
: ""), "resolve the rebase inside the session worktree, commit, and re-run flow.integrate", { branch, developBefore });
|
|
663
|
+
}
|
|
664
|
+
let failed = false;
|
|
665
|
+
for (const o of verdict.owners) {
|
|
666
|
+
await git(branchWorktree, io, ["checkout", "--theirs", "--", o.path]);
|
|
667
|
+
const regen = await opts.invoke(o.command, o.flags);
|
|
668
|
+
if (regen.ok === false || (regen.exitCode !== undefined && regen.exitCode !== 0)) {
|
|
669
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
670
|
+
failed = true;
|
|
671
|
+
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 });
|
|
672
|
+
}
|
|
673
|
+
await git(branchWorktree, io, ["add", "--", o.path]);
|
|
674
|
+
opts.onProgress?.(`conflict: ${o.path} — regenerated via ${o.command}`);
|
|
675
|
+
autoResolved.push(o.path);
|
|
676
|
+
}
|
|
677
|
+
if (failed)
|
|
678
|
+
break;
|
|
679
|
+
rebase = await git(branchWorktree, io, [
|
|
680
|
+
"-c",
|
|
681
|
+
"core.editor=true",
|
|
682
|
+
"rebase",
|
|
683
|
+
"--continue",
|
|
684
|
+
]);
|
|
685
|
+
}
|
|
686
|
+
if (rebase.exitCode !== 0) {
|
|
687
|
+
const conflicts = await git(branchWorktree, io, [
|
|
688
|
+
"diff",
|
|
689
|
+
"--name-only",
|
|
690
|
+
"--diff-filter=U",
|
|
691
|
+
]);
|
|
692
|
+
const paths = conflicts.stdout
|
|
693
|
+
.split("\n")
|
|
694
|
+
.map((l) => l.trim())
|
|
695
|
+
.filter((l) => l.length > 0);
|
|
696
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
697
|
+
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 });
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
// (4) integration gate — the primary's script, executed by the session
|
|
701
|
+
// engine's build when the worktree carries one (RFC-1538): the code
|
|
702
|
+
// under review judges itself; the checks it faces stay primary-owned.
|
|
703
|
+
const { resolveGateEngine } = await import("../gate-engine.js");
|
|
704
|
+
const engine = await resolveGateEngine(branchWorktree, primary, io);
|
|
705
|
+
const warnings = [];
|
|
706
|
+
if (engine.source === "primary" && (await io.exists(join(primary, "hooks", "integration-gate.sh")))) {
|
|
707
|
+
warnings.push({
|
|
708
|
+
ruleId: "FLOW-INT-16",
|
|
709
|
+
severity: "warning",
|
|
710
|
+
message: `no session engine build under ${branchWorktree} — the integration gate runs the primary engine`,
|
|
711
|
+
fixHint: "run pnpm install inside the session worktree to have its own build judged; the F-0137 self-referential escape is a backport worktree",
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
opts.onProgress?.(`gate engine: ${engine.source} (${engine.root})`);
|
|
315
715
|
const gate = await runFlowScript(io, "integration-gate", {
|
|
316
716
|
primary,
|
|
317
|
-
cwd:
|
|
717
|
+
cwd: engine.root,
|
|
318
718
|
env: {
|
|
319
719
|
FLOW_PRIMARY: primary,
|
|
320
720
|
FLOW_BRANCH: branch,
|
|
@@ -323,15 +723,40 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
323
723
|
},
|
|
324
724
|
});
|
|
325
725
|
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 }
|
|
726
|
+
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 },
|
|
727
|
+
// RFC-1532 AC-4: name the persisted report so the fixing agent reads
|
|
728
|
+
// full check rows instead of re-running the gate.
|
|
729
|
+
gate.reportPath ? { reportPath: gate.reportPath } : undefined);
|
|
327
730
|
}
|
|
328
|
-
// (5) primary must sit clean on develop, then fast-forward.
|
|
731
|
+
// (5) primary must sit clean on develop, then fast-forward. Mid-gate
|
|
732
|
+
// importer churn from another session's open mission tolerates here too
|
|
733
|
+
// (RFC-1537) — the same classifier the preflight ran.
|
|
329
734
|
const primaryBranch = await currentBranch(primary, io);
|
|
330
735
|
const primaryDirty = await statusTracked(primary, io);
|
|
331
|
-
if (primaryBranch !== "develop" || primaryDirty.length > 0) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
736
|
+
if (primaryBranch !== "develop" || primaryDirty.entries.length > 0) {
|
|
737
|
+
let unattributed = primaryDirty.entries;
|
|
738
|
+
if (primaryDirty.entries.length > 0) {
|
|
739
|
+
const { classifyDirt } = await import("../preflight.js");
|
|
740
|
+
const verdict = await classifyDirt(primary, io, primaryDirty.entries);
|
|
741
|
+
unattributed = verdict.unattributed;
|
|
742
|
+
if (verdict.tolerated.length > 0) {
|
|
743
|
+
toleratedDirt = [...toleratedDirt, ...verdict.tolerated];
|
|
744
|
+
for (const t of verdict.tolerated) {
|
|
745
|
+
opts.onProgress?.(`tolerated regenerable state on primary: ${t.path} (${t.class})`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (primaryBranch !== "develop" || unattributed.length > 0) {
|
|
750
|
+
return refuse("FLOW-INT-03", primaryBranch !== "develop"
|
|
751
|
+
? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
|
|
752
|
+
: `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", {
|
|
753
|
+
branch,
|
|
754
|
+
developBefore,
|
|
755
|
+
rebased: entry.port === null,
|
|
756
|
+
gate,
|
|
757
|
+
...(toleratedDirt.length > 0 ? { toleratedDirt } : {}),
|
|
758
|
+
});
|
|
759
|
+
}
|
|
335
760
|
}
|
|
336
761
|
const developNow = (await git(primary, io, ["rev-parse", "develop"])).stdout.trim();
|
|
337
762
|
if (!(await isAncestor(primary, io, developNow, branch))) {
|
|
@@ -350,38 +775,64 @@ export async function integrateFlowBranch(repoRoot, io, opts) {
|
|
|
350
775
|
rebased: entry.port === null,
|
|
351
776
|
gate,
|
|
352
777
|
cleanedUp: false,
|
|
353
|
-
|
|
778
|
+
...(dirty.toleratedState.length > 0 ? { toleratedState: dirty.toleratedState } : {}),
|
|
779
|
+
...(toleratedDirt.length > 0 ? { toleratedDirt } : {}),
|
|
780
|
+
...(autoResolved.length > 0 ? { autoResolved } : {}),
|
|
781
|
+
...(reattachedTo !== undefined ? { reattachedTo } : {}),
|
|
782
|
+
...(autoCleaned !== undefined && autoCleaned.length > 0 ? { autoCleaned } : {}),
|
|
783
|
+
...(autocommitSha !== undefined ? { autocommitSha } : {}),
|
|
784
|
+
gateEngine: engine.source,
|
|
785
|
+
diagnostics: warnings,
|
|
354
786
|
};
|
|
355
787
|
};
|
|
356
788
|
let inner;
|
|
357
789
|
try {
|
|
358
|
-
inner =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
790
|
+
inner =
|
|
791
|
+
opts.lockHeld === true
|
|
792
|
+
? await integrateInner()
|
|
793
|
+
: await withFlowLock(lockPath, {
|
|
794
|
+
waitMs: opts.lockWaitMs ?? INTEGRATE_LOCK_WAIT_MS,
|
|
795
|
+
staleMs: INTEGRATE_LOCK_STALE_MS,
|
|
796
|
+
progressEveryMs: 60_000,
|
|
797
|
+
onProgress: opts.onProgress,
|
|
798
|
+
onStale: (l) => opts.onProgress?.(l.reason === "dead-holder"
|
|
799
|
+
? `broke dead-holder integration lock (pid ${l.pid ?? "?"} on ${l.host ?? "?"}, held since ${l.at})`
|
|
800
|
+
: `broke stale integration lock (held since ${l.at}, ${Math.round(l.ageMs / 60000)} min old)`),
|
|
801
|
+
}, integrateInner, io);
|
|
369
802
|
}
|
|
370
803
|
catch (error) {
|
|
371
804
|
if (error instanceof LockTimeoutError) {
|
|
372
|
-
|
|
805
|
+
// RFC-1515 AC-4: a refused attempt reports the holder on the first
|
|
806
|
+
// try — the lock payload names pid/host/at/heldMs plus a disposition
|
|
807
|
+
// computed by the same dead-holder classifier withFlowLock uses.
|
|
808
|
+
const holder = error.holder;
|
|
809
|
+
const lock = holder === undefined ? undefined : describeHeldLock(holder, INTEGRATE_LOCK_STALE_MS);
|
|
810
|
+
return refuse("FLOW-INT-08", lock === undefined
|
|
811
|
+
? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
|
|
812
|
+
: `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
813
|
}
|
|
374
814
|
if (error instanceof FlowRegistrySchemaError) {
|
|
375
|
-
return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
|
|
815
|
+
return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
|
|
816
|
+
branch,
|
|
817
|
+
});
|
|
376
818
|
}
|
|
377
819
|
throw error;
|
|
378
820
|
}
|
|
379
|
-
|
|
821
|
+
// Only error-severity diagnostics are refusals — warnings (e.g. the
|
|
822
|
+
// FLOW-INT-16 primary-engine notice) must not skip cleanup and journaling.
|
|
823
|
+
if (!inner.integrated || inner.diagnostics.some((d) => d.severity === "error"))
|
|
380
824
|
return inner;
|
|
381
825
|
// (6) cleanup — outside the lock; every git call runs with -C primary.
|
|
826
|
+
// RFC-1536: prune this session's own id reservations once the branch
|
|
827
|
+
// landed — other sessions' entries stay untouched.
|
|
828
|
+
await pruneReservationsForSession(io, primary, branch);
|
|
382
829
|
const worktrees = await worktreeList(primary, io);
|
|
383
830
|
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
|
|
831
|
+
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, {
|
|
832
|
+
reattachedTo: inner.reattachedTo,
|
|
833
|
+
autoCleaned: inner.autoCleaned,
|
|
834
|
+
autocommitSha: inner.autocommitSha,
|
|
835
|
+
}, inner.gate?.reportPath ?? undefined);
|
|
385
836
|
return {
|
|
386
837
|
...inner,
|
|
387
838
|
gate: inner.gate,
|
|
@@ -403,6 +854,11 @@ export async function runFlowIntegrate(input, context) {
|
|
|
403
854
|
branch: typeof branchFlag === "string" ? branchFlag : null,
|
|
404
855
|
dryRun: context.dryRun || input.flags["dry-run"] === true,
|
|
405
856
|
onProgress: (m) => logger.info(` ${m}`),
|
|
857
|
+
invoke: context.invoke,
|
|
858
|
+
commandRegistry: context.commandRegistry,
|
|
859
|
+
reattach: input.flags["reattach"] === true,
|
|
860
|
+
autoClean: input.flags["auto-clean"] === true,
|
|
861
|
+
autocommit: input.flags["autocommit"] === true,
|
|
406
862
|
});
|
|
407
863
|
const refused = data.diagnostics.find((d) => d.severity === "error");
|
|
408
864
|
if (outputFormat === "pretty") {
|
|
@@ -415,6 +871,21 @@ export async function runFlowIntegrate(input, context) {
|
|
|
415
871
|
logger.info(` integrated: ${data.integrated}${data.rebased ? " (rebased)" : ""}`);
|
|
416
872
|
logger.info(` develop: ${data.developBefore?.slice(0, 9)} → ${data.developAfter?.slice(0, 9)}`);
|
|
417
873
|
logger.info(` cleanedUp: ${data.cleanedUp}`);
|
|
874
|
+
if (data.toleratedDirt !== undefined && data.toleratedDirt.length > 0) {
|
|
875
|
+
logger.info(` tolerated: ${data.toleratedDirt.map((t) => `${t.path} (${t.class})`).join(", ")}`);
|
|
876
|
+
}
|
|
877
|
+
if (data.toleratedState !== undefined && data.toleratedState.length > 0) {
|
|
878
|
+
logger.info(` tolerated forge state: ${data.toleratedState.join(", ")}`);
|
|
879
|
+
}
|
|
880
|
+
if (data.reattachedTo !== undefined) {
|
|
881
|
+
logger.info(` reattached: ${data.reattachedTo}`);
|
|
882
|
+
}
|
|
883
|
+
if (data.autoCleaned !== undefined && data.autoCleaned.length > 0) {
|
|
884
|
+
logger.info(` auto-cleaned: ${data.autoCleaned.join(", ")}`);
|
|
885
|
+
}
|
|
886
|
+
if (data.autocommitSha !== undefined) {
|
|
887
|
+
logger.info(` autocommit: ${data.autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`);
|
|
888
|
+
}
|
|
418
889
|
}
|
|
419
890
|
}
|
|
420
891
|
return {
|