@warpgogol/forge 9.1.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/bin/cli.ts +5 -3
- package/dist/bin/cli.js +5 -3
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
- package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/adr/handlers/implement-stamp.js +23 -15
- package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
- package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
- package/dist/os/checks/handlers/counters-journal.js +9 -1
- package/dist/os/checks/handlers/counters-journal.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +32 -39
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/lock-holder.d.ts +32 -0
- package/dist/os/core/lock-holder.d.ts.map +1 -0
- package/dist/os/core/lock-holder.js +81 -0
- package/dist/os/core/lock-holder.js.map +1 -0
- package/dist/os/core/stamp-lock.d.ts +30 -0
- package/dist/os/core/stamp-lock.d.ts.map +1 -0
- package/dist/os/core/stamp-lock.js +112 -0
- package/dist/os/core/stamp-lock.js.map +1 -0
- package/dist/os/flow/branch-name.d.ts +56 -0
- package/dist/os/flow/branch-name.d.ts.map +1 -0
- package/dist/os/flow/branch-name.js +108 -0
- package/dist/os/flow/branch-name.js.map +1 -0
- package/dist/os/flow/digest.d.ts +92 -0
- package/dist/os/flow/digest.d.ts.map +1 -0
- package/dist/os/flow/digest.js +663 -0
- package/dist/os/flow/digest.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts +3 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -0
- package/dist/os/flow/flow.module.js +771 -0
- package/dist/os/flow/flow.module.js.map +1 -0
- package/dist/os/flow/git.d.ts +68 -0
- package/dist/os/flow/git.d.ts.map +1 -0
- package/dist/os/flow/git.js +257 -0
- package/dist/os/flow/git.js.map +1 -0
- package/dist/os/flow/guard-files.d.ts +50 -0
- package/dist/os/flow/guard-files.d.ts.map +1 -0
- package/dist/os/flow/guard-files.js +147 -0
- package/dist/os/flow/guard-files.js.map +1 -0
- package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
- package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-backmerge.js +332 -0
- package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
- package/dist/os/flow/handlers/flow-check.d.ts +42 -0
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-check.js +347 -0
- package/dist/os/flow/handlers/flow-check.js.map +1 -0
- package/dist/os/flow/handlers/flow-cut.d.ts +71 -0
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-cut.js +722 -0
- package/dist/os/flow/handlers/flow-cut.js.map +1 -0
- package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-digest.js +116 -0
- package/dist/os/flow/handlers/flow-digest.js.map +1 -0
- package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
- package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-discard.js +204 -0
- package/dist/os/flow/handlers/flow-discard.js.map +1 -0
- package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
- package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-fix.js +532 -0
- package/dist/os/flow/handlers/flow-fix.js.map +1 -0
- package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
- package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-hold.js +359 -0
- package/dist/os/flow/handlers/flow-hold.js.map +1 -0
- package/dist/os/flow/handlers/flow-install.d.ts +92 -0
- package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-install.js +883 -0
- package/dist/os/flow/handlers/flow-install.js.map +1 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-integrate.js +436 -0
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
- package/dist/os/flow/handlers/flow-open.d.ts +63 -0
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-open.js +294 -0
- package/dist/os/flow/handlers/flow-open.js.map +1 -0
- package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
- package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
- package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
- package/dist/os/flow/handlers/flow-push.d.ts +29 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-push.js +397 -0
- package/dist/os/flow/handlers/flow-push.js.map +1 -0
- package/dist/os/flow/handlers/flow-status.d.ts +65 -0
- package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-status.js +193 -0
- package/dist/os/flow/handlers/flow-status.js.map +1 -0
- package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
- package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-unhold.js +158 -0
- package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
- package/dist/os/flow/handlers/flow-version.d.ts +39 -0
- package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-version.js +122 -0
- package/dist/os/flow/handlers/flow-version.js.map +1 -0
- package/dist/os/flow/index.d.ts +30 -0
- package/dist/os/flow/index.d.ts.map +1 -0
- package/dist/os/flow/index.js +83 -0
- package/dist/os/flow/index.js.map +1 -0
- package/dist/os/flow/line-version.d.ts +23 -0
- package/dist/os/flow/line-version.d.ts.map +1 -0
- package/dist/os/flow/line-version.js +83 -0
- package/dist/os/flow/line-version.js.map +1 -0
- package/dist/os/flow/locks.d.ts +39 -0
- package/dist/os/flow/locks.d.ts.map +1 -0
- package/dist/os/flow/locks.js +177 -0
- package/dist/os/flow/locks.js.map +1 -0
- package/dist/os/flow/markers.d.ts +49 -0
- package/dist/os/flow/markers.d.ts.map +1 -0
- package/dist/os/flow/markers.js +112 -0
- package/dist/os/flow/markers.js.map +1 -0
- package/dist/os/flow/publication-order.d.ts +25 -0
- package/dist/os/flow/publication-order.d.ts.map +1 -0
- package/dist/os/flow/publication-order.js +75 -0
- package/dist/os/flow/publication-order.js.map +1 -0
- package/dist/os/flow/publish.d.ts +46 -0
- package/dist/os/flow/publish.d.ts.map +1 -0
- package/dist/os/flow/publish.js +209 -0
- package/dist/os/flow/publish.js.map +1 -0
- package/dist/os/flow/registry.d.ts +142 -0
- package/dist/os/flow/registry.d.ts.map +1 -0
- package/dist/os/flow/registry.js +199 -0
- package/dist/os/flow/registry.js.map +1 -0
- package/dist/os/flow/release-level.d.ts +23 -0
- package/dist/os/flow/release-level.d.ts.map +1 -0
- package/dist/os/flow/release-level.js +102 -0
- package/dist/os/flow/release-level.js.map +1 -0
- package/dist/os/flow/release-lines.d.ts +25 -0
- package/dist/os/flow/release-lines.d.ts.map +1 -0
- package/dist/os/flow/release-lines.js +172 -0
- package/dist/os/flow/release-lines.js.map +1 -0
- package/dist/os/flow/release-tags.d.ts +73 -0
- package/dist/os/flow/release-tags.d.ts.map +1 -0
- package/dist/os/flow/release-tags.js +167 -0
- package/dist/os/flow/release-tags.js.map +1 -0
- package/dist/os/flow/repo-kind.d.ts +41 -0
- package/dist/os/flow/repo-kind.d.ts.map +1 -0
- package/dist/os/flow/repo-kind.js +92 -0
- package/dist/os/flow/repo-kind.js.map +1 -0
- package/dist/os/flow/scripts.d.ts +20 -0
- package/dist/os/flow/scripts.d.ts.map +1 -0
- package/dist/os/flow/scripts.js +50 -0
- package/dist/os/flow/scripts.js.map +1 -0
- package/dist/os/flow/semver.d.ts +21 -0
- package/dist/os/flow/semver.d.ts.map +1 -0
- package/dist/os/flow/semver.js +73 -0
- package/dist/os/flow/semver.js.map +1 -0
- package/dist/os/flow/task-files.d.ts +11 -0
- package/dist/os/flow/task-files.d.ts.map +1 -0
- package/dist/os/flow/task-files.js +51 -0
- package/dist/os/flow/task-files.js.map +1 -0
- package/dist/os/flow/tests/helpers.d.ts +55 -0
- package/dist/os/flow/tests/helpers.d.ts.map +1 -0
- package/dist/os/flow/tests/helpers.js +193 -0
- package/dist/os/flow/tests/helpers.js.map +1 -0
- package/dist/os/flow/version-files.d.ts +21 -0
- package/dist/os/flow/version-files.d.ts.map +1 -0
- package/dist/os/flow/version-files.js +94 -0
- package/dist/os/flow/version-files.js.map +1 -0
- package/dist/os/flow/worktree-path.d.ts +31 -0
- package/dist/os/flow/worktree-path.d.ts.map +1 -0
- package/dist/os/flow/worktree-path.js +80 -0
- package/dist/os/flow/worktree-path.js.map +1 -0
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +44 -51
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/lockfile.d.ts +21 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -0
- package/dist/os/mission/lockfile.js +76 -0
- package/dist/os/mission/lockfile.js.map +1 -0
- package/dist/os/mission/mission.module.d.ts.map +1 -1
- package/dist/os/mission/mission.module.js +2 -1
- package/dist/os/mission/mission.module.js.map +1 -1
- package/dist/os/program/handlers/seal.d.ts.map +1 -1
- package/dist/os/program/handlers/seal.js +1 -1
- package/dist/os/program/handlers/seal.js.map +1 -1
- package/dist/os/program/handlers/validate.d.ts.map +1 -1
- package/dist/os/program/handlers/validate.js +1 -1
- package/dist/os/program/handlers/validate.js.map +1 -1
- package/dist/os/program/program.module.d.ts.map +1 -1
- package/dist/os/program/program.module.js +2 -1
- package/dist/os/program/program.module.js.map +1 -1
- package/dist/os/program/schemas.d.ts +4 -6
- package/dist/os/program/schemas.d.ts.map +1 -1
- package/dist/os/program/schemas.js +16 -6
- package/dist/os/program/schemas.js.map +1 -1
- package/dist/os/program/state.d.ts +0 -1
- package/dist/os/program/state.d.ts.map +1 -1
- package/dist/os/program/state.js +1 -7
- package/dist/os/program/state.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts +21 -0
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +62 -13
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/frontmatter-io.d.ts +19 -0
- package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
- package/dist/os/rfc/frontmatter-io.js +65 -12
- package/dist/os/rfc/frontmatter-io.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +24 -19
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +10 -8
- 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 +15 -5
- package/dist/os/rfc/handlers/validate.js.map +1 -1
- package/dist/os/rfc/index.d.ts +2 -2
- package/dist/os/rfc/index.d.ts.map +1 -1
- package/dist/os/rfc/index.js +5 -2
- package/dist/os/rfc/index.js.map +1 -1
- package/dist/os/rfc/probe-batch.d.ts +71 -0
- package/dist/os/rfc/probe-batch.d.ts.map +1 -0
- package/dist/os/rfc/probe-batch.js +251 -0
- package/dist/os/rfc/probe-batch.js.map +1 -0
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +16 -2
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +21 -10
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
- package/dist/os/rfc/verification-refresh.js +20 -13
- package/dist/os/rfc/verification-refresh.js.map +1 -1
- package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
- package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
- package/dist/os/system/handlers/outbox-validate.js +102 -0
- package/dist/os/system/handlers/outbox-validate.js.map +1 -0
- package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
- package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
- package/dist/os/system/handlers/system-map-validate.js +78 -0
- package/dist/os/system/handlers/system-map-validate.js.map +1 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
- package/dist/os/system/handlers/system-outbox-scan.js +195 -0
- package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
- package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-collect.js +238 -0
- package/dist/os/system/handlers/system-task-collect.js.map +1 -0
- package/dist/os/system/handlers/system-task-create.d.ts +32 -0
- package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-create.js +216 -0
- package/dist/os/system/handlers/system-task-create.js.map +1 -0
- package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
- package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-dispatch.js +290 -0
- package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
- package/dist/os/system/handlers/system-task-move.d.ts +12 -0
- package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-move.js +217 -0
- package/dist/os/system/handlers/system-task-move.js.map +1 -0
- package/dist/os/system/handlers/system-task-status.d.ts +20 -0
- package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-status.js +139 -0
- package/dist/os/system/handlers/system-task-status.js.map +1 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
- package/dist/os/system/handlers/system-versionset-record.js +332 -0
- package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
- package/dist/os/system/index.d.ts +6 -0
- package/dist/os/system/index.d.ts.map +1 -0
- package/dist/os/system/index.js +18 -0
- package/dist/os/system/index.js.map +1 -0
- package/dist/os/system/outbox-schema.d.ts +30 -0
- package/dist/os/system/outbox-schema.d.ts.map +1 -0
- package/dist/os/system/outbox-schema.js +29 -0
- package/dist/os/system/outbox-schema.js.map +1 -0
- package/dist/os/system/repo.d.ts +64 -0
- package/dist/os/system/repo.d.ts.map +1 -0
- package/dist/os/system/repo.js +364 -0
- package/dist/os/system/repo.js.map +1 -0
- package/dist/os/system/scenario-schemas.d.ts +26 -0
- package/dist/os/system/scenario-schemas.d.ts.map +1 -0
- package/dist/os/system/scenario-schemas.js +53 -0
- package/dist/os/system/scenario-schemas.js.map +1 -0
- package/dist/os/system/schemas.d.ts +63 -0
- package/dist/os/system/schemas.d.ts.map +1 -0
- package/dist/os/system/schemas.js +83 -0
- package/dist/os/system/schemas.js.map +1 -0
- package/dist/os/system/system.module.d.ts +3 -0
- package/dist/os/system/system.module.d.ts.map +1 -0
- package/dist/os/system/system.module.js +429 -0
- package/dist/os/system/system.module.js.map +1 -0
- package/dist/os/system/task-schemas.d.ts +108 -0
- package/dist/os/system/task-schemas.d.ts.map +1 -0
- package/dist/os/system/task-schemas.js +152 -0
- package/dist/os/system/task-schemas.js.map +1 -0
- package/dist/os/system/task-store.d.ts +41 -0
- package/dist/os/system/task-store.d.ts.map +1 -0
- package/dist/os/system/task-store.js +142 -0
- package/dist/os/system/task-store.js.map +1 -0
- package/dist/os/system/tests/helpers.d.ts +30 -0
- package/dist/os/system/tests/helpers.d.ts.map +1 -0
- package/dist/os/system/tests/helpers.js +178 -0
- package/dist/os/system/tests/helpers.js.map +1 -0
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
- package/dist/os/werkstatt/werkstatt.module.js +2 -82
- package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +0 -3
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +2 -4
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +49 -4
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/create.d.ts +13 -0
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +95 -9
- package/dist/src/onboarding/create.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +2 -47
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts +5 -0
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +70 -1
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -2
- package/docs/branch-model.md +98 -0
- package/docs/maintainers/publishing.md +10 -8
- package/docs/reference/cli.md +0 -3
- package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
- package/os/adr/handlers/implement-stamp.ts +29 -20
- package/os/checks/handlers/counters-journal.test.ts +10 -0
- package/os/checks/handlers/counters-journal.ts +8 -1
- package/os/core/core.module.ts +38 -39
- package/os/core/lock-holder.ts +88 -0
- package/os/core/stamp-lock.ts +142 -0
- package/os/flow/assets/flow-guard.sh +176 -0
- package/os/flow/branch-name.ts +139 -0
- package/os/flow/digest.ts +803 -0
- package/os/flow/flow.module.ts +796 -0
- package/os/flow/git.ts +342 -0
- package/os/flow/guard-files.ts +172 -0
- package/os/flow/handlers/flow-backmerge.ts +488 -0
- package/os/flow/handlers/flow-check.ts +450 -0
- package/os/flow/handlers/flow-cut.ts +1025 -0
- package/os/flow/handlers/flow-digest.ts +130 -0
- package/os/flow/handlers/flow-discard.ts +310 -0
- package/os/flow/handlers/flow-fix.ts +703 -0
- package/os/flow/handlers/flow-hold.ts +500 -0
- package/os/flow/handlers/flow-install.ts +1185 -0
- package/os/flow/handlers/flow-integrate.ts +623 -0
- package/os/flow/handlers/flow-open.ts +447 -0
- package/os/flow/handlers/flow-publication-retire.ts +156 -0
- package/os/flow/handlers/flow-push.ts +488 -0
- package/os/flow/handlers/flow-status.ts +283 -0
- package/os/flow/handlers/flow-unhold.ts +220 -0
- package/os/flow/handlers/flow-version.ts +196 -0
- package/os/flow/index.ts +102 -0
- package/os/flow/line-version.ts +113 -0
- package/os/flow/locks.ts +227 -0
- package/os/flow/markers.ts +135 -0
- package/os/flow/publication-order.ts +99 -0
- package/os/flow/publish.ts +272 -0
- package/os/flow/registry.ts +269 -0
- package/os/flow/release-level.ts +139 -0
- package/os/flow/release-lines.ts +208 -0
- package/os/flow/release-tags.ts +232 -0
- package/os/flow/repo-kind.ts +117 -0
- package/os/flow/scripts.ts +75 -0
- package/os/flow/semver.ts +82 -0
- package/os/flow/task-files.ts +59 -0
- package/os/flow/tests/branch-name.test.ts +136 -0
- package/os/flow/tests/fixtures/branch-names.yaml +56 -0
- package/os/flow/tests/flow-backmerge.test.ts +267 -0
- package/os/flow/tests/flow-check-version.test.ts +138 -0
- package/os/flow/tests/flow-check.test.ts +213 -0
- package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
- package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
- package/os/flow/tests/flow-cut.test.ts +323 -0
- package/os/flow/tests/flow-digest.test.ts +313 -0
- package/os/flow/tests/flow-discard.test.ts +220 -0
- package/os/flow/tests/flow-fix.test.ts +359 -0
- package/os/flow/tests/flow-guard-merge.test.ts +100 -0
- package/os/flow/tests/flow-guard-parity.test.ts +115 -0
- package/os/flow/tests/flow-guard-push.test.ts +100 -0
- package/os/flow/tests/flow-guard.test.ts +135 -0
- package/os/flow/tests/flow-hold.test.ts +465 -0
- package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
- package/os/flow/tests/flow-install-baseline.test.ts +164 -0
- package/os/flow/tests/flow-install-markers.test.ts +161 -0
- package/os/flow/tests/flow-install.rerun.test.ts +212 -0
- package/os/flow/tests/flow-install.test.ts +330 -0
- package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
- package/os/flow/tests/flow-integrate.test.ts +229 -0
- package/os/flow/tests/flow-open.test.ts +200 -0
- package/os/flow/tests/flow-publication-retire.test.ts +191 -0
- package/os/flow/tests/flow-push-publish.test.ts +282 -0
- package/os/flow/tests/flow-push-supersede.test.ts +221 -0
- package/os/flow/tests/flow-push.test.ts +160 -0
- package/os/flow/tests/flow-stale.test.ts +136 -0
- package/os/flow/tests/flow-status.test.ts +93 -0
- package/os/flow/tests/flow-task-files.test.ts +59 -0
- package/os/flow/tests/flow-version-level.test.ts +116 -0
- package/os/flow/tests/flow-version.test.ts +169 -0
- package/os/flow/tests/helpers.ts +239 -0
- package/os/flow/tests/is-flow-adopted.test.ts +71 -0
- package/os/flow/tests/locks.test.ts +219 -0
- package/os/flow/tests/publication-order.test.ts +102 -0
- package/os/flow/tests/registry.test.ts +150 -0
- package/os/flow/tests/repository-line-version.test.ts +100 -0
- package/os/flow/tests/scripts.test.ts +97 -0
- package/os/flow/tests/state-roots.test.ts +127 -0
- package/os/flow/tests/version-files.test.ts +145 -0
- package/os/flow/version-files.ts +115 -0
- package/os/flow/worktree-path.ts +107 -0
- package/os/mission/handlers/archive.test.ts +108 -36
- package/os/mission/handlers/archive.ts +46 -51
- package/os/mission/lockfile.ts +84 -0
- package/os/mission/mission.module.ts +2 -1
- package/os/program/handlers/seal.ts +1 -1
- package/os/program/handlers/validate.ts +1 -1
- package/os/program/program.module.ts +2 -1
- package/os/program/schemas.ts +51 -34
- package/os/program/state.ts +1 -9
- package/os/rfc/acceptance.ts +84 -19
- package/os/rfc/frontmatter-io.ts +78 -12
- package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
- package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
- package/os/rfc/handlers/implement-stamp.ts +30 -24
- package/os/rfc/handlers/validate-rules.test.ts +9 -6
- package/os/rfc/handlers/validate-rules.ts +12 -10
- package/os/rfc/handlers/validate.ts +17 -5
- package/os/rfc/index.ts +13 -1
- package/os/rfc/probe-batch.ts +329 -0
- package/os/rfc/rfc.module.ts +19 -2
- package/os/rfc/verification-emit-check.test.ts +22 -0
- package/os/rfc/verification-emit-freshness.test.ts +22 -0
- package/os/rfc/verification-emit.test.ts +22 -0
- package/os/rfc/verification-evidence.ts +21 -16
- package/os/rfc/verification-refresh.test.ts +22 -0
- package/os/rfc/verification-refresh.ts +20 -18
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
- package/os/system/handlers/outbox-validate.ts +120 -0
- package/os/system/handlers/system-map-validate.ts +107 -0
- package/os/system/handlers/system-outbox-scan.ts +320 -0
- package/os/system/handlers/system-task-collect.ts +305 -0
- package/os/system/handlers/system-task-create.ts +271 -0
- package/os/system/handlers/system-task-dispatch.ts +387 -0
- package/os/system/handlers/system-task-move.ts +353 -0
- package/os/system/handlers/system-task-status.ts +176 -0
- package/os/system/handlers/system-versionset-record.ts +476 -0
- package/os/system/index.ts +47 -0
- package/os/system/outbox-schema.ts +47 -0
- package/os/system/repo.ts +451 -0
- package/os/system/scenario-schemas.ts +62 -0
- package/os/system/schemas.ts +102 -0
- package/os/system/system.module.ts +449 -0
- package/os/system/task-schemas.ts +190 -0
- package/os/system/task-store.ts +184 -0
- package/os/system/tests/helpers.ts +189 -0
- package/os/system/tests/outbox-validate.test.ts +92 -0
- package/os/system/tests/system-map-validate.test.ts +321 -0
- package/os/system/tests/system-outbox-scan.test.ts +273 -0
- package/os/system/tests/system-profile.test.ts +90 -0
- package/os/system/tests/system-task-collect.test.ts +293 -0
- package/os/system/tests/system-task-dispatch.test.ts +279 -0
- package/os/system/tests/system-task-status.test.ts +153 -0
- package/os/system/tests/system-task.test.ts +330 -0
- package/os/system/tests/system-versionset.test.ts +314 -0
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
- package/os/werkstatt/werkstatt.module.ts +2 -85
- package/package.json +49 -1
- package/profiles/forge-shell.yaml +22 -10
- package/profiles/godot-game.yaml +24 -13
- package/profiles/knowledge.yaml +19 -0
- package/profiles/phaser-game.yaml +25 -13
- package/profiles/site-workshop.yaml +27 -10
- package/profiles/system.yaml +650 -0
- package/profiles/typescript.yaml +26 -9
- package/skills/fo/fo-outbox/SKILL.md +71 -0
- package/skills/fo/fo-session-retro/SKILL.md +18 -7
- package/skills/fo/fo-step-commit/SKILL.md +2 -1
- package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
- package/skills/fo/fo-task-run/SKILL.md +75 -0
- package/src/config/forge-config.ts +2 -6
- package/src/index.ts +19 -4
- package/src/onboarding/agents-generate.ts +49 -5
- package/src/onboarding/create.ts +101 -9
- package/src/onboarding/doctor.ts +2 -51
- package/src/onboarding/upgrade.ts +86 -1
- package/src/tests/agents-generate-flow.test.ts +132 -0
- package/src/tests/create-flow.test.ts +114 -0
- package/src/tests/create.test.ts +22 -21
- package/src/tests/doctor-autonomy.test.ts +2 -1
- package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
- package/src/tests/implement-stamp.test.ts +26 -3
- package/src/tests/profile-flow-hooks.test.ts +77 -0
- package/src/tests/profile-schema.test.ts +2 -1
- package/src/tests/program-schemas.test.ts +66 -6
- package/src/tests/program-spec-node.test.ts +1 -5
- package/src/tests/rfc-evidence-sync.test.ts +22 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
- package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
- package/src/tests/upgrade-flow.test.ts +174 -0
- package/src/types.ts +11 -2
- package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
- package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-close.js +0 -56
- package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
- package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-engine.js +0 -28
- package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
- package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-open.js +0 -46
- package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
- package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-status.js +0 -34
- package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
- package/os/werkstatt/handlers/session-close.ts +0 -82
- package/os/werkstatt/handlers/session-engine.ts +0 -34
- package/os/werkstatt/handlers/session-open.ts +0 -68
- package/os/werkstatt/handlers/session-status.ts +0 -55
|
@@ -13,13 +13,18 @@ and atomically mutates ADR frontmatter.
|
|
|
13
13
|
</MODULE_CONTRACT>
|
|
14
14
|
<CHANGE_SUMMARY>
|
|
15
15
|
<item>RFC-0727: initial implementation — mirrors rfc.implement.stamp for ADRs.</item>
|
|
16
|
+
<item>RFC-1504: step 4 — shared stamp lock for rfc and adr stamp handlers</item>
|
|
17
|
+
<item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
|
|
16
18
|
</CHANGE_SUMMARY>
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
import { execFile
|
|
21
|
+
import { execFile } from "../../../src/utils/sync-fs.ts";
|
|
20
22
|
import { ambientIo, resolveIo } from "../../../src/utils/io.ts";
|
|
21
23
|
|
|
22
|
-
import { join
|
|
24
|
+
import { join } from "node:path";
|
|
25
|
+
|
|
26
|
+
import { acquireStampLock } from "../../core/stamp-lock.ts";
|
|
27
|
+
import type { StampLockHeld, StampLockOptions } from "../../core/stamp-lock.ts";
|
|
23
28
|
|
|
24
29
|
import { writeFileAtomic } from "../../../src/utils/fs-atomic.ts";
|
|
25
30
|
|
|
@@ -96,28 +101,27 @@ function lockFilePath(workspaceRoot: string, adrId: string): string {
|
|
|
96
101
|
return join(workspaceRoot, ".adr-locks", `${slug}.lock`);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
|
|
104
|
+
// RFC-1504: shared dead-holder recovery — a lock recording this host and a
|
|
105
|
+
// dead pid (or a foreign boot id) is broken and retried; a live pid still
|
|
106
|
+
// returns acquired:false → ADR-IMP-05. Exported for the lock tests.
|
|
107
|
+
export async function acquireAdrLock(
|
|
100
108
|
workspaceRoot: string,
|
|
101
109
|
adrId: string,
|
|
102
|
-
|
|
110
|
+
opts: StampLockOptions = {},
|
|
111
|
+
): Promise<{ acquired: boolean; lockPath: string; held?: StampLockHeld }> {
|
|
103
112
|
const lockPath = lockFilePath(workspaceRoot, adrId);
|
|
104
|
-
|
|
105
|
-
await io.mkdir(lockDir);
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
writeFileSync(
|
|
109
|
-
lockPath,
|
|
110
|
-
JSON.stringify({ pid: process.pid, acquiredAt: new Date().toISOString() }),
|
|
111
|
-
{ flag: "wx" },
|
|
112
|
-
);
|
|
113
|
-
return { acquired: true, lockPath };
|
|
114
|
-
} catch {
|
|
115
|
-
return { acquired: false, lockPath };
|
|
116
|
-
}
|
|
113
|
+
return acquireStampLock(lockPath, opts);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
|
|
116
|
+
// RFC-1504: release only the lock we hold — after a dead/stale break a
|
|
117
|
+
// contender may have written a fresh payload, and unlinking it would break
|
|
118
|
+
// mutual exclusion entirely. Mirrors withFlowLock's ownership check.
|
|
119
|
+
async function releaseAdrLock(lockPath: string, held?: StampLockHeld): Promise<void> {
|
|
120
120
|
try {
|
|
121
|
+
if (held !== undefined) {
|
|
122
|
+
const parsed = JSON.parse(await io.readFile(lockPath)) as { pid?: number; at?: string };
|
|
123
|
+
if (parsed.pid !== held.pid || parsed.at !== held.at) return;
|
|
124
|
+
}
|
|
121
125
|
await io.rm(lockPath);
|
|
122
126
|
} catch {
|
|
123
127
|
// Lock file already removed — safe
|
|
@@ -270,7 +274,12 @@ export async function runAdrImplementStamp(
|
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
// ── ADR-IMP-05: acquire ADR-specific exclusive lock ───────────────────────
|
|
273
|
-
const { acquired, lockPath } = await acquireAdrLock(workspaceRoot, targetId
|
|
277
|
+
const { acquired, lockPath, held } = await acquireAdrLock(workspaceRoot, targetId, {
|
|
278
|
+
onStale: (info) =>
|
|
279
|
+
logger.warn(
|
|
280
|
+
`broke ${info.reason} stamp lock ${info.path} (pid ${info.pid ?? "?"} on ${info.host ?? "?"})`,
|
|
281
|
+
),
|
|
282
|
+
});
|
|
274
283
|
if (!acquired) {
|
|
275
284
|
violations.push({
|
|
276
285
|
rule: "ADR-IMP-05",
|
|
@@ -347,7 +356,7 @@ export async function runAdrImplementStamp(
|
|
|
347
356
|
],
|
|
348
357
|
};
|
|
349
358
|
} finally {
|
|
350
|
-
await releaseAdrLock(lockPath);
|
|
359
|
+
await releaseAdrLock(lockPath, held);
|
|
351
360
|
}
|
|
352
361
|
}
|
|
353
362
|
|
|
@@ -15,6 +15,7 @@ truncated-tail tolerance).</purpose>
|
|
|
15
15
|
|
|
16
16
|
import { test, expect, describe, beforeEach, afterEach } from "vitest";
|
|
17
17
|
import { mkdtemp, rm, mkdir, writeFile, readFile, appendFile } from "node:fs/promises";
|
|
18
|
+
import { existsSync } from "node:fs";
|
|
18
19
|
import { join } from "node:path";
|
|
19
20
|
import { tmpdir } from "node:os";
|
|
20
21
|
import {
|
|
@@ -71,6 +72,15 @@ describe("recordRuleEvaluations", () => {
|
|
|
71
72
|
expect(records).toHaveLength(0);
|
|
72
73
|
});
|
|
73
74
|
|
|
75
|
+
test("a workspace root that no longer exists is not recreated (W5-16)", async () => {
|
|
76
|
+
// flow.integrate removes the session worktree before the executor journals
|
|
77
|
+
// its counters; the journal must not resurrect the worktree directory.
|
|
78
|
+
const gone = join(root, "removed-worktree");
|
|
79
|
+
const warning = await recordRuleEvaluations(gone, [rec()]);
|
|
80
|
+
expect(existsSync(gone)).toBe(false);
|
|
81
|
+
expect(warning).toContain("no longer exists");
|
|
82
|
+
});
|
|
83
|
+
|
|
74
84
|
test("AC-11: append failure returns a warning, never throws", async () => {
|
|
75
85
|
// Make the journal's parent path a regular file — mkdir/append must fail.
|
|
76
86
|
await mkdir(join(root, "docs", ".index"), { recursive: true });
|
|
@@ -29,7 +29,7 @@ Append-only counters.jsonl journaled per evaluated rule ({runId, ruleId, contrac
|
|
|
29
29
|
</CHANGE_SUMMARY>
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
import { appendFile, mkdir, readFile } from "node:fs/promises";
|
|
32
|
+
import { appendFile, mkdir, readFile, stat } from "node:fs/promises";
|
|
33
33
|
import { dirname, join } from "node:path";
|
|
34
34
|
import { z } from "zod";
|
|
35
35
|
|
|
@@ -65,6 +65,13 @@ export async function recordRuleEvaluations(
|
|
|
65
65
|
): Promise<string | undefined> {
|
|
66
66
|
if (records.length === 0) return undefined;
|
|
67
67
|
const file = join(workspaceRoot, COUNTERS_JOURNAL_PATH);
|
|
68
|
+
// A command can remove its own workspace root (flow.integrate tears down the
|
|
69
|
+
// session worktree); mkdir -p below would recreate it as an orphan directory.
|
|
70
|
+
try {
|
|
71
|
+
await stat(workspaceRoot);
|
|
72
|
+
} catch {
|
|
73
|
+
return `counters journal skipped: workspace root ${workspaceRoot} no longer exists`;
|
|
74
|
+
}
|
|
68
75
|
try {
|
|
69
76
|
await mkdir(dirname(file), { recursive: true });
|
|
70
77
|
await appendFile(file, records.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
package/os/core/core.module.ts
CHANGED
|
@@ -6,20 +6,12 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-1351: step 4 — drop stale coverage declarations (COVERAGE-02)
|
|
10
|
-
|
|
11
|
-
Remove coverage/coverageNote from 9 mechanically reachable commands: compass.header.scaffold, forge.agents.generate, journal.binding.validate, leitstand.state.reconcile, leitstand.verify, mission.deploy-preflight, onboarding.intake.validate, test.repro.verify, contract.ripple.apply (last — RFC-1349 acceptance stays green via its AGENTS.md doc edge). Manifest regenerated: 0 warnings.</item>
|
|
12
|
-
<item>RFC-1354: step 4 — CMD-MAN-02 sweep: writes/generates on mutating commands, mutatesState:false on read-only and port/in-memory commands, execOnReadOnly on subprocess commands (0 CMD-MAN-02; 42 ENV-INPUT-02 excluded per Q-1)</item>
|
|
13
|
-
<item>RFC-1360: step 2 — env-input declaration sweep (59 commands)
|
|
14
|
-
|
|
15
|
-
Declare every reachable env read on its owning command across engine/site/
|
|
16
|
-
forge (fresh full-registry replay worklist: 151 ENV-INPUT-01, 60 commands).
|
|
17
|
-
ForgeCommandMetadata gains the mirrored envInputs contract field. The
|
|
18
|
-
npm_execpath ambient read in open-source-page.ts is removed for a
|
|
19
|
-
deterministic PATH spawn (DNA-105) — undeclarable name class, ledger Q-9.</item>
|
|
20
|
-
<item>RFC-1366: kernel resolves mission workpieceEnv + KERNEL-ENV-01 gate on required envInputs</item>
|
|
21
9
|
<item>RFC-1461: declare rules[] severity via CommandRuleDecl workspace-wide (RFC-1461)</item>
|
|
22
|
-
<
|
|
10
|
+
<item>RFC-1500: step 2 — forge.create adopts the fixed branch model</item>
|
|
11
|
+
<item>RFC-1505: review r1 — durable projections and lockfile restore hardening</item>
|
|
12
|
+
<item>RFC-1505: review r2 — clone-only sternsystem enumeration and mission-gated lockfile net</item>
|
|
13
|
+
<item>RFC-1508: implement RFC-1508 — system profile, system map schemas and system.map.validate</item>
|
|
14
|
+
<history>ADR-0021, RFC-0374, RFC-0521, RFC-0539, RFC-0542, RFC-0543, RFC-0544, RFC-0546, RFC-0640, RFC-0662, RFC-0674, RFC-0678, RFC-0679, RFC-0680, RFC-0711, RFC-0733, RFC-0877, RFC-0940, RFC-1080, RFC-1088, RFC-1089, RFC-1097, RFC-1173, RFC-1230, RFC-1231, RFC-1235, RFC-1248, RFC-1251, RFC-1254, RFC-1255, RFC-1351, RFC-1354, RFC-1360, RFC-1366</history>
|
|
23
15
|
</CHANGE_SUMMARY>
|
|
24
16
|
*/
|
|
25
17
|
|
|
@@ -31,7 +23,11 @@ import type {
|
|
|
31
23
|
ForgeRuntimeContext,
|
|
32
24
|
} from "../../src/types.ts";
|
|
33
25
|
import path from "node:path";
|
|
34
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
restoreTrackedLockfile,
|
|
28
|
+
execFileSyncAdapter,
|
|
29
|
+
} from "../mission/lockfile.ts";
|
|
30
|
+
import { writeFileIfChanged } from "../../src/utils/fs-idempotent.ts";
|
|
35
31
|
import {
|
|
36
32
|
FORGE_SKILLS,
|
|
37
33
|
discoverPackSkills,
|
|
@@ -423,7 +419,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
423
419
|
kind: "string",
|
|
424
420
|
required: true,
|
|
425
421
|
description:
|
|
426
|
-
"Stack profile id. Required. Available: forge-shell, phaser-game, godot-game, knowledge, typescript.",
|
|
422
|
+
"Stack profile id. Required. Available: forge-shell, phaser-game, godot-game, knowledge, system, typescript.",
|
|
427
423
|
},
|
|
428
424
|
name: {
|
|
429
425
|
kind: "string",
|
|
@@ -443,6 +439,11 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
443
439
|
description:
|
|
444
440
|
"After create, run compass.docs.scaffold to materialize the Compass corpus (RFC-1253).",
|
|
445
441
|
},
|
|
442
|
+
"no-flow": {
|
|
443
|
+
kind: "boolean",
|
|
444
|
+
description:
|
|
445
|
+
"Skip the scaffold commit and flow.install adoption — the repository is created unadopted (RFC-1500).",
|
|
446
|
+
},
|
|
446
447
|
},
|
|
447
448
|
cacheable: false,
|
|
448
449
|
execute: async (input, context) =>
|
|
@@ -929,6 +930,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
929
930
|
"missions/*",
|
|
930
931
|
"missions/archive/**",
|
|
931
932
|
"docs/specs/live/*.md",
|
|
933
|
+
"pnpm-lock.yaml",
|
|
932
934
|
],
|
|
933
935
|
generates: [],
|
|
934
936
|
reads: [
|
|
@@ -1107,35 +1109,32 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
1107
1109
|
}
|
|
1108
1110
|
}
|
|
1109
1111
|
|
|
1110
|
-
//
|
|
1111
|
-
//
|
|
1112
|
-
//
|
|
1113
|
-
//
|
|
1114
|
-
|
|
1112
|
+
// RFC-1505: post-loop lockfile restore — safety net for mission.archive's
|
|
1113
|
+
// own restore. Only mission moves run `pnpm install` and can churn the
|
|
1114
|
+
// lockfile; gating on them alone means an rfc/adr/plan-only archive run
|
|
1115
|
+
// never touches a locally edited pnpm-lock.yaml. Restore HEAD bytes
|
|
1116
|
+
// instead of staging — mission churn is never committed.
|
|
1117
|
+
const missionData = results["mission.archive"] as
|
|
1118
|
+
| { moved?: unknown[] }
|
|
1119
|
+
| undefined;
|
|
1120
|
+
const missionMoved = Array.isArray(missionData?.moved)
|
|
1121
|
+
? missionData.moved.length
|
|
1122
|
+
: 0;
|
|
1123
|
+
if (!dryRun && missionMoved > 0) {
|
|
1115
1124
|
try {
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
1125
|
-
timeout: 120_000,
|
|
1126
|
-
});
|
|
1127
|
-
execSync("git add pnpm-lock.yaml", {
|
|
1128
|
-
cwd: context.workspaceRoot,
|
|
1129
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
1130
|
-
});
|
|
1131
|
-
if (outputFormat === "pretty") {
|
|
1132
|
-
logger.info(" docs.archive: staged pnpm-lock.yaml refresh (safety net)");
|
|
1133
|
-
}
|
|
1125
|
+
const restored = await restoreTrackedLockfile(context.workspaceRoot, {
|
|
1126
|
+
...execFileSyncAdapter(),
|
|
1127
|
+
writeFile: async (target, content) => {
|
|
1128
|
+
await writeFileIfChanged(target, content);
|
|
1129
|
+
},
|
|
1130
|
+
});
|
|
1131
|
+
if (restored && outputFormat === "pretty") {
|
|
1132
|
+
logger.info(" docs.archive: restored pnpm-lock.yaml to HEAD (safety net)");
|
|
1134
1133
|
}
|
|
1135
1134
|
} catch (refreshErr) {
|
|
1136
1135
|
if (outputFormat === "pretty") {
|
|
1137
1136
|
logger.warn(
|
|
1138
|
-
` docs.archive: lockfile safety-net
|
|
1137
|
+
` docs.archive: lockfile safety-net restore failed — run 'pnpm install' manually: ${refreshErr instanceof Error ? refreshErr.message : String(refreshErr)}`,
|
|
1139
1138
|
);
|
|
1140
1139
|
}
|
|
1141
1140
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Liveness check for file-lock holders (RFC-1504): `holderIsDead`
|
|
4
|
+
decides whether the process that wrote a lock no longer exists — dead pids
|
|
5
|
+
are broken without waiting, foreign hosts keep the age rule, a foreign boot
|
|
6
|
+
id on this host means the holder died with the last boot. `currentBootId`
|
|
7
|
+
reads /proc/sys/kernel/random/boot_id when the platform has one.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No lock acquisition — os/flow/locks.ts and os/core/stamp-lock.ts own
|
|
10
|
+
the O_EXCL path.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1504: step 2 — holderIsDead + currentBootId</item>
|
|
15
|
+
<item>RFC-1504: steps 2-3 — holderIsDead, boot-id payload, dead-holder break in withFlowLock</item>
|
|
16
|
+
<item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
import { readFile, rename } from "node:fs/promises";
|
|
22
|
+
import { hostname } from "node:os";
|
|
23
|
+
|
|
24
|
+
export interface LockHolder {
|
|
25
|
+
pid: number;
|
|
26
|
+
host?: string;
|
|
27
|
+
at?: string;
|
|
28
|
+
bootId?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The machine's boot id, or undefined on platforms without one / on any read error. */
|
|
32
|
+
export function currentBootId(): string | undefined {
|
|
33
|
+
try {
|
|
34
|
+
const raw = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
35
|
+
return raw.length > 0 ? raw : undefined;
|
|
36
|
+
} catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* True when the recorded holder cannot exist anymore. A lock from another
|
|
43
|
+
* host (or with no host at all) is never judged by pid — pid namespaces
|
|
44
|
+
* differ, so the age rule stays the only breaker there. A same-host lock
|
|
45
|
+
* carrying a bootId different from the current boot is dead by definition:
|
|
46
|
+
* the machine restarted since it was written. Otherwise `kill(pid, 0)`
|
|
47
|
+
* probes: ESRCH is dead, EPERM and success are alive; any other error is
|
|
48
|
+
* treated as alive (fail closed).
|
|
49
|
+
*/
|
|
50
|
+
export function holderIsDead(lock: LockHolder, bootId: string | undefined = currentBootId()): boolean {
|
|
51
|
+
if (lock.host === undefined || lock.host !== hostname()) return false;
|
|
52
|
+
if (lock.bootId !== undefined && bootId !== undefined && lock.bootId !== bootId) return true;
|
|
53
|
+
try {
|
|
54
|
+
process.kill(lock.pid, 0);
|
|
55
|
+
return false;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return (error as NodeJS.ErrnoException).code === "ESRCH";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Atomically claim the right to remove a stale/dead lock file: re-read the
|
|
63
|
+
* file, verify it still carries the `expected` holder (same pid and at), and
|
|
64
|
+
* rename it to a unique tombstone path. Returns the tombstone path for the
|
|
65
|
+
* caller to unlink, or null when the lock changed hands in between — in
|
|
66
|
+
* that case a fresh holder stands and the file must not be touched.
|
|
67
|
+
* The rename is the claim: two contenders racing the same dead lock cannot
|
|
68
|
+
* both land it, so a winner never deletes another contender's fresh lock.
|
|
69
|
+
*/
|
|
70
|
+
export async function claimLockBreak(
|
|
71
|
+
lockPath: string,
|
|
72
|
+
expected: { pid: number; at: string } | null,
|
|
73
|
+
): Promise<string | null> {
|
|
74
|
+
const tombPath = `${lockPath}.tomb.${process.pid}.${Date.now()}`;
|
|
75
|
+
try {
|
|
76
|
+
const current = JSON.parse(await readFile(lockPath, "utf8")) as Record<string, unknown>;
|
|
77
|
+
if (expected !== null) {
|
|
78
|
+
const at = typeof current["at"] === "string" ? current["at"]
|
|
79
|
+
: typeof current["acquiredAt"] === "string" ? current["acquiredAt"]
|
|
80
|
+
: "";
|
|
81
|
+
if (current["pid"] !== expected.pid || at !== expected.at) return null;
|
|
82
|
+
}
|
|
83
|
+
await rename(lockPath, tombPath);
|
|
84
|
+
return tombPath;
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Shared one-shot stamp lock for rfc.implement.stamp and
|
|
4
|
+
adr.implement.stamp (RFC-1504): O_EXCL acquisition carrying
|
|
5
|
+
{pid, host, at, bootId?}; on contention the holder's file is judged —
|
|
6
|
+
a dead holder or a lock older than STAMP_LOCK_STALE_MS is claimed by an
|
|
7
|
+
atomic rename and removed, then the acquire retries (bounded attempts);
|
|
8
|
+
a live or foreign holder returns acquired:false so the caller keeps its
|
|
9
|
+
IMP-05 refusal. Legacy lock files written as {pid, acquiredAt} have no
|
|
10
|
+
host — they are judged by age only, reading acquiredAt when at is absent.
|
|
11
|
+
No wait loop — stamp locks never had one.</purpose>
|
|
12
|
+
<non-goals>
|
|
13
|
+
<item>No release — callers keep their own verified rm(lockPath).</item>
|
|
14
|
+
</non-goals>
|
|
15
|
+
</MODULE_CONTRACT>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1504: step 4 — shared stamp lock with dead-holder break</item>
|
|
18
|
+
<item>RFC-1504: review fixes — acquiredAt fallback, atomic break claim, held payload for verified release</item>
|
|
19
|
+
</CHANGE_SUMMARY>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
23
|
+
import { hostname } from "node:os";
|
|
24
|
+
import { dirname } from "node:path";
|
|
25
|
+
|
|
26
|
+
import { claimLockBreak, currentBootId, holderIsDead } from "./lock-holder.ts";
|
|
27
|
+
|
|
28
|
+
export const STAMP_LOCK_STALE_MS = 30 * 60 * 1000;
|
|
29
|
+
|
|
30
|
+
export interface StampLockOptions {
|
|
31
|
+
/** Called when a stale or dead lock file is removed. */
|
|
32
|
+
onStale?: (info: {
|
|
33
|
+
path: string;
|
|
34
|
+
reason: "dead-holder" | "stale-age";
|
|
35
|
+
at?: string;
|
|
36
|
+
pid?: number;
|
|
37
|
+
host?: string;
|
|
38
|
+
ageMs?: number;
|
|
39
|
+
}) => void;
|
|
40
|
+
/** Injectable clock for tests. */
|
|
41
|
+
now?: () => number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface StampLockHeld {
|
|
45
|
+
pid: number;
|
|
46
|
+
at: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface StampLockContent {
|
|
50
|
+
pid: number;
|
|
51
|
+
host?: string;
|
|
52
|
+
at: string;
|
|
53
|
+
bootId?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function tryAcquire(lockPath: string, content: StampLockContent): Promise<boolean> {
|
|
57
|
+
try {
|
|
58
|
+
await writeFile(lockPath, JSON.stringify(content), { flag: "wx" });
|
|
59
|
+
return true;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if ((error as NodeJS.ErrnoException).code === "EEXIST") return false;
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function readHolder(lockPath: string): Promise<StampLockContent | null> {
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(await readFile(lockPath, "utf8")) as Record<string, unknown>;
|
|
69
|
+
if (typeof parsed["pid"] !== "number") return null;
|
|
70
|
+
// RFC-1504: legacy locks carry acquiredAt instead of at — read either.
|
|
71
|
+
const at = typeof parsed["at"] === "string" ? parsed["at"]
|
|
72
|
+
: typeof parsed["acquiredAt"] === "string" ? parsed["acquiredAt"]
|
|
73
|
+
: "";
|
|
74
|
+
return {
|
|
75
|
+
pid: parsed["pid"],
|
|
76
|
+
host: typeof parsed["host"] === "string" ? parsed["host"] : undefined,
|
|
77
|
+
at,
|
|
78
|
+
bootId: typeof parsed["bootId"] === "string" ? parsed["bootId"] : undefined,
|
|
79
|
+
};
|
|
80
|
+
} catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Acquire `lockPath` once. Returns {acquired:true, held} after claiming and
|
|
87
|
+
* removing a dead or stale holder, {acquired:false} while a live or foreign
|
|
88
|
+
* holder stands. `held` is the payload just written — pass it to a verified
|
|
89
|
+
* release so a lock taken over mid-run is never deleted.
|
|
90
|
+
*/
|
|
91
|
+
export async function acquireStampLock(
|
|
92
|
+
lockPath: string,
|
|
93
|
+
opts: StampLockOptions = {},
|
|
94
|
+
): Promise<{ acquired: boolean; lockPath: string; held?: StampLockHeld }> {
|
|
95
|
+
const now = opts.now ?? (() => Date.now());
|
|
96
|
+
await mkdir(dirname(lockPath), { recursive: true });
|
|
97
|
+
const bootId = currentBootId();
|
|
98
|
+
|
|
99
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
100
|
+
const at = new Date(now()).toISOString();
|
|
101
|
+
const content: StampLockContent = { pid: process.pid, host: hostname(), at };
|
|
102
|
+
if (bootId !== undefined) content.bootId = bootId;
|
|
103
|
+
if (await tryAcquire(lockPath, content)) {
|
|
104
|
+
return { acquired: true, lockPath, held: { pid: process.pid, at } };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const holder = await readHolder(lockPath);
|
|
108
|
+
const heldAtMs = holder !== null && holder.at.length > 0 ? Date.parse(holder.at) : NaN;
|
|
109
|
+
const ageMs = Number.isNaN(heldAtMs) ? NaN : now() - heldAtMs;
|
|
110
|
+
|
|
111
|
+
if (holder !== null && holderIsDead(holder, bootId)) {
|
|
112
|
+
opts.onStale?.({
|
|
113
|
+
path: lockPath,
|
|
114
|
+
reason: "dead-holder",
|
|
115
|
+
at: holder.at,
|
|
116
|
+
pid: holder.pid,
|
|
117
|
+
host: holder.host,
|
|
118
|
+
ageMs: Number.isNaN(ageMs) ? undefined : ageMs,
|
|
119
|
+
});
|
|
120
|
+
// Atomic claim: only the contender whose rename lands removes the file —
|
|
121
|
+
// a loser racing the same dead lock gets null and retries normally.
|
|
122
|
+
const tomb = await claimLockBreak(lockPath, holder);
|
|
123
|
+
if (tomb !== null) await rm(tomb, { force: true });
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!Number.isNaN(ageMs) && ageMs > STAMP_LOCK_STALE_MS) {
|
|
127
|
+
opts.onStale?.({
|
|
128
|
+
path: lockPath,
|
|
129
|
+
reason: "stale-age",
|
|
130
|
+
at: holder?.at,
|
|
131
|
+
pid: holder?.pid,
|
|
132
|
+
host: holder?.host,
|
|
133
|
+
ageMs,
|
|
134
|
+
});
|
|
135
|
+
const tomb = await claimLockBreak(lockPath, holder);
|
|
136
|
+
if (tomb !== null) await rm(tomb, { force: true });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
return { acquired: false, lockPath };
|
|
140
|
+
}
|
|
141
|
+
return { acquired: false, lockPath };
|
|
142
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# flow-guard.sh — Forge fixed-branch-model commit guard (RFC-1486).
|
|
3
|
+
#
|
|
4
|
+
# Installed by `flow.install` into hooks/flow-guard.sh and invoked from the
|
|
5
|
+
# managed blocks in hooks/pre-commit and hooks/pre-merge-commit:
|
|
6
|
+
#
|
|
7
|
+
# # >>> forge flow guard (managed by flow.install) >>>
|
|
8
|
+
# sh "$(git rev-parse --show-toplevel)/hooks/flow-guard.sh" <mode> || exit 1
|
|
9
|
+
# # <<< forge flow guard <<<
|
|
10
|
+
#
|
|
11
|
+
# POSIX sh only — no node, no pnpm, no bashisms — so it runs in a fresh
|
|
12
|
+
# worktree before `pnpm install` and on Windows Git Bash. The guard never
|
|
13
|
+
# commits, never writes files and never reads network state.
|
|
14
|
+
#
|
|
15
|
+
# The branch-name grammar MUST stay byte-identical to FLOW_BRANCH_PATTERN in
|
|
16
|
+
# packages/forge/os/flow/branch-name.ts — flow-guard-parity.test.ts compares
|
|
17
|
+
# the literal text and the verdicts.
|
|
18
|
+
|
|
19
|
+
set -eu
|
|
20
|
+
|
|
21
|
+
refuse() {
|
|
22
|
+
# $1 rule id, $2 message, $3 remedy — stderr, one line per field.
|
|
23
|
+
printf '%s\n' "$1: $2" >&2
|
|
24
|
+
printf 'remedy: %s\n' "$3" >&2
|
|
25
|
+
exit 1
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Modes: pre-commit (regular commits), pre-merge-commit (merge commits) and
|
|
29
|
+
# pre-push (git passes remote name + URL — the guard ignores its extra
|
|
30
|
+
# arguments and stdin). Unknown modes are not ours.
|
|
31
|
+
mode="${1:-}"
|
|
32
|
+
case "$mode" in
|
|
33
|
+
pre-commit) ;;
|
|
34
|
+
pre-merge-commit) ;;
|
|
35
|
+
pre-push) ;;
|
|
36
|
+
*) exit 0 ;;
|
|
37
|
+
esac
|
|
38
|
+
|
|
39
|
+
# 1. Generated repositories are exempt: a VALID forge.generated.yaml at the
|
|
40
|
+
# top level marks a generator-owned repository (extract mirror,
|
|
41
|
+
# deployment repository) — never blocked by this guard. "Valid" mirrors
|
|
42
|
+
# markerContentIsValid in os/flow/markers.ts: a schema + generator key —
|
|
43
|
+
# a bare or garbage file does NOT disable the guard.
|
|
44
|
+
top=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0
|
|
45
|
+
if [ -f "$top/forge.generated.yaml" ] &&
|
|
46
|
+
grep -Eq '^schema:[ \t]*"?forge/generated' "$top/forge.generated.yaml" &&
|
|
47
|
+
grep -Eq '^generator:[ \t]*"?[A-Za-z]' "$top/forge.generated.yaml"; then
|
|
48
|
+
exit 0
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# 2. FORGE_FLOW_OP — closed vocabulary per mode, only Forge flow commands
|
|
52
|
+
# set it. pre-commit accepts `install` (the adoption commit); the
|
|
53
|
+
# pre-merge-commit vocabulary is empty — no flow operation may create a
|
|
54
|
+
# merge commit directly (back-merges go through a port branch under the
|
|
55
|
+
# gate, RFC-1490); pre-push accepts `push` (flow.push). `backmerge` is
|
|
56
|
+
# retired (RFC-1490) and `push` outside pre-push refuses — both with
|
|
57
|
+
# FLOW-GUARD-04.
|
|
58
|
+
op_vocabulary="install"
|
|
59
|
+
[ "$mode" = "pre-merge-commit" ] && op_vocabulary="<none>"
|
|
60
|
+
[ "$mode" = "pre-push" ] && op_vocabulary="push"
|
|
61
|
+
case "${FORGE_FLOW_OP:-}" in
|
|
62
|
+
"")
|
|
63
|
+
[ "$mode" != "pre-push" ] || {
|
|
64
|
+
refuse "FLOW-GUARD-05" \
|
|
65
|
+
"pushes go through flow.push (outbound only by operator command, RFC-1491)." \
|
|
66
|
+
"read the risk digest first — pnpm exec forge flow.digest"
|
|
67
|
+
}
|
|
68
|
+
;;
|
|
69
|
+
install)
|
|
70
|
+
[ "$mode" = "pre-commit" ] || {
|
|
71
|
+
refuse "FLOW-GUARD-04" \
|
|
72
|
+
"FORGE_FLOW_OP='${FORGE_FLOW_OP}' is not a forge flow operation in mode '$mode' (closed vocabulary: $op_vocabulary; RFC-1486/1490)." \
|
|
73
|
+
"unset FORGE_FLOW_OP — only forge flow commands set it"
|
|
74
|
+
}
|
|
75
|
+
exit 0 ;;
|
|
76
|
+
push)
|
|
77
|
+
[ "$mode" = "pre-push" ] || {
|
|
78
|
+
refuse "FLOW-GUARD-04" \
|
|
79
|
+
"FORGE_FLOW_OP='${FORGE_FLOW_OP}' is not a forge flow operation in mode '$mode' (closed vocabulary: $op_vocabulary; RFC-1486/1490)." \
|
|
80
|
+
"unset FORGE_FLOW_OP — only forge flow commands set it"
|
|
81
|
+
}
|
|
82
|
+
exit 0 ;;
|
|
83
|
+
*)
|
|
84
|
+
refuse "FLOW-GUARD-04" \
|
|
85
|
+
"FORGE_FLOW_OP='${FORGE_FLOW_OP}' is not a forge flow operation in mode '$mode' (closed vocabulary: $op_vocabulary; RFC-1486/1490)." \
|
|
86
|
+
"unset FORGE_FLOW_OP — only forge flow commands set it"
|
|
87
|
+
;;
|
|
88
|
+
esac
|
|
89
|
+
|
|
90
|
+
# pre-push guards outbound transport only — branch rules below are commit rules.
|
|
91
|
+
[ "$mode" = "pre-push" ] && exit 0
|
|
92
|
+
|
|
93
|
+
# 3./4. Resolve the branch — an empty symbolic ref means detached HEAD.
|
|
94
|
+
branch=$(git symbolic-ref --short -q HEAD 2>/dev/null) || branch=""
|
|
95
|
+
if [ -z "$branch" ]; then
|
|
96
|
+
gitdir=$(git rev-parse --git-dir 2>/dev/null) || gitdir=""
|
|
97
|
+
if [ -n "$gitdir" ] && {
|
|
98
|
+
[ -d "$gitdir/rebase-merge" ] || [ -d "$gitdir/rebase-apply" ] || [ -f "$gitdir/CHERRY_PICK_HEAD" ]
|
|
99
|
+
}; then
|
|
100
|
+
exit 0
|
|
101
|
+
fi
|
|
102
|
+
refuse "FLOW-GUARD-03" \
|
|
103
|
+
"commits on a detached HEAD outside a rebase or cherry-pick are refused (fixed branch model, RFC-1486)." \
|
|
104
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# Unborn HEAD: only an unborn develop may carry the repository's first
|
|
108
|
+
# commit (flow.install points new repositories at develop).
|
|
109
|
+
if ! git rev-parse --verify -q HEAD >/dev/null 2>&1; then
|
|
110
|
+
[ "$branch" = "develop" ] && exit 0
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# 5. Protected integration branches receive integrations only.
|
|
114
|
+
case "$branch" in
|
|
115
|
+
develop|main)
|
|
116
|
+
refuse "FLOW-GUARD-01" \
|
|
117
|
+
"direct commits on '$branch' are refused (fixed branch model, RFC-1486)." \
|
|
118
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
119
|
+
;;
|
|
120
|
+
esac
|
|
121
|
+
|
|
122
|
+
# 6. FI-1 grammar — the literal below is the same text as FLOW_BRANCH_PATTERN
|
|
123
|
+
# in packages/forge/os/flow/branch-name.ts (do not diverge).
|
|
124
|
+
flow_branch_pattern='^auto/(task|session|fix)-[0-9]{6}-[0-9]{2}-[a-z0-9]+(-[a-z0-9]+)*$'
|
|
125
|
+
if ! printf '%s' "$branch" | grep -Eq "$flow_branch_pattern"; then
|
|
126
|
+
refuse "FLOW-GUARD-02" \
|
|
127
|
+
"branch '$branch' is outside the fixed branch model grammar auto/<kind>-<YYMMDD>-<NN>-<slug> (RFC-1486)." \
|
|
128
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
# The regex cannot express: NN 01–99 (never 00), slug length 3–48, YYMMDD a
|
|
132
|
+
# real calendar date. Enforce them exactly as parseFlowBranch does.
|
|
133
|
+
tail=${branch#auto/} # <kind>-<YYMMDD>-<NN>-<slug>
|
|
134
|
+
tail=${tail#*-} # <YYMMDD>-<NN>-<slug>
|
|
135
|
+
yymmdd=${tail%%-*}
|
|
136
|
+
tail=${tail#*-} # <NN>-<slug>
|
|
137
|
+
nn=${tail%%-*}
|
|
138
|
+
slug=${tail#*-}
|
|
139
|
+
|
|
140
|
+
if [ "$nn" = "00" ]; then
|
|
141
|
+
refuse "FLOW-GUARD-02" \
|
|
142
|
+
"branch '$branch' is outside the fixed branch model grammar auto/<kind>-<YYMMDD>-<NN>-<slug> (RFC-1486)." \
|
|
143
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
slug_len=${#slug}
|
|
147
|
+
if [ "$slug_len" -lt 3 ] || [ "$slug_len" -gt 48 ]; then
|
|
148
|
+
refuse "FLOW-GUARD-02" \
|
|
149
|
+
"branch '$branch' is outside the fixed branch model grammar auto/<kind>-<YYMMDD>-<NN>-<slug> (RFC-1486)." \
|
|
150
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
# YYMMDD as a real date. ${var#0} strips one leading zero so the numbers stay
|
|
154
|
+
# decimal without non-POSIX base prefixes.
|
|
155
|
+
yy=${yymmdd%????}
|
|
156
|
+
mdpart=${yymmdd#??}
|
|
157
|
+
mm=${mdpart%??}
|
|
158
|
+
dd=${mdpart#??}
|
|
159
|
+
yy_n=${yy#0}
|
|
160
|
+
mm_n=${mm#0}
|
|
161
|
+
dd_n=${dd#0}
|
|
162
|
+
case "$mm_n" in
|
|
163
|
+
1|3|5|7|8|10|12) dim=31 ;;
|
|
164
|
+
4|6|9|11) dim=30 ;;
|
|
165
|
+
2)
|
|
166
|
+
if [ $((yy_n % 4)) -eq 0 ]; then dim=29; else dim=28; fi
|
|
167
|
+
;;
|
|
168
|
+
*) dim=0 ;;
|
|
169
|
+
esac
|
|
170
|
+
if [ "$dim" -eq 0 ] || [ "$dd_n" -lt 1 ] || [ "$dd_n" -gt "$dim" ]; then
|
|
171
|
+
refuse "FLOW-GUARD-02" \
|
|
172
|
+
"branch '$branch' is outside the fixed branch model grammar auto/<kind>-<YYMMDD>-<NN>-<slug> (RFC-1486)." \
|
|
173
|
+
"work on an auto branch — pnpm exec forge flow.open --kind session --slug <slug>"
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
exit 0
|