mandrel 1.58.0 → 1.60.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/README.md +100 -98
- package/.agents/docs/SDLC.md +140 -141
- package/.agents/docs/configuration.md +16 -16
- package/.agents/docs/workflows.md +7 -8
- package/.agents/instructions.md +12 -11
- package/.agents/personas/architect.md +1 -1
- package/.agents/personas/product.md +1 -1
- package/.agents/personas/project-manager.md +14 -14
- package/.agents/personas/technical-writer.md +1 -1
- package/.agents/rules/changelog-style.md +5 -5
- package/.agents/rules/git-conventions.md +3 -3
- package/.agents/schemas/agentrc.schema.json +3 -3
- package/.agents/schemas/audit-rules.json +20 -0
- package/.agents/schemas/dispatch-manifest.json +4 -4
- package/.agents/schemas/epic-spec.schema.json +15 -45
- package/.agents/schemas/lifecycle/README.md +1 -1
- package/.agents/schemas/lifecycle/story.dispatch.end.schema.json +1 -1
- package/.agents/schemas/lifecycle/story.dispatch.start.schema.json +1 -1
- package/.agents/schemas/lifecycle/story.heartbeat.schema.json +1 -1
- package/.agents/schemas/validation-evidence.schema.json +1 -1
- package/.agents/scripts/README.md +1 -1
- package/.agents/scripts/acceptance-eval.js +21 -4
- package/.agents/scripts/acceptance-spec-reconciler.js +2 -2
- package/.agents/scripts/analyze-execution.js +2 -2
- package/.agents/scripts/assert-branch.js +1 -3
- package/.agents/scripts/audit-to-stories.js +1 -1
- package/.agents/scripts/bootstrap.js +1 -1
- package/.agents/scripts/check-arch-cycles.js +360 -0
- package/.agents/scripts/check-doc-links.js +2 -3
- package/.agents/scripts/coverage-capture.js +24 -3
- package/.agents/scripts/diagnose-friction.js +1 -1
- package/.agents/scripts/dispatcher.js +2 -2
- package/.agents/scripts/drain-pending-cleanup.js +1 -1
- package/.agents/scripts/epic-audit-prepare.js +3 -3
- package/.agents/scripts/epic-deliver-note-intervention.js +2 -2
- package/.agents/scripts/epic-deliver-preflight.js +11 -9
- package/.agents/scripts/epic-deliver-prepare.js +13 -5
- package/.agents/scripts/epic-execute-record-wave.js +5 -5
- package/.agents/scripts/epic-plan-healthcheck.js +6 -10
- package/.agents/scripts/epic-plan-spec-validate.js +1 -1
- package/.agents/scripts/epic-reconcile.js +11 -29
- package/.agents/scripts/evidence-gate.js +2 -2
- package/.agents/scripts/generate-workflows-doc.js +1 -1
- package/.agents/scripts/git-rebase-and-resolve.js +1 -1
- package/.agents/scripts/hierarchy-gate.js +40 -24
- package/.agents/scripts/lib/ITicketingProvider.js +1 -1
- package/.agents/scripts/lib/audit-suite/selector.js +1 -1
- package/.agents/scripts/lib/audit-to-stories/seed-epic-from-findings.js +2 -2
- package/.agents/scripts/lib/baseline-snapshot.js +7 -7
- package/.agents/scripts/lib/baselines/kinds/coverage.js +33 -149
- package/.agents/scripts/lib/baselines/kinds/duplication.js +27 -116
- package/.agents/scripts/lib/baselines/kinds/kind-factory.js +192 -0
- package/.agents/scripts/lib/baselines/kinds/lighthouse.js +34 -133
- package/.agents/scripts/lib/baselines/kinds/maintainability.js +31 -124
- package/.agents/scripts/lib/baselines/kinds/mutation.js +25 -111
- package/.agents/scripts/lib/baselines/maintainability-baseline-io.js +59 -0
- package/.agents/scripts/lib/baselines/maintainability-baseline-save.js +37 -0
- package/.agents/scripts/lib/baselines/writer.js +1 -1
- package/.agents/scripts/lib/bdd-runner-detect.js +1 -1
- package/.agents/scripts/lib/bdd-scenario-scanner.js +3 -3
- package/.agents/scripts/lib/bootstrap/baselines-layout-migration.js +1 -1
- package/.agents/scripts/lib/bootstrap/branch-protection.js +1 -1
- package/.agents/scripts/lib/bootstrap/ci-workflow-template.js +1 -1
- package/.agents/scripts/lib/bootstrap/commit-push.js +2 -2
- package/.agents/scripts/lib/close-validation/commands.js +188 -0
- package/.agents/scripts/lib/close-validation/gates.js +235 -0
- package/.agents/scripts/lib/close-validation/process.js +101 -0
- package/.agents/scripts/lib/close-validation/projections/maintainability.js +1 -1
- package/.agents/scripts/lib/close-validation/runner.js +325 -0
- package/.agents/scripts/lib/close-validation/telemetry.js +70 -0
- package/.agents/scripts/lib/codebase-snapshot.js +1 -1
- package/.agents/scripts/lib/config/explain.js +1 -1
- package/.agents/scripts/lib/config/quality.js +6 -6
- package/.agents/scripts/lib/config/runners.js +2 -2
- package/.agents/scripts/lib/config/runtime.js +1 -1
- package/.agents/scripts/lib/config/temp-paths.js +2 -2
- package/.agents/scripts/lib/config-resolver.js +2 -5
- package/.agents/scripts/lib/config-settings-schema-delivery.js +2 -2
- package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
- package/.agents/scripts/lib/config-settings-schema.js +3 -3
- package/.agents/scripts/lib/coverage-capture.js +147 -4
- package/.agents/scripts/lib/cpu-pool.js +14 -0
- package/.agents/scripts/lib/crap-utils.js +6 -11
- package/.agents/scripts/lib/duplicate-search.js +1 -1
- package/.agents/scripts/lib/dynamic-workflow/capability.js +1 -1
- package/.agents/scripts/lib/dynamic-workflow/documentation-report-contract.js +87 -0
- package/.agents/scripts/lib/epic-plan-clarity.js +1 -1
- package/.agents/scripts/lib/epic-plan-ideation.js +1 -1
- package/.agents/scripts/lib/feedback-loop/memory-freshness.js +1 -1
- package/.agents/scripts/lib/feedback-loop/prior-feedback-fetcher.js +1 -1
- package/.agents/scripts/lib/findings/classify-finding.js +1 -1
- package/.agents/scripts/lib/findings/promote-finding.js +10 -10
- package/.agents/scripts/lib/git-utils.js +24 -22
- package/.agents/scripts/lib/label-constants.js +3 -4
- package/.agents/scripts/lib/label-taxonomy.js +3 -8
- package/.agents/scripts/lib/maintainability-engine.js +1 -1
- package/.agents/scripts/lib/maintainability-utils.js +4 -187
- package/.agents/scripts/lib/observability/perf-report-readers.js +32 -23
- package/.agents/scripts/lib/orchestration/acceptance-eval-decision.js +81 -7
- package/.agents/scripts/lib/orchestration/code-review.js +95 -82
- package/.agents/scripts/lib/orchestration/context-hydration-engine.js +8 -9
- package/.agents/scripts/lib/orchestration/dependency-analyzer.js +3 -3
- package/.agents/scripts/lib/orchestration/detectors-phase.js +2 -2
- package/.agents/scripts/lib/orchestration/dispatch-engine.js +30 -38
- package/.agents/scripts/lib/orchestration/dispatch-pipeline.js +14 -37
- package/.agents/scripts/lib/orchestration/epic-cleanup.js +1 -1
- package/.agents/scripts/lib/orchestration/epic-deliver-lease-guard.js +22 -22
- package/.agents/scripts/lib/orchestration/epic-plan-decompose/phases/creation.js +1 -1
- package/.agents/scripts/lib/orchestration/epic-plan-decompose/phases/dag.js +7 -21
- package/.agents/scripts/lib/orchestration/epic-plan-decompose/phases/diagnostics.js +3 -3
- package/.agents/scripts/lib/orchestration/epic-plan-decompose/phases/planning-artifacts.js +2 -2
- package/.agents/scripts/lib/orchestration/epic-plan-lease-guard.js +206 -58
- package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/drain.js +1 -1
- package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/plan-epic.js +27 -3
- package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/prompts.js +1 -1
- package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/run-spec-phase.js +28 -8
- package/.agents/scripts/lib/orchestration/epic-plan-state-store.js +1 -1
- package/.agents/scripts/lib/orchestration/epic-run-state-store.js +3 -3
- package/.agents/scripts/lib/orchestration/epic-runner/concurrency-gate.js +4 -4
- package/.agents/scripts/lib/orchestration/epic-runner/deliver-phases.js +3 -3
- package/.agents/scripts/lib/orchestration/epic-runner/phases/build-wave-dag.js +13 -41
- package/.agents/scripts/lib/orchestration/epic-runner/phases/snapshot.js +7 -7
- package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter/composition.js +2 -3
- package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter/signals.js +2 -8
- package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter/transport.js +4 -4
- package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/component-drift.js +103 -0
- package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/crap-drift.js +22 -64
- package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/maintainability-drift.js +38 -76
- package/.agents/scripts/lib/orchestration/epic-runner/story-launcher.js +4 -4
- package/.agents/scripts/lib/orchestration/epic-runner/story-run-progress-writer.js +10 -10
- package/.agents/scripts/lib/orchestration/epic-runner/sub-agent-return.js +8 -20
- package/.agents/scripts/lib/orchestration/epic-spec-reconciler-apply.js +7 -15
- package/.agents/scripts/lib/orchestration/epic-spec-reconciler-diff.js +72 -41
- package/.agents/scripts/lib/orchestration/epic-spec-reconciler-ops.js +2 -4
- package/.agents/scripts/lib/orchestration/file-assumptions.js +6 -5
- package/.agents/scripts/lib/orchestration/finalize/close-planning-tickets.js +1 -1
- package/.agents/scripts/lib/orchestration/finalize/open-or-locate-pr.js +2 -2
- package/.agents/scripts/lib/orchestration/finalize/sanitize-skip-ci.js +1 -1
- package/.agents/scripts/lib/orchestration/lease-guard-shared.js +144 -0
- package/.agents/scripts/lib/orchestration/lifecycle/emit-story-dispatch-end.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/emit-story-heartbeat.js +3 -3
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/README.md +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/automerge-armer.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/automerge-predicate.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/branch-cleaner.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/finalizer.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/index.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/merge-watcher.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/notify-dispatcher.js +1 -1
- package/.agents/scripts/lib/orchestration/lifecycle/listeners/watcher.js +8 -8
- package/.agents/scripts/lib/orchestration/manifest-builder.js +5 -5
- package/.agents/scripts/lib/orchestration/parked-follow-ons.js +2 -2
- package/.agents/scripts/lib/orchestration/plan-runner/plan-router.js +5 -5
- package/.agents/scripts/lib/orchestration/post-merge/phases/notification.js +3 -3
- package/.agents/scripts/lib/orchestration/post-merge/phases/ticket-closure.js +3 -3
- package/.agents/scripts/lib/orchestration/post-merge/phases/worktree-reap.js +7 -7
- package/.agents/scripts/lib/orchestration/preflight-cache.js +36 -13
- package/.agents/scripts/lib/orchestration/recurring-failure-detector.js +1 -1
- package/.agents/scripts/lib/orchestration/retro/phases/compose-body.js +1 -1
- package/.agents/scripts/lib/orchestration/retro/phases/gather-signals.js +2 -2
- package/.agents/scripts/lib/orchestration/retro-runner.js +3 -3
- package/.agents/scripts/lib/orchestration/review-depth.js +1 -1
- package/.agents/scripts/lib/orchestration/review-providers/codex.js +5 -60
- package/.agents/scripts/lib/orchestration/review-providers/native.js +7 -6
- package/.agents/scripts/lib/orchestration/review-providers/parse-findings.js +105 -0
- package/.agents/scripts/lib/orchestration/review-providers/security-review.js +7 -59
- package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +2 -4
- package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +1 -1
- package/.agents/scripts/lib/orchestration/single-story-close/phases/wrong-tree-guard.js +1 -1
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +2 -4
- package/.agents/scripts/lib/orchestration/single-story-lease-guard.js +32 -35
- package/.agents/scripts/lib/orchestration/skill-capsule-loader.js +1 -2
- package/.agents/scripts/lib/orchestration/spec-freshness.js +1 -1
- package/.agents/scripts/lib/orchestration/spec-renderer.js +36 -73
- package/.agents/scripts/lib/orchestration/spec-section-validator.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/auto-refresh-runner.js +451 -503
- package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/pre-merge-attribution.js +8 -2
- package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/refresh-commit.js +47 -2
- package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/regression-projection.js +2 -2
- package/.agents/scripts/lib/orchestration/story-close/baseline-friction-body.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/format-autofix.js +358 -54
- package/.agents/scripts/lib/orchestration/story-close/phases/close.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/phases/gates.js +3 -2
- package/.agents/scripts/lib/orchestration/story-close/phases/locked-pipeline.js +32 -5
- package/.agents/scripts/lib/orchestration/story-close/post-merge-close.js +5 -18
- package/.agents/scripts/lib/orchestration/story-close/pre-merge-validation.js +3 -3
- package/.agents/scripts/lib/orchestration/story-close-recovery.js +33 -16
- package/.agents/scripts/lib/orchestration/story-reachability.js +47 -0
- package/.agents/scripts/lib/orchestration/task-body-validator.js +6 -6
- package/.agents/scripts/lib/orchestration/ticket-lease.js +1 -1
- package/.agents/scripts/lib/orchestration/ticket-validator-conflicts.js +4 -35
- package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -10
- package/.agents/scripts/lib/orchestration/ticket-validator.js +25 -70
- package/.agents/scripts/lib/orchestration/ticketing/bulk.js +44 -73
- package/.agents/scripts/lib/orchestration/ticketing/reads.js +16 -7
- package/.agents/scripts/lib/orchestration/ticketing/state.js +53 -439
- package/.agents/scripts/lib/orchestration/ticketing/transition.js +471 -0
- package/.agents/scripts/lib/orchestration/ticketing.js +0 -1
- package/.agents/scripts/lib/orchestration/wave-record-notifications.js +3 -3
- package/.agents/scripts/lib/orchestration/wave-record-projection.js +2 -8
- package/.agents/scripts/lib/plan-phase-cleanup.js +1 -1
- package/.agents/scripts/lib/preflight-runner.js +1 -1
- package/.agents/scripts/lib/presentation/dispatch-manifest-render.js +4 -5
- package/.agents/scripts/lib/presentation/manifest-builder.js +28 -34
- package/.agents/scripts/lib/presentation/manifest-formatter.js +3 -4
- package/.agents/scripts/lib/presentation/manifest-helpers.js +1 -1
- package/.agents/scripts/lib/presentation/manifest-procedures.js +4 -4
- package/.agents/scripts/lib/presentation/manifest-render-waves.js +4 -23
- package/.agents/scripts/lib/presentation/manifest-renderer.js +1 -1
- package/.agents/scripts/lib/presentation/manifest-story-views.js +2 -11
- package/.agents/scripts/lib/project-root.js +17 -0
- package/.agents/scripts/lib/signals/schema.js +1 -1
- package/.agents/scripts/lib/spec/index.js +1 -1
- package/.agents/scripts/lib/spec/loader.js +2 -2
- package/.agents/scripts/lib/spec/state.js +7 -16
- package/.agents/scripts/lib/story-adjacency.js +76 -0
- package/.agents/scripts/lib/story-init/context-resolver.js +3 -3
- package/.agents/scripts/lib/story-init/state-transitioner.js +2 -2
- package/.agents/scripts/lib/story-init/task-graph-builder.js +7 -7
- package/.agents/scripts/lib/story-lifecycle.js +9 -9
- package/.agents/scripts/lib/story-plan.js +1 -1
- package/.agents/scripts/lib/templates/decomposer-prompts.js +59 -52
- package/.agents/scripts/lib/transpile.js +93 -0
- package/.agents/scripts/lib/wave-runner/tick.js +4 -153
- package/.agents/scripts/lib/workers/crap-worker.js +1 -1
- package/.agents/scripts/lib/workers/maintainability-report-worker.js +1 -1
- package/.agents/scripts/lib/worktree/lifecycle/creation.js +20 -2
- package/.agents/scripts/lib/worktree/lifecycle/force-drain.js +90 -0
- package/.agents/scripts/lib/worktree/lifecycle/reap.js +26 -8
- package/.agents/scripts/lib/worktree/node-modules-strategy.js +74 -0
- package/.agents/scripts/lifecycle-emit-story-dispatch.js +1 -1
- package/.agents/scripts/lifecycle-emit.js +1 -1
- package/.agents/scripts/providers/github/board-add.js +1 -1
- package/.agents/scripts/providers/github/errors.js +1 -1
- package/.agents/scripts/providers/github/mappers.js +2 -2
- package/.agents/scripts/providers/github/tickets.js +114 -10
- package/.agents/scripts/resync-status-column.js +1 -1
- package/.agents/scripts/retro-run.js +2 -2
- package/.agents/scripts/run-lint.js +10 -1
- package/.agents/scripts/run-tests.js +24 -4
- package/.agents/scripts/single-story-init.js +1 -1
- package/.agents/scripts/stories-wave-tick.js +13 -10
- package/.agents/scripts/story-close.js +1 -1
- package/.agents/scripts/story-init.js +162 -26
- package/.agents/scripts/story-phase.js +5 -5
- package/.agents/scripts/story-plan.js +3 -3
- package/.agents/scripts/sync-branch-from-base.js +2 -2
- package/.agents/scripts/validate-docs-freshness.js +1 -1
- package/.agents/scripts/wave-tick.js +1 -1
- package/.agents/skills/core/analyze-execution/SKILL.md +2 -2
- package/.agents/skills/core/epic-plan-consolidate/SKILL.md +21 -26
- package/.agents/skills/core/epic-plan-decompose-author/SKILL.md +23 -56
- package/.agents/skills/core/epic-plan-spec-author/SKILL.md +4 -4
- package/.agents/skills/core/hydrate-context/SKILL.md +2 -2
- package/.agents/skills/core/idea-refinement/SKILL.md +4 -4
- package/.agents/skills/core/knowledge-transfer/SKILL.md +2 -2
- package/.agents/skills/core/planning-and-task-breakdown/SKILL.md +1 -1
- package/.agents/skills/core/scope-triage/SKILL.md +9 -10
- package/.agents/skills/core/using-agent-skills/SKILL.md +1 -1
- package/.agents/skills/skills.index.json +7 -7
- package/.agents/skills/stack/qa/lighthouse-baseline/SKILL.md +1 -1
- package/.agents/templates/agent-protocol.md +2 -2
- package/.agents/workflows/agents-update.md +2 -2
- package/.agents/workflows/audit-architecture.md +2 -2
- package/.agents/workflows/audit-clean-code.md +2 -2
- package/.agents/workflows/audit-dependencies.md +1 -1
- package/.agents/workflows/audit-devops.md +1 -1
- package/.agents/workflows/audit-documentation.md +226 -0
- package/.agents/workflows/audit-lighthouse.md +1 -1
- package/.agents/workflows/audit-performance.md +2 -2
- package/.agents/workflows/audit-privacy.md +1 -1
- package/.agents/workflows/audit-quality.md +2 -2
- package/.agents/workflows/audit-security.md +2 -2
- package/.agents/workflows/audit-seo.md +1 -1
- package/.agents/workflows/audit-sre.md +1 -1
- package/.agents/workflows/audit-to-stories.md +10 -10
- package/.agents/workflows/audit-ux-ui.md +1 -1
- package/.agents/workflows/deliver.md +85 -0
- package/.agents/workflows/explain.md +3 -3
- package/.agents/workflows/git-merge-pr.md +1 -1
- package/.agents/workflows/git-pr-all.md +13 -10
- package/.agents/workflows/git-push.md +6 -3
- package/.agents/workflows/helpers/_merge-conflict-template.md +1 -1
- package/.agents/workflows/helpers/acceptance-self-eval.md +1 -1
- package/.agents/workflows/helpers/code-review.md +5 -5
- package/.agents/workflows/{epic-deliver.md → helpers/deliver-epic.md} +59 -66
- package/.agents/workflows/{story-deliver.md → helpers/deliver-stories.md} +25 -25
- package/.agents/workflows/helpers/diagnose.md +1 -1
- package/.agents/workflows/helpers/epic-audit.md +6 -6
- package/.agents/workflows/helpers/epic-deliver-story.md +28 -39
- package/.agents/workflows/helpers/epic-plan-decompose.md +23 -23
- package/.agents/workflows/helpers/epic-plan-spec.md +6 -6
- package/.agents/workflows/helpers/epic-testing.md +3 -3
- package/.agents/workflows/helpers/parallel-tooling.md +1 -1
- package/.agents/workflows/{epic-plan.md → helpers/plan-epic.md} +84 -84
- package/.agents/workflows/{story-plan.md → helpers/plan-story.md} +43 -43
- package/.agents/workflows/helpers/signals.md +1 -1
- package/.agents/workflows/helpers/single-story-deliver.md +12 -11
- package/.agents/workflows/helpers/worktree-lifecycle.md +18 -18
- package/.agents/workflows/onboard.md +21 -20
- package/.agents/workflows/plan.md +89 -0
- package/.agents/workflows/qa-explore.md +1 -1
- package/.agents/workflows/qa-run-harness.md +1 -1
- package/README.md +17 -20
- package/docs/CHANGELOG.md +1149 -0
- package/lib/cli/__tests__/update-changelog-surface.test.js +357 -0
- package/lib/cli/__tests__/update-reexec.test.js +513 -0
- package/lib/cli/init.js +338 -0
- package/lib/cli/update.js +413 -52
- package/package.json +3 -1
- package/.agents/scripts/lib/auto-refresh-baselines.js +0 -308
- package/.agents/scripts/lib/close-validation.js +0 -897
- package/.agents/scripts/lib/orchestration/cascade-grouping.js +0 -275
- package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter.js +0 -69
- package/.agents/scripts/lib/orchestration/reconciler.js +0 -137
- package/.agents/scripts/lib/orchestration/story-close/format-autofix-scoped.js +0 -221
- package/.agents/scripts/lib/orchestration/story-close/format-autofix-shared.js +0 -123
- package/.agents/scripts/lib/task-utils.js +0 -26
- package/.agents/scripts/story-deliver-prepare.js +0 -267
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* epic-plan-lease-guard.js — `/
|
|
2
|
+
* epic-plan-lease-guard.js — `/plan` workflow guards (Story #3481,
|
|
3
3
|
* Epic #3457).
|
|
4
4
|
*
|
|
5
5
|
* Wires the assignee-as-lease primitive (`ticket-lease.js`, Story #3480) and a
|
|
6
6
|
* decompose-idempotency guard into the split planning flow so two concurrent
|
|
7
|
-
* `/
|
|
7
|
+
* `/plan` runs cannot both drive the same Epic, and so a re-run does not
|
|
8
8
|
* silently duplicate the Feature/Story tree:
|
|
9
9
|
*
|
|
10
10
|
* - `acquireEpicPlanLease` — claim the Epic before Phase 7 (spec). Refuses
|
|
11
|
-
* (throws, exit non-zero) when a foreign
|
|
12
|
-
* already holds the Epic, naming the
|
|
13
|
-
* owner. **
|
|
14
|
-
* `/
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* unassigned or self-held Epic still proceeds.
|
|
11
|
+
* (throws, exit non-zero) when a live foreign
|
|
12
|
+
* claim already holds the Epic, naming the
|
|
13
|
+
* current owner. **Claim-time liveness
|
|
14
|
+
* (Story #4019):** `/plan` emits no
|
|
15
|
+
* `story.heartbeat`, so the lease records its
|
|
16
|
+
* own claim-time in a `plan-lease` structured
|
|
17
|
+
* comment on the Epic at acquire time. A
|
|
18
|
+
* foreign claim fresher than the lease TTL
|
|
19
|
+
* refuses (unless `--steal`); a stale or
|
|
20
|
+
* record-less claim is reclaimed
|
|
21
|
+
* automatically. An unassigned or self-held
|
|
22
|
+
* Epic still proceeds.
|
|
24
23
|
* - `releaseEpicPlanLease` — release the claim after Phase 8 (decompose).
|
|
25
24
|
* Best-effort and self-scoped: a no-op once the
|
|
26
25
|
* Epic was reassigned elsewhere.
|
|
27
26
|
* - `assertNoOpenPlanChildren` — refuse Phase 8 persist when the Epic already
|
|
28
|
-
* has open
|
|
27
|
+
* has open Story children, unless the
|
|
29
28
|
* operator passed `--force` (a deliberate
|
|
30
29
|
* re-decompose that closes the old tree).
|
|
31
30
|
*
|
|
@@ -35,16 +34,18 @@
|
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
36
|
import { getGitHub } from '../config/github.js';
|
|
37
|
+
import { resolveLeaseTtlMs } from '../config/limits.js';
|
|
38
38
|
import { Logger } from '../Logger.js';
|
|
39
39
|
import { TYPE_LABELS } from '../label-constants.js';
|
|
40
40
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} from './ticket-lease.js';
|
|
41
|
+
acquireLeaseFailClosed,
|
|
42
|
+
resolveOperatorFromCandidates,
|
|
43
|
+
} from './lease-guard-shared.js';
|
|
44
|
+
import { currentOwner, releaseLease } from './ticket-lease.js';
|
|
45
|
+
import { findStructuredComment, upsertStructuredComment } from './ticketing.js';
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
|
-
* Resolve the operator handle that owns this `/
|
|
48
|
+
* Resolve the operator handle that owns this `/plan` run from
|
|
48
49
|
* `github.operatorHandle`. The assignee-as-lease primitive is single-holder
|
|
49
50
|
* keyed on a non-empty string; when no operator is configured (unset, or the
|
|
50
51
|
* shipped `@[USERNAME]` placeholder, both of which `normalizeOperatorHandle`
|
|
@@ -52,32 +53,115 @@ import {
|
|
|
52
53
|
* (`acquireEpicPlanLease`) then fails closed by throwing rather than running an
|
|
53
54
|
* ownerless, unguarded plan.
|
|
54
55
|
*
|
|
55
|
-
* The `@`-prefix some operators carry on `operatorHandle` is stripped
|
|
56
|
-
* value matches the bare login GitHub
|
|
57
|
-
*
|
|
58
|
-
* assignee
|
|
59
|
-
*
|
|
60
|
-
*
|
|
56
|
+
* The `@`-prefix some operators carry on `operatorHandle` is stripped (via
|
|
57
|
+
* the shared lease-guard kernel) so the value matches the bare login GitHub
|
|
58
|
+
* writes to (and returns from) a ticket's `assignees` — otherwise the
|
|
59
|
+
* assignee PATCH is rejected (HTTP 422, invalid assignee) and the
|
|
60
|
+
* self-held-claim comparison (`owner === operator`) never matches.
|
|
61
|
+
*
|
|
62
|
+
* The plan surface's missing-handle policy is `'null'` (intentional
|
|
63
|
+
* divergence from the standalone path's `'throw'`): `releaseEpicPlanLease`
|
|
64
|
+
* is best-effort and must degrade to a `no-operator` no-op rather than
|
|
65
|
+
* throw, so the throw-on-missing decision lives in `acquireEpicPlanLease`.
|
|
61
66
|
*
|
|
62
67
|
* @param {object} config Resolved config bag.
|
|
63
68
|
* @returns {string|null}
|
|
64
69
|
*/
|
|
65
70
|
export function resolveOperator(config) {
|
|
66
|
-
return
|
|
71
|
+
return resolveOperatorFromCandidates({
|
|
72
|
+
candidates: [getGitHub(config).operatorHandle],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Structured-comment type carrying the plan-lease claim-time record.
|
|
78
|
+
* Registered in `ticketing/reads.js` `STRUCTURED_COMMENT_TYPES`.
|
|
79
|
+
*/
|
|
80
|
+
export const PLAN_LEASE_COMMENT_TYPE = 'plan-lease';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Render the `plan-lease` structured-comment body: a one-line human
|
|
84
|
+
* summary plus the canonical fenced-JSON record `parsePlanLeaseClaim`
|
|
85
|
+
* reads back.
|
|
86
|
+
*
|
|
87
|
+
* @param {{ epicId: number, owner: string, claimedAt: string }} input
|
|
88
|
+
* `claimedAt` is an ISO-8601 timestamp.
|
|
89
|
+
* @returns {string}
|
|
90
|
+
*/
|
|
91
|
+
export function buildPlanLeaseCommentBody({ epicId, owner, claimedAt }) {
|
|
92
|
+
const record = {
|
|
93
|
+
kind: PLAN_LEASE_COMMENT_TYPE,
|
|
94
|
+
epicId,
|
|
95
|
+
owner,
|
|
96
|
+
claimedAt,
|
|
97
|
+
};
|
|
98
|
+
return [
|
|
99
|
+
`### 🔒 Plan Lease — claimed by \`${owner}\``,
|
|
100
|
+
'',
|
|
101
|
+
`This Epic is being planned by \`${owner}\` (claimed ${claimedAt}). A`,
|
|
102
|
+
'concurrent `/plan` run refuses while this claim is fresher than the',
|
|
103
|
+
'lease TTL, and reclaims automatically once it goes stale.',
|
|
104
|
+
'',
|
|
105
|
+
'```json',
|
|
106
|
+
JSON.stringify(record, null, 2),
|
|
107
|
+
'```',
|
|
108
|
+
].join('\n');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Parse the claim record out of a `plan-lease` comment body. Returns
|
|
113
|
+
* `{ owner, claimedAtMs }` or `null` when the body carries no readable
|
|
114
|
+
* record — which callers treat as "no claim-time recorded" (stale,
|
|
115
|
+
* reclaimable).
|
|
116
|
+
*
|
|
117
|
+
* @param {string|undefined|null} body
|
|
118
|
+
* @returns {{ owner: string, claimedAtMs: number } | null}
|
|
119
|
+
*/
|
|
120
|
+
export function parsePlanLeaseClaim(body) {
|
|
121
|
+
if (typeof body !== 'string') return null;
|
|
122
|
+
const match = body.match(/```json\s*\n([\s\S]*?)\n\s*```/);
|
|
123
|
+
if (!match) return null;
|
|
124
|
+
let record;
|
|
125
|
+
try {
|
|
126
|
+
record = JSON.parse(match[1]);
|
|
127
|
+
} catch (_err) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (!record || record.kind !== PLAN_LEASE_COMMENT_TYPE) return null;
|
|
131
|
+
const owner =
|
|
132
|
+
typeof record.owner === 'string' && record.owner.length > 0
|
|
133
|
+
? record.owner
|
|
134
|
+
: null;
|
|
135
|
+
const claimedAtMs = Date.parse(record.claimedAt ?? '');
|
|
136
|
+
if (owner === null || !Number.isFinite(claimedAtMs)) return null;
|
|
137
|
+
return { owner, claimedAtMs };
|
|
67
138
|
}
|
|
68
139
|
|
|
69
140
|
/**
|
|
70
141
|
* Acquire the Epic-lease before Phase 7.
|
|
71
142
|
*
|
|
72
|
-
* **
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
143
|
+
* **Claim-time liveness (Story #4019, superseding the audit-#3513
|
|
144
|
+
* fail-closed anchor).** `/plan` emits no `story.heartbeat`, so the
|
|
145
|
+
* old guard treated EVERY foreign assignee as live — which made the
|
|
146
|
+
* documented "`--steal` once you have confirmed the other run is dead"
|
|
147
|
+
* contract undecidable (there was no in-band liveness signal to confirm
|
|
148
|
+
* against). The lease now records its own claim-time: on every successful
|
|
149
|
+
* acquire the guard upserts a `plan-lease` structured comment on the Epic
|
|
150
|
+
* carrying `{ owner, claimedAt }`. A subsequent run judges a foreign
|
|
151
|
+
* claim's liveness from that claim-time against the lease TTL
|
|
152
|
+
* (`resolveLeaseTtlMs`):
|
|
153
|
+
*
|
|
154
|
+
* - **Fresh foreign claim** (claim-time within TTL) → refuse, naming the
|
|
155
|
+
* owner and the claim age; `--steal` force-transfers.
|
|
156
|
+
* - **Stale foreign claim** (claim-time older than TTL) → reclaim
|
|
157
|
+
* automatically.
|
|
158
|
+
* - **No claim-time record** (foreign assignee but no readable
|
|
159
|
+
* `plan-lease` comment, or the comment names a different owner) →
|
|
160
|
+
* treated as stale and reclaimed — the assignee predates this
|
|
161
|
+
* mechanism or was set out-of-band, so there is nothing to wait on.
|
|
162
|
+
*
|
|
163
|
+
* An unassigned Epic (`unclaimed`) or a self-held claim (`already-held`)
|
|
164
|
+
* proceeds; both refresh the claim-time record.
|
|
81
165
|
*
|
|
82
166
|
* A refused claim throws (caught at the CLI boundary → exit non-zero).
|
|
83
167
|
*
|
|
@@ -85,7 +169,7 @@ export function resolveOperator(config) {
|
|
|
85
169
|
* @param {import('../ITicketingProvider.js').ITicketingProvider} args.provider
|
|
86
170
|
* @param {number} args.epicId
|
|
87
171
|
* @param {object} [args.config]
|
|
88
|
-
* @param {boolean} [args.steal=false] Force-transfer a foreign claim.
|
|
172
|
+
* @param {boolean} [args.steal=false] Force-transfer a live foreign claim.
|
|
89
173
|
* @param {number} [args.now] Injectable clock (epoch ms; tests).
|
|
90
174
|
* @returns {Promise<{ acquired: boolean, owner: string|null, previousOwner: string|null, reason: string }>}
|
|
91
175
|
*/
|
|
@@ -102,37 +186,88 @@ export async function acquireEpicPlanLease({
|
|
|
102
186
|
`[epic-plan] Refusing to plan Epic #${epicId}: no operator identity is ` +
|
|
103
187
|
'configured. github.operatorHandle is unset or still the shipped ' +
|
|
104
188
|
'`@[USERNAME]` placeholder, so the Epic-lease has no owner and ' +
|
|
105
|
-
'concurrent /
|
|
189
|
+
'concurrent /plan runs cannot be serialised. Set your own handle ' +
|
|
106
190
|
'in .agentrc.local.json (e.g. { "github": { "operatorHandle": ' +
|
|
107
191
|
'"@your-login" } }) and re-run.',
|
|
108
192
|
);
|
|
109
193
|
}
|
|
110
194
|
|
|
111
|
-
// Fail closed: with no live-heartbeat source on the plan path, treat any
|
|
112
|
-
// foreign assignee as a live claim by anchoring `heartbeatAt` to the same
|
|
113
|
-
// `now` the primitive evaluates against (`isClaimLive` → true for any owner).
|
|
114
|
-
// `acquireLease` then refuses a foreign claim unless `steal` is set; an
|
|
115
|
-
// unassigned or self-held Epic proceeds without a write.
|
|
116
195
|
const resolvedNow =
|
|
117
196
|
typeof now === 'number' && Number.isFinite(now) ? now : Date.now();
|
|
118
|
-
const
|
|
197
|
+
const ttlMs = resolveLeaseTtlMs(config);
|
|
198
|
+
|
|
199
|
+
// Resolve the current assignee and the recorded claim-time. The
|
|
200
|
+
// claim-time only counts when the `plan-lease` record names the same
|
|
201
|
+
// owner as the assignee — a mismatched or missing record means the claim
|
|
202
|
+
// has no liveness signal and is treated as stale (reclaimable).
|
|
203
|
+
const ticket = await provider.getTicket(epicId);
|
|
204
|
+
const owner = currentOwner(ticket?.assignees);
|
|
205
|
+
let heartbeatAt = null;
|
|
206
|
+
if (owner !== null && owner !== operator) {
|
|
207
|
+
let claim = null;
|
|
208
|
+
try {
|
|
209
|
+
const comment = await findStructuredComment(
|
|
210
|
+
provider,
|
|
211
|
+
epicId,
|
|
212
|
+
PLAN_LEASE_COMMENT_TYPE,
|
|
213
|
+
);
|
|
214
|
+
claim = comment ? parsePlanLeaseClaim(comment.body) : null;
|
|
215
|
+
} catch (err) {
|
|
216
|
+
Logger.warn(
|
|
217
|
+
`[epic-plan] Could not read plan-lease claim record on #${epicId} ` +
|
|
218
|
+
`(treating foreign claim as stale): ${err.message}`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
if (claim && claim.owner === owner) {
|
|
222
|
+
heartbeatAt = claim.claimedAtMs;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const result = await acquireLeaseFailClosed({
|
|
119
227
|
provider,
|
|
120
228
|
ticketId: epicId,
|
|
121
229
|
operator,
|
|
122
|
-
heartbeatAt
|
|
230
|
+
heartbeatAt,
|
|
123
231
|
steal,
|
|
124
232
|
config,
|
|
125
233
|
now: resolvedNow,
|
|
234
|
+
renderRefusal: (refused) => {
|
|
235
|
+
const ageMinutes =
|
|
236
|
+
heartbeatAt !== null
|
|
237
|
+
? Math.round((resolvedNow - heartbeatAt) / 60000)
|
|
238
|
+
: null;
|
|
239
|
+
const ageNote =
|
|
240
|
+
ageMinutes !== null
|
|
241
|
+
? `Its plan-lease claim is ~${ageMinutes} minute(s) old (TTL ${Math.round(ttlMs / 60000)} minute(s)), so the run is presumed live. `
|
|
242
|
+
: '';
|
|
243
|
+
return (
|
|
244
|
+
`[epic-plan] Epic #${epicId} is currently claimed by '${refused.owner}'. ` +
|
|
245
|
+
`Refusing to plan concurrently — another /plan run owns this Epic. ` +
|
|
246
|
+
`${ageNote}Wait for that run to finish (the claim auto-expires at the ` +
|
|
247
|
+
`lease TTL), or re-run with --steal to forcibly transfer the claim.`
|
|
248
|
+
);
|
|
249
|
+
},
|
|
126
250
|
});
|
|
127
251
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
252
|
+
// Record (or refresh) the claim-time so the next run can judge this
|
|
253
|
+
// claim's liveness. Best-effort: a comment failure degrades to a
|
|
254
|
+
// record-less claim (which a later run treats as stale) — it never
|
|
255
|
+
// fails the plan.
|
|
256
|
+
try {
|
|
257
|
+
await upsertStructuredComment(
|
|
258
|
+
provider,
|
|
259
|
+
epicId,
|
|
260
|
+
PLAN_LEASE_COMMENT_TYPE,
|
|
261
|
+
buildPlanLeaseCommentBody({
|
|
262
|
+
epicId,
|
|
263
|
+
owner: operator,
|
|
264
|
+
claimedAt: new Date(resolvedNow).toISOString(),
|
|
265
|
+
}),
|
|
266
|
+
);
|
|
267
|
+
} catch (err) {
|
|
268
|
+
Logger.warn(
|
|
269
|
+
`[epic-plan] Failed to record plan-lease claim-time on #${epicId} ` +
|
|
270
|
+
`(non-fatal; a later run will treat this claim as stale): ${err.message}`,
|
|
136
271
|
);
|
|
137
272
|
}
|
|
138
273
|
|
|
@@ -206,10 +341,14 @@ export async function assertNoOpenPlanChildren({
|
|
|
206
341
|
const openChildren = (children ?? []).filter((t) => {
|
|
207
342
|
const labels = Array.isArray(t.labels) ? t.labels : [];
|
|
208
343
|
const isOpen = t.state === undefined || t.state === 'open';
|
|
344
|
+
// Any open typed plan ticket counts — `type::story` plus pre-v4
|
|
345
|
+
// `type::feature` leftovers. The prefix check is legacy-data
|
|
346
|
+
// detection, not compat support: the guard only refuses, it never
|
|
347
|
+
// processes the legacy tier. Context tickets (`context::*`) are
|
|
348
|
+
// untouched.
|
|
209
349
|
return (
|
|
210
350
|
isOpen &&
|
|
211
|
-
|
|
212
|
-
labels.includes(TYPE_LABELS.STORY))
|
|
351
|
+
labels.some((l) => typeof l === 'string' && l.startsWith('type::'))
|
|
213
352
|
);
|
|
214
353
|
});
|
|
215
354
|
|
|
@@ -222,12 +361,21 @@ export async function assertNoOpenPlanChildren({
|
|
|
222
361
|
openChildren.length > 10
|
|
223
362
|
? `\n …and ${openChildren.length - 10} more`
|
|
224
363
|
: '';
|
|
364
|
+
const legacyCount = openChildren.filter(
|
|
365
|
+
(t) => !(t.labels ?? []).includes(TYPE_LABELS.STORY),
|
|
366
|
+
).length;
|
|
367
|
+
const legacyHint =
|
|
368
|
+
legacyCount > 0
|
|
369
|
+
? `\n${legacyCount} of these are not type::story — they look like ` +
|
|
370
|
+
`legacy pre-v4 Feature tickets; migrate or close them per the ` +
|
|
371
|
+
`v1.60.0 migration notes before re-planning.`
|
|
372
|
+
: '';
|
|
225
373
|
throw new Error(
|
|
226
374
|
`[epic-plan-decompose] Epic #${epicId} already has ` +
|
|
227
|
-
`${openChildren.length} open
|
|
375
|
+
`${openChildren.length} open plan child ticket(s):\n${summary}${more}\n\n` +
|
|
228
376
|
`Persisting now would duplicate the breakdown. Re-run with --force to ` +
|
|
229
377
|
`close the existing tree and re-decompose, or close the stale children ` +
|
|
230
|
-
`by hand first
|
|
378
|
+
`by hand first.${legacyHint}`,
|
|
231
379
|
);
|
|
232
380
|
}
|
|
233
381
|
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import path from 'node:path';
|
|
11
|
-
import { PROJECT_ROOT } from '../../../config-resolver.js';
|
|
12
11
|
import * as gitUtils from '../../../git-utils.js';
|
|
12
|
+
import { PROJECT_ROOT } from '../../../project-root.js';
|
|
13
13
|
import { forceDrainPendingCleanup } from '../../../worktree/lifecycle/force-drain.js';
|
|
14
14
|
import { readManifest } from '../../../worktree/lifecycle/pending-cleanup.js';
|
|
15
15
|
import { sweepStaleStoryWorktrees } from '../../plan-runner/worktree-sweep.js';
|
|
@@ -78,7 +78,7 @@ export async function overwriteContextTicket(
|
|
|
78
78
|
try {
|
|
79
79
|
await provider.postComment(ticketId, {
|
|
80
80
|
type: 'notification',
|
|
81
|
-
body: `♻️ **Regeneration Audit**: This ${artifact} body was regenerated in place by a \`/
|
|
81
|
+
body: `♻️ **Regeneration Audit**: This ${artifact} body was regenerated in place by a \`/plan --force\` re-plan. The issue number and prior discussion history are preserved.`,
|
|
82
82
|
});
|
|
83
83
|
} catch (_err) {
|
|
84
84
|
// Audit comment is best-effort — never fail the overwrite on a comment
|
|
@@ -321,7 +321,13 @@ export async function planEpic(
|
|
|
321
321
|
Logger.warn(
|
|
322
322
|
`[Epic Planner] Epic #${epicId} already has all requested planning artifacts. Aborting to prevent duplicates. Use --force to re-plan.`,
|
|
323
323
|
);
|
|
324
|
-
return
|
|
324
|
+
return {
|
|
325
|
+
persisted: false,
|
|
326
|
+
reason: 'already-planned',
|
|
327
|
+
prdId: existing.prd,
|
|
328
|
+
techSpecId: existing.techSpec,
|
|
329
|
+
acceptanceSpecId: existing.acceptanceSpec,
|
|
330
|
+
};
|
|
325
331
|
}
|
|
326
332
|
// Under --force we now OVERWRITE the canonical context tickets in place
|
|
327
333
|
// (same issue numbers, refreshed bodies) rather than closing + recreating
|
|
@@ -388,8 +394,18 @@ export async function planEpic(
|
|
|
388
394
|
if (acceptanceSpecId !== null) {
|
|
389
395
|
artifactLines.push(`- [ ] Acceptance Spec: #${acceptanceSpecId}`);
|
|
390
396
|
}
|
|
397
|
+
// Idempotent append (Story #4019): strip any pre-existing
|
|
398
|
+
// `## Planning Artifacts` section before re-appending. The `--force`
|
|
399
|
+
// path already stripped it in `healAndCleanupArtifacts`, but the
|
|
400
|
+
// partial-recovery rerun (e.g. PRD present, Tech Spec missing) reaches
|
|
401
|
+
// here with a body that may still carry a stale section — without the
|
|
402
|
+
// strip, every rerun stacked a duplicate section onto the Epic body.
|
|
391
403
|
const appendBody = `\n\n## Planning Artifacts\n${artifactLines.join('\n')}\n`;
|
|
392
|
-
const
|
|
404
|
+
const strippedBody = epic.body.replace(
|
|
405
|
+
/\n*## Planning Artifacts[\s\S]*$/,
|
|
406
|
+
'',
|
|
407
|
+
);
|
|
408
|
+
const newBody = strippedBody + appendBody;
|
|
393
409
|
|
|
394
410
|
/** @type {{ add?: string[], remove?: string[] }} */
|
|
395
411
|
const labelMutations = {};
|
|
@@ -411,4 +427,12 @@ export async function planEpic(
|
|
|
411
427
|
|
|
412
428
|
Logger.info(`[Epic Planner] Epic #${epicId} updated successfully.`);
|
|
413
429
|
Logger.info(`[Epic Planner] Planning pipeline complete!`);
|
|
430
|
+
|
|
431
|
+
return {
|
|
432
|
+
persisted: true,
|
|
433
|
+
reason: force ? 'force-replan' : 'persisted',
|
|
434
|
+
prdId,
|
|
435
|
+
techSpecId,
|
|
436
|
+
acceptanceSpecId,
|
|
437
|
+
};
|
|
414
438
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* phases/prompts.js — Canonical PRD / Tech Spec / Acceptance Spec system
|
|
3
|
-
* prompts for the spec phase of `/
|
|
3
|
+
* prompts for the spec phase of `/plan`.
|
|
4
4
|
*
|
|
5
5
|
* These ride along on the `--emit-context` envelope as a backstop. The
|
|
6
6
|
* `epic-plan-spec-author` Skill
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import { PROJECT_ROOT } from '../../../config-resolver.js';
|
|
11
10
|
import { Logger } from '../../../Logger.js';
|
|
12
11
|
import { AGENT_LABELS, TYPE_LABELS } from '../../../label-constants.js';
|
|
13
12
|
import { cleanupPhaseTempFiles } from '../../../plan-phase-cleanup.js';
|
|
13
|
+
import { PROJECT_ROOT } from '../../../project-root.js';
|
|
14
14
|
import { acquireEpicPlanLease } from '../../epic-plan-lease-guard.js';
|
|
15
15
|
import {
|
|
16
16
|
initialize as initializePlanState,
|
|
@@ -112,14 +112,14 @@ export async function runSpecPhase(
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// Workflow-guards (Story #3481): acquire the Epic-lease before any Phase 7
|
|
115
|
-
// mutation so two concurrent /
|
|
115
|
+
// mutation so two concurrent /plan runs cannot both drive this Epic. The
|
|
116
116
|
// guard fails closed (audit #3513) — any foreign assignee refuses here and
|
|
117
117
|
// the CLI exits non-zero naming the owner, unless `--steal` transfers it.
|
|
118
118
|
await acquireEpicPlanLease({ provider, epicId, config, steal });
|
|
119
119
|
|
|
120
120
|
await initializePlanState({ provider, epicId });
|
|
121
121
|
|
|
122
|
-
await planEpic(
|
|
122
|
+
const planResult = await planEpic(
|
|
123
123
|
epicId,
|
|
124
124
|
provider,
|
|
125
125
|
{ prdContent, techSpecContent, acceptanceSpecContent },
|
|
@@ -129,6 +129,7 @@ export async function runSpecPhase(
|
|
|
129
129
|
planningRisk,
|
|
130
130
|
},
|
|
131
131
|
);
|
|
132
|
+
const specChanged = planResult?.persisted !== false;
|
|
132
133
|
|
|
133
134
|
const afterPlan = await provider.getEpic(epicId);
|
|
134
135
|
const prdId = afterPlan.linkedIssues?.prd ?? null;
|
|
@@ -157,7 +158,7 @@ export async function runSpecPhase(
|
|
|
157
158
|
// Story #1585 (Epic #1471): the baseline-snapshot fork was previously
|
|
158
159
|
// performed here at plan-time. It now runs at first-story-init time
|
|
159
160
|
// inside `lib/story-init/branch-initializer.js#bootstrapWorktree` so
|
|
160
|
-
// `/
|
|
161
|
+
// `/plan` remains git-state-free. `forkAndCommitEpicSnapshot` and
|
|
161
162
|
// `forkMainToEpic` remain exported for that caller.
|
|
162
163
|
|
|
163
164
|
const reviewRouting = resolveReviewRouting({ planningRisk, forceReview });
|
|
@@ -199,10 +200,27 @@ export async function runSpecPhase(
|
|
|
199
200
|
Logger.info(`[epic-plan-spec] Review routing: ${reviewRouting.decision}.`);
|
|
200
201
|
Logger.info(`[epic-plan-spec] ${reviewRouting.operatorMessage}`);
|
|
201
202
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
// Story #4019 (refining #3905): a spec-phase rerun that changed nothing
|
|
204
|
+
// (planEpic short-circuited on `already-planned`) MUST NOT demote a
|
|
205
|
+
// fully-decomposed `agent::ready` Epic back to `agent::review-spec` —
|
|
206
|
+
// there is no new spec content to review. The demotion fires only when
|
|
207
|
+
// the spec actually persisted/changed, or when the Epic is not at
|
|
208
|
+
// `agent::ready` (where the flip is the normal forward transition).
|
|
209
|
+
const epicLabels = afterPlan.labels ?? [];
|
|
210
|
+
const skipDemotion = !specChanged && epicLabels.includes(AGENT_LABELS.READY);
|
|
211
|
+
let labelTransition;
|
|
212
|
+
if (skipDemotion) {
|
|
213
|
+
labelTransition = 'kept-ready';
|
|
214
|
+
Logger.info(
|
|
215
|
+
`[epic-plan-spec] Spec unchanged (${planResult?.reason ?? 'already-planned'}) and Epic #${epicId} is ${AGENT_LABELS.READY} — keeping ${AGENT_LABELS.READY} (no demotion to ${AGENT_LABELS.REVIEW_SPEC}).`,
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
labelTransition = 'review-spec';
|
|
219
|
+
Logger.info(
|
|
220
|
+
`[epic-plan-spec] Flipping Epic #${epicId} to ${AGENT_LABELS.REVIEW_SPEC}...`,
|
|
221
|
+
);
|
|
222
|
+
await setEpicLabel(provider, epicId, AGENT_LABELS.REVIEW_SPEC);
|
|
223
|
+
}
|
|
206
224
|
|
|
207
225
|
const cleanup = await cleanupPhaseTempFiles({ phase: 'spec', epicId });
|
|
208
226
|
|
|
@@ -231,5 +249,7 @@ export async function runSpecPhase(
|
|
|
231
249
|
freshness,
|
|
232
250
|
planningRisk,
|
|
233
251
|
reviewRouting,
|
|
252
|
+
specChanged,
|
|
253
|
+
labelTransition,
|
|
234
254
|
};
|
|
235
255
|
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* the lifecycle phase is already authoritative on the Epic's `agent::*` labels,
|
|
31
31
|
* so the duplicate `phase` telemetry (and its `setPhase` round-trips) was
|
|
32
32
|
* deleted. The fields that survive — `spec`, `decompose`, `planningRisk`,
|
|
33
|
-
* `reviewRouting`, `manifestCommentId` — are the ones `/
|
|
33
|
+
* `reviewRouting`, `manifestCommentId` — are the ones `/plan --resume`
|
|
34
34
|
* reads to skip already-completed work.
|
|
35
35
|
*/
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* epic-run-state-store — stateless functions for reading and writing the
|
|
3
|
-
* `epic-run-state` structured comment used by `/
|
|
3
|
+
* `epic-run-state` structured comment used by `/deliver`.
|
|
4
4
|
*
|
|
5
5
|
* This module is the function-based replacement for the legacy
|
|
6
6
|
* `Checkpointer` class that previously lived at
|
|
@@ -133,7 +133,7 @@ export async function initialize({
|
|
|
133
133
|
* Reconcile the resume pointer (`currentWave` + `waves[]` history) against
|
|
134
134
|
* a freshly-recomputed wave plan.
|
|
135
135
|
*
|
|
136
|
-
* Story #3358 — when `/
|
|
136
|
+
* Story #3358 — when `/deliver` is resumed on a partially-complete
|
|
137
137
|
* Epic, `epic-deliver-prepare.js` recomputes the wave DAG over only the
|
|
138
138
|
* **not-done** Stories (`build-wave-dag.js#discoverOpenStories` drops the
|
|
139
139
|
* closed/merged Stories). The recomputed plan is therefore *shorter* and
|
|
@@ -270,7 +270,7 @@ export async function appendIntervention({ provider, epicId, entry } = {}) {
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
* Advance the checkpoint's `phase` field to the next `/
|
|
273
|
+
* Advance the checkpoint's `phase` field to the next `/deliver`
|
|
274
274
|
* phase. Reads the current state first so the caller does not need to
|
|
275
275
|
* keep an in-memory copy. Other state fields are preserved verbatim.
|
|
276
276
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cross-Story conflict-finding gate for `epic-deliver-prepare.js`.
|
|
3
3
|
*
|
|
4
|
-
* Story #2297 — when the bounded `/
|
|
4
|
+
* Story #2297 — when the bounded `/plan` flow emitted concurrency
|
|
5
5
|
* findings (Story #2296's validator pass), the operator may have shipped
|
|
6
|
-
* them through to `/
|
|
7
|
-
* `depends_on` gaps. This gate runs at Phase 1 of `/
|
|
6
|
+
* them through to `/deliver` without resolving the underlying
|
|
7
|
+
* `depends_on` gaps. This gate runs at Phase 1 of `/deliver` and
|
|
8
8
|
* refuses to flip the Epic to `agent::executing` when the upcoming
|
|
9
9
|
* waves still contain unresolved conflicts — surfacing the exact
|
|
10
10
|
* remediation commands the operator should run before retrying.
|
|
@@ -138,7 +138,7 @@ export function renderGateErrorMessage(findings, ownerRepo) {
|
|
|
138
138
|
lines.push('');
|
|
139
139
|
}
|
|
140
140
|
lines.push(
|
|
141
|
-
'Resolve the listed conflicts and re-run `/
|
|
141
|
+
'Resolve the listed conflicts and re-run `/deliver`, or pass `--ignore-concurrency-hazards` to bypass this gate.',
|
|
142
142
|
);
|
|
143
143
|
return lines.join('\n');
|
|
144
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* deliver-phases.js — phase enum and ordering utility for `/
|
|
2
|
+
* deliver-phases.js — phase enum and ordering utility for `/deliver`.
|
|
3
3
|
*
|
|
4
4
|
* Story #1155 (Epic #1142, 5.40.0). Originally extracted from the
|
|
5
5
|
* legacy class-based checkpoint module so the phase enum and close-tail
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Ordered list of `/
|
|
14
|
+
* Ordered list of `/deliver` phases. The checkpoint's `phase` field
|
|
15
15
|
* stores the **next phase to run**, so a mid-flight crash during
|
|
16
16
|
* `code-review` resumes by reading `phase === 'code-review'` and re-
|
|
17
17
|
* entering Phase D from the start.
|
|
@@ -44,7 +44,7 @@ export function assertValidDeliverPhase(nextPhase) {
|
|
|
44
44
|
if (nextPhase === 'done') return;
|
|
45
45
|
if (phaseIndex(nextPhase) >= 0) return;
|
|
46
46
|
throw new Error(
|
|
47
|
-
`Invalid /
|
|
47
|
+
`Invalid /deliver phase ${JSON.stringify(nextPhase)}. ` +
|
|
48
48
|
`Expected one of ${DELIVER_PHASES.join(', ')} or 'done'.`,
|
|
49
49
|
);
|
|
50
50
|
}
|