@opengsd/gsd-core 1.12.0 → 1.13.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.opencode/plugins/gsd-core.js +12 -0
- package/agents/gsd-executor.md +63 -35
- package/agents/gsd-plan-checker.md +76 -57
- package/agents/gsd-planner.md +14 -0
- package/agents/gsd-ui-checker.md +19 -3
- package/agents/gsd-ui-researcher.md +29 -0
- package/agents/gsd-verifier.md +23 -1
- package/bin/install.js +239 -67
- package/commands/gsd/execute-phase.md +1 -1
- package/commands/gsd/ns-workflow.md +2 -1
- package/commands/gsd/phase.md +1 -1
- package/commands/gsd/quick-batch.md +105 -0
- package/commands/gsd/surface.md +18 -8
- package/gsd-core/bin/gsd-tools.cjs +195 -50
- package/gsd-core/bin/lib/capability-activation.cjs +27 -0
- package/gsd-core/bin/lib/capability-registry.cjs +514 -114
- package/gsd-core/bin/lib/capability-state.cjs +7 -1
- package/gsd-core/bin/lib/capability-validator.cjs +120 -4
- package/gsd-core/bin/lib/capability-writer.cjs +14 -4
- package/gsd-core/bin/lib/check-command-router.cjs +85 -2
- package/gsd-core/bin/lib/claude-orchestration.cjs +10 -25
- package/gsd-core/bin/lib/clusters.cjs +1 -0
- package/gsd-core/bin/lib/command-aliases.cjs +16 -0
- package/gsd-core/bin/lib/commands.cjs +337 -13
- package/gsd-core/bin/lib/config-loader.cjs +3 -0
- package/gsd-core/bin/lib/core-utils.cjs +34 -7
- package/gsd-core/bin/lib/decisions.cjs +213 -1
- package/gsd-core/bin/lib/edge-probe.cjs +14 -1
- package/gsd-core/bin/lib/file-overlap-partitioner.cjs +74 -0
- package/gsd-core/bin/lib/frontmatter.cjs +137 -23
- package/gsd-core/bin/lib/gap-checker.cjs +22 -13
- package/gsd-core/bin/lib/git-base-branch.cjs +10 -2
- package/gsd-core/bin/lib/health-diagnostic-rules/phase-structure.cjs +8 -2
- package/gsd-core/bin/lib/health-diagnostic-rules/roadmap-disk-consistency.cjs +54 -11
- package/gsd-core/bin/lib/health-diagnostic-rules/state-consistency.cjs +75 -22
- package/gsd-core/bin/lib/host-integration.cjs +57 -5
- package/gsd-core/bin/lib/init-command-router.cjs +14 -0
- package/gsd-core/bin/lib/init.cjs +132 -15
- package/gsd-core/bin/lib/install-engine.cjs +184 -12
- package/gsd-core/bin/lib/install-model-override-resolver.cjs +45 -0
- package/gsd-core/bin/lib/install-profiles.cjs +22 -14
- package/gsd-core/bin/lib/installer-migration-report.cjs +1 -0
- package/gsd-core/bin/lib/io.cjs +35 -0
- package/gsd-core/bin/lib/loop-resolver.cjs +14 -8
- package/gsd-core/bin/lib/markdown-table.cjs +123 -0
- package/gsd-core/bin/lib/milestone.cjs +22 -2
- package/gsd-core/bin/lib/phase-command-router.cjs +13 -6
- package/gsd-core/bin/lib/phase-id.cjs +251 -9
- package/gsd-core/bin/lib/phase.cjs +774 -35
- package/gsd-core/bin/lib/plan-document.cjs +10 -0
- package/gsd-core/bin/lib/planning-snapshot.cjs +147 -20
- package/gsd-core/bin/lib/planning-workspace.cjs +103 -28
- package/gsd-core/bin/lib/quick-batch-command-router.cjs +285 -0
- package/gsd-core/bin/lib/quick-batch-dispatch.cjs +250 -0
- package/gsd-core/bin/lib/quick-batch.cjs +840 -0
- package/gsd-core/bin/lib/review-lane-descriptor.cjs +53 -5
- package/gsd-core/bin/lib/review-lane-invocation.cjs +73 -1
- package/gsd-core/bin/lib/review-lane-runner.cjs +136 -10
- package/gsd-core/bin/lib/roadmap-parser.cjs +499 -26
- package/gsd-core/bin/lib/roadmap.cjs +187 -58
- package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +233 -33
- package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +16 -17
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +286 -108
- package/gsd-core/bin/lib/runtime-hooks-surface.cjs +215 -43
- package/gsd-core/bin/lib/shell-command-projection.cjs +4 -0
- package/gsd-core/bin/lib/smart-entry.cjs +7 -9
- package/gsd-core/bin/lib/state-document.cjs +30 -5
- package/gsd-core/bin/lib/state-md-schema.cjs +23 -13
- package/gsd-core/bin/lib/state-transition.cjs +333 -44
- package/gsd-core/bin/lib/state.cjs +684 -125
- package/gsd-core/bin/lib/surface.cjs +23 -8
- package/gsd-core/bin/lib/tdd-red-evidence.cjs +133 -0
- package/gsd-core/bin/lib/uat.cjs +1419 -515
- package/gsd-core/bin/lib/update-context.cjs +6 -2
- package/gsd-core/bin/lib/validate.cjs +230 -12
- package/gsd-core/bin/lib/verification-command-router.cjs +2 -1
- package/gsd-core/bin/lib/verification.cjs +273 -12
- package/gsd-core/bin/lib/verify-command-router.cjs +1 -0
- package/gsd-core/bin/lib/verify.cjs +346 -16
- package/gsd-core/bin/lib/workstream-inventory.cjs +20 -2
- package/gsd-core/bin/lib/worktree-safety.cjs +8 -0
- package/gsd-core/bin/shared/config-schema.manifest.json +8 -0
- package/gsd-core/bin/verify-reapply-patches.cjs +70 -3
- package/gsd-core/references/agent-contracts.md +3 -3
- package/gsd-core/references/edge-probe.md +17 -13
- package/gsd-core/references/execute-mvp-tdd.md +18 -16
- package/gsd-core/references/execute-phase-response-language.md +6 -0
- package/gsd-core/references/executor-examples.md +42 -0
- package/gsd-core/references/few-shot-examples/plan-checker.md +15 -15
- package/gsd-core/references/mvp-concepts.md +2 -2
- package/gsd-core/references/plan-checker-examples.md +41 -0
- package/gsd-core/references/planner-antipatterns.md +25 -0
- package/gsd-core/references/planner-chunked.md +5 -1
- package/gsd-core/references/planner-coupling.md +42 -0
- package/gsd-core/references/planner-quick-batch.md +71 -0
- package/gsd-core/references/planner-reviews.md +47 -0
- package/gsd-core/references/planner-revision.md +75 -2
- package/gsd-core/references/planning-config.md +2 -1
- package/gsd-core/references/response-language-directive.md +9 -0
- package/gsd-core/references/revision-loop.md +118 -11
- package/gsd-core/references/tdd.md +14 -9
- package/gsd-core/references/verifier-evidence-gate.md +160 -0
- package/gsd-core/templates/phase-prompt.md +4 -0
- package/gsd-core/templates/verification-report.md +5 -0
- package/gsd-core/workflows/add-backlog.md +2 -0
- package/gsd-core/workflows/add-phase.md +2 -0
- package/gsd-core/workflows/add-tests.md +1 -1
- package/gsd-core/workflows/add-todo.md +1 -1
- package/gsd-core/workflows/ai-integration-phase.md +1 -1
- package/gsd-core/workflows/analyze-dependencies.md +2 -0
- package/gsd-core/workflows/audit-fix.md +2 -0
- package/gsd-core/workflows/audit-milestone.md +2 -0
- package/gsd-core/workflows/audit-uat.md +2 -0
- package/gsd-core/workflows/autonomous.md +2 -0
- package/gsd-core/workflows/check-todos.md +1 -1
- package/gsd-core/workflows/cleanup.md +1 -1
- package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +15 -13
- package/gsd-core/workflows/code-review-fix.md +2 -0
- package/gsd-core/workflows/code-review.md +73 -31
- package/gsd-core/workflows/complete-milestone.md +13 -4
- package/gsd-core/workflows/debug.md +1 -1
- package/gsd-core/workflows/diagnose-issues.md +5 -1
- package/gsd-core/workflows/discuss-phase/modes/advisor.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/all.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/analyze.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/auto.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/batch.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/chain.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/default.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/power.md +2 -0
- package/gsd-core/workflows/discuss-phase/modes/text.md +2 -0
- package/gsd-core/workflows/discuss-phase/templates/context.md +2 -0
- package/gsd-core/workflows/discuss-phase/templates/discussion-log.md +2 -0
- package/gsd-core/workflows/discuss-phase-assumptions.md +1 -1
- package/gsd-core/workflows/discuss-phase-power.md +2 -0
- package/gsd-core/workflows/discuss-phase.md +1 -1
- package/gsd-core/workflows/do.md +43 -13
- package/gsd-core/workflows/docs-update.md +1 -1
- package/gsd-core/workflows/edit-phase.md +2 -0
- package/gsd-core/workflows/eval-review.md +1 -1
- package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +2 -0
- package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +17 -1
- package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +8 -2
- package/gsd-core/workflows/execute-phase/steps/regression-gate-run.md +2 -0
- package/gsd-core/workflows/execute-phase/steps/tdd-applicability-resolution.md +25 -0
- package/gsd-core/workflows/execute-phase/steps/worktree-recovery-policy.md +2 -0
- package/gsd-core/workflows/execute-phase.md +32 -14
- package/gsd-core/workflows/execute-plan.md +8 -8
- package/gsd-core/workflows/explore.md +2 -0
- package/gsd-core/workflows/extract-learnings.md +2 -0
- package/gsd-core/workflows/fast.md +6 -0
- package/gsd-core/workflows/forensics.md +2 -0
- package/gsd-core/workflows/graduation.md +1 -1
- package/gsd-core/workflows/health.md +1 -1
- package/gsd-core/workflows/help/modes/brief.md +2 -0
- package/gsd-core/workflows/help/modes/default.md +2 -0
- package/gsd-core/workflows/help/modes/full.md +12 -0
- package/gsd-core/workflows/help/modes/topic.md +2 -0
- package/gsd-core/workflows/help.md +2 -0
- package/gsd-core/workflows/import.md +3 -3
- package/gsd-core/workflows/inbox.md +1 -1
- package/gsd-core/workflows/ingest-docs.md +1 -1
- package/gsd-core/workflows/insert-phase.md +2 -0
- package/gsd-core/workflows/list-phase-assumptions.md +2 -0
- package/gsd-core/workflows/list-seeds.md +2 -0
- package/gsd-core/workflows/list-workspaces.md +2 -0
- package/gsd-core/workflows/manager.md +3 -3
- package/gsd-core/workflows/map-codebase.md +2 -0
- package/gsd-core/workflows/milestone-summary.md +2 -0
- package/gsd-core/workflows/mvp-phase.md +1 -1
- package/gsd-core/workflows/new-milestone.md +1 -1
- package/gsd-core/workflows/new-project.md +5 -3
- package/gsd-core/workflows/new-workspace.md +1 -1
- package/gsd-core/workflows/next.md +2 -0
- package/gsd-core/workflows/node-repair.md +2 -0
- package/gsd-core/workflows/note.md +2 -0
- package/gsd-core/workflows/onboard.md +1 -1
- package/gsd-core/workflows/pause-work.md +19 -4
- package/gsd-core/workflows/plan-phase/steps/chunked-planning-mode.md +100 -18
- package/gsd-core/workflows/plan-phase/steps/prd-express-path.md +2 -0
- package/gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md +9 -0
- package/gsd-core/workflows/plan-phase.md +130 -12
- package/gsd-core/workflows/plan-review-convergence.md +102 -10
- package/gsd-core/workflows/plant-seed.md +1 -1
- package/gsd-core/workflows/pr-branch.md +11 -3
- package/gsd-core/workflows/profile-user.md +1 -1
- package/gsd-core/workflows/progress/steps/forensic-audit.md +1 -1
- package/gsd-core/workflows/progress.md +25 -3
- package/gsd-core/workflows/quick/steps/plan-checker-loop.md +37 -2
- package/gsd-core/workflows/quick/steps/research-phase.md +3 -3
- package/gsd-core/workflows/quick-batch/steps/batch-init.md +55 -0
- package/gsd-core/workflows/quick-batch/steps/completion.md +65 -0
- package/gsd-core/workflows/quick-batch/steps/merge-wave.md +100 -0
- package/gsd-core/workflows/quick-batch/steps/plan-checker-loop.md +147 -0
- package/gsd-core/workflows/quick-batch/steps/planner-wave.md +158 -0
- package/gsd-core/workflows/quick-batch/steps/research-phase.md +95 -0
- package/gsd-core/workflows/quick-batch/steps/resume-mode.md +49 -0
- package/gsd-core/workflows/quick-batch/steps/verification-wave.md +73 -0
- package/gsd-core/workflows/quick-batch/steps/worktree-dispatch.md +169 -0
- package/gsd-core/workflows/quick-batch.md +203 -0
- package/gsd-core/workflows/quick.md +13 -3
- package/gsd-core/workflows/reapply-patches.md +2 -0
- package/gsd-core/workflows/remove-phase.md +2 -0
- package/gsd-core/workflows/remove-workspace.md +1 -1
- package/gsd-core/workflows/resume-project.md +6 -2
- package/gsd-core/workflows/review.md +215 -10
- package/gsd-core/workflows/scan.md +2 -0
- package/gsd-core/workflows/section-manifest.json +12 -0
- package/gsd-core/workflows/secure-phase.md +1 -1
- package/gsd-core/workflows/session-report.md +2 -0
- package/gsd-core/workflows/settings-advanced.md +2 -0
- package/gsd-core/workflows/settings-integrations.md +9 -8
- package/gsd-core/workflows/settings.md +1 -1
- package/gsd-core/workflows/ship.md +10 -10
- package/gsd-core/workflows/sketch-wrap-up.md +2 -0
- package/gsd-core/workflows/sketch.md +1 -1
- package/gsd-core/workflows/smart-entry.md +1 -1
- package/gsd-core/workflows/spec-phase.md +24 -19
- package/gsd-core/workflows/spike-wrap-up.md +2 -0
- package/gsd-core/workflows/spike.md +1 -1
- package/gsd-core/workflows/stats.md +2 -0
- package/gsd-core/workflows/sync-skills.md +12 -4
- package/gsd-core/workflows/thread.md +2 -0
- package/gsd-core/workflows/transition.md +2 -0
- package/gsd-core/workflows/ui-phase.md +26 -5
- package/gsd-core/workflows/ui-review.md +1 -1
- package/gsd-core/workflows/ultraplan-phase.md +2 -0
- package/gsd-core/workflows/undo.md +1 -1
- package/gsd-core/workflows/update.md +41 -38
- package/gsd-core/workflows/validate-phase.md +1 -1
- package/gsd-core/workflows/verify-work.md +49 -3
- package/hooks/dist/gsd-check-update-worker.js +19 -2
- package/hooks/dist/gsd-context-monitor.js +283 -12
- package/hooks/dist/gsd-node-runner.sh +1 -0
- package/hooks/dist/gsd-prompt-guard.js +30 -5
- package/hooks/dist/gsd-read-guard.js +2 -0
- package/hooks/dist/gsd-read-injection-scanner.js +5 -5
- package/hooks/dist/gsd-secret-read-guard.js +1079 -0
- package/hooks/dist/gsd-statusline.js +7 -3
- package/hooks/dist/gsd-validate-commit.sh +444 -7
- package/hooks/dist/gsd-workflow-guard.js +2 -1
- package/hooks/dist/lib/git-cmd.js +210 -1
- package/hooks/dist/lib/injection-patterns.js +36 -6
- package/hooks/dist/managed-hooks-registry.cjs +1 -0
- package/hooks/gsd-check-update-worker.js +19 -2
- package/hooks/gsd-context-monitor.js +283 -12
- package/hooks/gsd-node-runner.sh +1 -0
- package/hooks/gsd-prompt-guard.js +30 -5
- package/hooks/gsd-read-guard.js +2 -0
- package/hooks/gsd-read-injection-scanner.js +5 -5
- package/hooks/gsd-secret-read-guard.js +1079 -0
- package/hooks/gsd-statusline.js +7 -3
- package/hooks/gsd-validate-commit.sh +444 -7
- package/hooks/gsd-workflow-guard.js +2 -1
- package/hooks/hooks.json +6 -0
- package/hooks/lib/git-cmd.js +210 -1
- package/hooks/lib/injection-patterns.js +36 -6
- package/hooks/managed-hooks-registry.cjs +1 -0
- package/package.json +5 -5
- package/scripts/build-hooks.js +11 -4
- package/scripts/ci-test-scope.cjs +7 -0
- package/scripts/docs-guard-registry.cjs +10 -0
- package/scripts/gen-loop-host-contract.cjs +67 -15
- package/scripts/lib/shellcheck-fetch.cjs +247 -0
- package/scripts/lint-allow-test-rule-refs.allowlist.json +0 -6
- package/scripts/lint-allow-test-rule-refs.effective-ceiling.json +1 -1
- package/scripts/lint-allow-test-rule-refs.unverified-ceiling.json +1 -1
- package/scripts/lint-docs-guard-registration.exempt-baseline.cjs +5 -0
- package/scripts/lint-phase-enumeration-drift.cjs +24 -6
- package/scripts/lint-phase-id-drift.cjs +133 -8
- package/scripts/lint-portable-grep.cjs +176 -0
- package/scripts/lint-response-language-coverage.cjs +524 -0
- package/scripts/lint-test-file-count.allowlist.json +3 -1
- package/scripts/lint-workflow-shellcheck-baseline.json +1027 -0
- package/scripts/lint-workflow-shellcheck.cjs +614 -0
- package/scripts/npm-audit-baseline.cjs +376 -0
- package/scripts/prompt-injection-scan.sh +8 -0
- package/scripts/require-issue-link-policy.cjs +16 -1
- package/skills/gsd-execute-phase/SKILL.md +1 -1
- package/skills/gsd-ns-workflow/SKILL.md +1 -0
- package/skills/gsd-phase/SKILL.md +1 -1
- package/skills/gsd-quick-batch/SKILL.md +105 -0
- package/skills/gsd-surface/SKILL.md +18 -8
- package/vscode/package.json +1 -1
|
@@ -32,10 +32,25 @@ const { phaseMarkdownRegexSource, stripProjectCodePrefix, OPTIONAL_PHASE_TAG_SOU
|
|
|
32
32
|
roadmapPhaseLookupSources, extractPhaseToken, isSentinelPhaseId,
|
|
33
33
|
// #3641: the single-owner heading-intro and digit-token grammar sources —
|
|
34
34
|
// see BRACKET_PHASE_ENTRY_HEADING_RE below.
|
|
35
|
-
PHASE_HEADING_PREFIX_SRC, PHASE_NUMBER_TOKEN_SOURCE,
|
|
35
|
+
PHASE_HEADING_PREFIX_SRC, PHASE_NUMBER_TOKEN_SOURCE, phaseHeadingPrefixSrcFor, PHASE_HEADING_BASELINE,
|
|
36
|
+
// #612: the disk-side milestone filter resolves bracket directories through
|
|
37
|
+
// the owner's gated helpers rather than spelling the grammar a second time.
|
|
38
|
+
phaseTokenMatches,
|
|
39
|
+
// #2761 B1: the version-less bracket milestone boundary (computeSectionEnd /
|
|
40
|
+
// preambleCutoff, below) is built from this single-owner source rather than a
|
|
41
|
+
// re-typed bracket-id literal.
|
|
42
|
+
BRACKET_ID_SRC,
|
|
43
|
+
// #2761 M3: the PINNED bracket milestone intro, owning the pad2 spelling rule
|
|
44
|
+
// as well as the grammar — consumed by the bracket-fallback selector below,
|
|
45
|
+
// which re-typed the project-code class and restated the padding rule.
|
|
46
|
+
bracketMilestoneIntroSrcFor,
|
|
47
|
+
// #2761 B1 (round-2 fix): fold-before-identity for the SAME-MILESTONE
|
|
48
|
+
// continuation check in isBracketMilestoneBoundary, below — the branch's own
|
|
49
|
+
// convention (matches bracketQualifiedKey/isSentinelPhaseId).
|
|
50
|
+
foldBracketId, } = phaseIdModule;
|
|
36
51
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
37
52
|
const planningWorkspace = require("./planning-workspace.cjs");
|
|
38
|
-
const { planningDir } = planningWorkspace;
|
|
53
|
+
const { planningDir, resolvePhaseIdConvention } = planningWorkspace;
|
|
39
54
|
const shell_command_projection_cjs_1 = require("./shell-command-projection.cjs");
|
|
40
55
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
41
56
|
const unusableInputMod = require("./unusable-input.cjs");
|
|
@@ -63,6 +78,21 @@ function isClosedMilestoneHeading(headingText) {
|
|
|
63
78
|
function stripShippedMilestones(content) {
|
|
64
79
|
return (0, markdown_sectionizer_cjs_1.stripTaggedBlocks)(content, 'details');
|
|
65
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* #3982: strip only <details> blocks whose <summary> marks a CLOSED milestone
|
|
83
|
+
* (ARCHIVED/SHIPPED/✅/… without an active marker) — the narrow form of
|
|
84
|
+
* stripShippedMilestones the current-milestone window needs. A blanket strip
|
|
85
|
+
* would delete the ACTIVE milestone's own collapsed blocks (#1341) and
|
|
86
|
+
* reproduce the phase_count: 0 class of #557/#2947.
|
|
87
|
+
*/
|
|
88
|
+
function stripClosedMilestoneDetails(content) {
|
|
89
|
+
return content.replace(/<details\b[^>]*>[\s\S]*?<\/details>/gi, (block) => {
|
|
90
|
+
const summaryMatch = block.match(/<summary[^>]*>([^<]*)<\/summary>/i);
|
|
91
|
+
if (!summaryMatch)
|
|
92
|
+
return block;
|
|
93
|
+
return isClosedMilestoneHeading(summaryMatch[1]) ? '' : block;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
66
96
|
/**
|
|
67
97
|
* #2562: is the milestone `version` marked SHIPPED by the ROADMAP itself?
|
|
68
98
|
*
|
|
@@ -99,6 +129,129 @@ function isMilestoneShippedInRoadmap(content, version) {
|
|
|
99
129
|
}
|
|
100
130
|
return false;
|
|
101
131
|
}
|
|
132
|
+
// #2761 B1: matches a bracket MILESTONE heading's intro (`[GSD.02]`) at the
|
|
133
|
+
// START of a heading's text, capturing the bracket id in group 1. Shared by
|
|
134
|
+
// isBracketMilestoneBoundary below — the ONE recognizer for "is this heading
|
|
135
|
+
// bracket-shaped", so computeSectionEnd and the preambleCutoff scan cannot
|
|
136
|
+
// independently drift on what counts as bracket-shaped (the drift that
|
|
137
|
+
// produced Blocker 3 in the round-2 review).
|
|
138
|
+
const BRACKET_HEADING_INTRO_RE = new RegExp(`^\\[(${BRACKET_ID_SRC})\\]`, 'i');
|
|
139
|
+
// #2761 B2 (round-2 fix, Blocker 2): ADR-612 Decision 1's own discriminator
|
|
140
|
+
// (docs/adr/612-bracket-phase-id-convention.md:56) — "a phase heading is a
|
|
141
|
+
// bracket followed by a digit-then-colon (`[GSD.02] 05:`); a milestone
|
|
142
|
+
// heading is a bracket followed by a name" — is CONTENT, not heading level.
|
|
143
|
+
// The prior `h.level <= 2` level cap broke on a level-3 bracket milestone
|
|
144
|
+
// heading (`### [GSD.02] Foundation`): its own level-3 phase children
|
|
145
|
+
// (`#### [GSD.02] 01: One`) never reached this check at all (excluded
|
|
146
|
+
// upstream by the `h.level > level` sibling-depth filter), but a level-3
|
|
147
|
+
// SIBLING milestone heading (`### [GSD.03] Later`) was ALSO excluded by the
|
|
148
|
+
// level cap, so the section ran to EOF instead of stopping there — trek-e's
|
|
149
|
+
// original #612 defect, reopened on any milestone heading below level 2.
|
|
150
|
+
//
|
|
151
|
+
// Built by interpolating phase-id.cts's single-owner
|
|
152
|
+
// phaseHeadingPrefixSrcFor (the SAME intro grammar getMilestonePhaseFilter's
|
|
153
|
+
// heading counter and extractRetiredPhaseNumbers already compile) plus the
|
|
154
|
+
// digit + optional-tag + colon tail every phase-heading counter in this file
|
|
155
|
+
// already spells (mirrors the `([\w][\w.-]*)(?:\s*\([^)\n]{0,200}\))?\s*:`
|
|
156
|
+
// shape at :nnn below) — not a re-typed grammar. Covers the dotted sub-phase
|
|
157
|
+
// heading form too (`[GSD.02] 05.03:`) via the same `[\w][\w.-]*` token,
|
|
158
|
+
// which admits an embedded `.`.
|
|
159
|
+
const BRACKET_PHASE_TAIL_RE = new RegExp(`^${phaseHeadingPrefixSrcFor(PHASE_HEADING_BASELINE.ANY_BRACKET, 'bracket', false)}[\\w][\\w.-]*(?:\\s*\\([^)\\n]{0,200}\\))?\\s*:`, 'i');
|
|
160
|
+
/**
|
|
161
|
+
* #2761 B1/B2 (round-2 fixes): is `headingText` (hashes STRIPPED — the
|
|
162
|
+
* `tokenizeHeadings` `HeadingToken.text` shape, and the shape the
|
|
163
|
+
* preambleCutoff scan below is made to match) a BRACKET MILESTONE boundary —
|
|
164
|
+
* as opposed to (a) a bracket PHASE heading (at any level, including the
|
|
165
|
+
* dotted sub-phase form), which must never terminate a milestone's own
|
|
166
|
+
* section, or (b) a heading that names the SAME milestone already selected,
|
|
167
|
+
* which is a CONTINUATION of the current milestone's own section (a
|
|
168
|
+
* version-less split like `## [GSD.02] Foundation (Phase Details)`), not the
|
|
169
|
+
* boundary to a DIFFERENT one?
|
|
170
|
+
*
|
|
171
|
+
* `level` is the CANDIDATE heading's own depth (`h.level`), capped at 3 — a
|
|
172
|
+
* depth-SANITY ceiling, not a phase/milestone discriminator (that job is
|
|
173
|
+
* BRACKET_PHASE_TAIL_RE, below). The cap mirrors the bracket-fallback
|
|
174
|
+
* selector's own `#{1,3}` ceiling (this file's SELECTION branch above) and
|
|
175
|
+
* `isMilestoneBounded`'s (`state.cts`) — a bracket-shaped heading deeper than
|
|
176
|
+
* either of those will ever select as a CURRENT milestone is outside the
|
|
177
|
+
* shape this function needs to discriminate at all.
|
|
178
|
+
*
|
|
179
|
+
* `selectedBracketId` is the SELECTED milestone's own bracket id, already
|
|
180
|
+
* case-folded by the caller — `null` when scoping is not bracket-gated, the
|
|
181
|
+
* selected heading is not itself bracket-shaped, or (preambleCutoff) the
|
|
182
|
+
* same-milestone check does not apply at this call site (see its own comment
|
|
183
|
+
* there) — in which case the same-milestone check below simply never fires.
|
|
184
|
+
*/
|
|
185
|
+
function isBracketMilestoneBoundary(headingText, level, selectedBracketId) {
|
|
186
|
+
if (level > 3)
|
|
187
|
+
return false;
|
|
188
|
+
const introMatch = BRACKET_HEADING_INTRO_RE.exec(headingText);
|
|
189
|
+
if (!introMatch)
|
|
190
|
+
return false;
|
|
191
|
+
// #2761 B2: a bracket PHASE heading (`[GSD.02] 05:`, or the dotted
|
|
192
|
+
// sub-phase form `[GSD.02] 05.03:`) is never a milestone boundary,
|
|
193
|
+
// regardless of level.
|
|
194
|
+
if (BRACKET_PHASE_TAIL_RE.test(headingText))
|
|
195
|
+
return false;
|
|
196
|
+
// #2761 B1: fold-before-identity — this branch's own convention
|
|
197
|
+
// (bracketQualifiedKey / isSentinelPhaseId apply the same rule).
|
|
198
|
+
if (selectedBracketId && foldBracketId(introMatch[1]) === selectedBracketId)
|
|
199
|
+
return false;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* #2761 B1 (round-3 fix, Blocker 1 case D; hardened post-round-3; round-4
|
|
204
|
+
* fix: requires a same-id PHASE child, not merely a same-id child): does
|
|
205
|
+
* `headings[index]`'s SUBTREE — every heading strictly deeper than it, up to
|
|
206
|
+
* (not including) the next heading at or above its own level — contain a
|
|
207
|
+
* bracket-shaped, PHASE-TAIL-shaped heading with the SAME id as
|
|
208
|
+
* `headings[index]`'s own?
|
|
209
|
+
*
|
|
210
|
+
* Used ONLY at the preambleCutoff scan below, to distinguish a genuine prior
|
|
211
|
+
* or later sibling milestone — whose subtree contains a real phase heading
|
|
212
|
+
* carrying its bracket id (`## [GSD.01] Setup` / `### [GSD.01] 01: …`)
|
|
213
|
+
* — from an unrelated bracket-shaped PROSE heading sitting above the current
|
|
214
|
+
* milestone's own content. Same-id-ness alone is insufficient: round-4 F1's
|
|
215
|
+
* `[ADR.612] Heading convention` owns `[ADR.612] Examples`, but that child is
|
|
216
|
+
* milestone-shaped, not a digit-colon phase. Reuse `BRACKET_PHASE_TAIL_RE`
|
|
217
|
+
* for the phase-vs-milestone distinction instead of re-deriving it.
|
|
218
|
+
*
|
|
219
|
+
* Scan the whole subtree, not just the immediate child: a genuine milestone
|
|
220
|
+
* may open with `### Notes` before its first matching-id phase. Stopping at
|
|
221
|
+
* that first non-match leaked the prior milestone's qualified phase into the
|
|
222
|
+
* current filter (3/2/67 instead of 2/1/50 in rv2-amend1).
|
|
223
|
+
*
|
|
224
|
+
* A subtree that closes with no same-id phase hit — including a childless
|
|
225
|
+
* heading or one with only milestone-shaped same-id children — degrades to
|
|
226
|
+
* not-a-boundary. That is deliberately over-inclusive: the unmatched text
|
|
227
|
+
* remains in the preamble rather than silently discarding current content.
|
|
228
|
+
*
|
|
229
|
+
* `headings` is the same fence-aware token list the caller iterates; `index`
|
|
230
|
+
* is the candidate's own position in it.
|
|
231
|
+
*/
|
|
232
|
+
function bracketHeadingHasMatchingChild(headings, index) {
|
|
233
|
+
const candidate = headings[index];
|
|
234
|
+
const ownMatch = BRACKET_HEADING_INTRO_RE.exec(candidate.text);
|
|
235
|
+
if (!ownMatch)
|
|
236
|
+
return false;
|
|
237
|
+
const ownId = foldBracketId(ownMatch[1]);
|
|
238
|
+
for (let i = index + 1; i < headings.length; i++) {
|
|
239
|
+
const next = headings[i];
|
|
240
|
+
if (next.level <= candidate.level)
|
|
241
|
+
return false;
|
|
242
|
+
const childMatch = BRACKET_HEADING_INTRO_RE.exec(next.text);
|
|
243
|
+
// #2761 round-4: a same-id child is not enough — it must also be a PHASE
|
|
244
|
+
// (BRACKET_PHASE_TAIL_RE), or an unrelated PROSE heading whose own
|
|
245
|
+
// sub-heading merely happens to share its bracket id (F1: [ADR.612]
|
|
246
|
+
// Heading convention / [ADR.612] Examples) satisfies this rule.
|
|
247
|
+
if (childMatch && foldBracketId(childMatch[1]) === ownId && BRACKET_PHASE_TAIL_RE.test(next.text))
|
|
248
|
+
return true;
|
|
249
|
+
// Not a same-id PHASE match — keep scanning DEEPER into the subtree
|
|
250
|
+
// instead of giving up on this one heading; only a same-or-shallower
|
|
251
|
+
// heading (above) actually closes the subtree.
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
102
255
|
/**
|
|
103
256
|
* #3184 (epic #3180 Phase 2): the sole owner of "where does this milestone
|
|
104
257
|
* heading's section end". Lifted from `currentMilestoneRawRanges`'s prior
|
|
@@ -108,12 +261,12 @@ function isMilestoneShippedInRoadmap(content, version) {
|
|
|
108
261
|
* `getMilestonePhaseFilter`'s versionOverride branch all call this instead of
|
|
109
262
|
* re-deriving it.
|
|
110
263
|
*/
|
|
111
|
-
function computeMilestoneSectionEnd(content, headingText, headingStart) {
|
|
264
|
+
function computeMilestoneSectionEnd(content, headingText, headingStart, additionalBoundary, headingTokens) {
|
|
112
265
|
const level = (headingText.match(/^(#{1,3})\s/) ?? ['', '#'])[1].length;
|
|
113
266
|
const afterHeading = headingStart + headingText.length;
|
|
114
267
|
// Use tokenizeHeadings (fence-aware, offsets into original content) to find
|
|
115
268
|
// the next stop boundary without re-implementing fence detection. T4 seam migration.
|
|
116
|
-
const headings = (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(content);
|
|
269
|
+
const headings = headingTokens ?? (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(content);
|
|
117
270
|
for (const h of headings) {
|
|
118
271
|
if (h.offset <= headingStart)
|
|
119
272
|
continue;
|
|
@@ -124,9 +277,10 @@ function computeMilestoneSectionEnd(content, headingText, headingStart) {
|
|
|
124
277
|
// Mirrors old stopPattern: level-bounded, not a Phase heading, milestone marker
|
|
125
278
|
if (/^Phase\s+\S/i.test(h.text))
|
|
126
279
|
continue;
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
280
|
+
if (/v\d+\.\d+|✅|📋|🚧/i.test(h.text))
|
|
281
|
+
return h.offset;
|
|
282
|
+
if (additionalBoundary?.(h))
|
|
283
|
+
return h.offset;
|
|
130
284
|
}
|
|
131
285
|
return content.length;
|
|
132
286
|
}
|
|
@@ -532,18 +686,35 @@ function collectTablePhaseRows(window) {
|
|
|
532
686
|
* narrower question — "which phase ids does this window declare" — where only
|
|
533
687
|
* the 999 icebox range is excluded.
|
|
534
688
|
*/
|
|
535
|
-
function
|
|
689
|
+
function scanMilestonePhaseIdSets(window, convention) {
|
|
536
690
|
const ids = new Set();
|
|
691
|
+
const qualifiedIds = new Set();
|
|
537
692
|
// Use tokenizeHeadings (fence-aware) instead of stripFencedLines + regex.
|
|
538
693
|
// T4 seam migration: phase headings inside fences are excluded automatically.
|
|
539
694
|
// #1729: `(?:\s*\([^)\n]{0,200}\))?` tolerates a pre-colon ( ) tag (literal mirror of OPTIONAL_PHASE_TAG_SOURCE).
|
|
540
|
-
|
|
695
|
+
// #612: select the heading grammar from the resolved convention and retain
|
|
696
|
+
// the bracket id so the disk-side filter can distinguish equal phase tokens
|
|
697
|
+
// belonging to different milestones.
|
|
698
|
+
const capturing = convention === 'bracket';
|
|
699
|
+
const bracketGroups = capturing ? 1 : 0;
|
|
700
|
+
const phaseHeadingPattern = new RegExp(`^${phaseHeadingPrefixSrcFor(PHASE_HEADING_BASELINE.ANY_BRACKET, convention, capturing)}([\\w][\\w.-]*)(?:\\s*\\([^)\\n]{0,200}\\))?\\s*:`, 'i');
|
|
541
701
|
for (const h of (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(window)) {
|
|
542
702
|
if (h.level < 2 || h.level > 4)
|
|
543
703
|
continue;
|
|
544
704
|
const pm = phaseHeadingPattern.exec(h.text);
|
|
545
|
-
if (pm
|
|
546
|
-
|
|
705
|
+
if (!pm)
|
|
706
|
+
continue;
|
|
707
|
+
const bracketId = bracketGroups ? pm[1] : undefined;
|
|
708
|
+
const token = pm[1 + bracketGroups];
|
|
709
|
+
if (bracketId && isSentinelPhaseId(`${bracketId}-${token}`, 'bracket'))
|
|
710
|
+
continue;
|
|
711
|
+
// This scan's legacy contract excludes only the 999 icebox range. Keep the
|
|
712
|
+
// narrower rule so real decimal phase 00.1 is not swallowed as milestone 0.
|
|
713
|
+
if (/^999\b/.test(token))
|
|
714
|
+
continue;
|
|
715
|
+
ids.add(token);
|
|
716
|
+
if (bracketId && !token.includes('-'))
|
|
717
|
+
qualifiedIds.add(`${bracketId}-${token}`);
|
|
547
718
|
}
|
|
548
719
|
// #2199: also count bullet/checkbox phase entries (`- [ ] **Phase N — name**`)
|
|
549
720
|
// so a bullet-house-style ROADMAP populates the milestone phase set instead of
|
|
@@ -559,7 +730,16 @@ function scanMilestonePhaseIds(window) {
|
|
|
559
730
|
// filter must not collapse a table-house-style window to zero-count.
|
|
560
731
|
for (const tr of collectTablePhaseRows(window))
|
|
561
732
|
ids.add(tr.id);
|
|
562
|
-
return ids;
|
|
733
|
+
return { ids, qualifiedIds };
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Public #3262 owner contract: the declared-id Set remains directly iterable.
|
|
737
|
+
* #612's qualified bracket ids are an internal companion used only by the
|
|
738
|
+
* milestone directory filter, so extending that internal read must not break
|
|
739
|
+
* existing consumers of this exported Set (including #3577's table scan).
|
|
740
|
+
*/
|
|
741
|
+
function scanMilestonePhaseIds(window, convention) {
|
|
742
|
+
return scanMilestonePhaseIdSets(window, convention).ids;
|
|
563
743
|
}
|
|
564
744
|
/**
|
|
565
745
|
* #3262 (write-time milestone-scope guard): does this free-text value contain
|
|
@@ -590,8 +770,26 @@ function scanMilestonePhaseIds(window) {
|
|
|
590
770
|
* Fence-aware via `tokenizeHeadings`: a FENCED example of a milestone heading
|
|
591
771
|
* inside a field value does not terminate the real window, so it must not be
|
|
592
772
|
* a violation either — the parser and this guard must agree on fences.
|
|
773
|
+
*
|
|
774
|
+
* #612: `convention` is the resolved `phase_id_convention`. This predicate is
|
|
775
|
+
* defined as a MIRROR of the parser's terminator vocabulary, and on this
|
|
776
|
+
* branch that vocabulary is convention-SELECTED: `computeBracketSectionEnd`
|
|
777
|
+
* adds `isBracketMilestoneBoundary` as a terminator arm, so the ADR-canonical
|
|
778
|
+
* `## [GSD.09] Hidden` — no version token, no status emoji, not the word
|
|
779
|
+
* "Milestone" — terminates the window on an opted-in bracket repo while
|
|
780
|
+
* matching NONE of the signals above. Left unmirrored, the guard accepts
|
|
781
|
+
* exactly the description that narrows the window on the one convention this
|
|
782
|
+
* branch teaches the parser to read, which is the failure the guard exists to
|
|
783
|
+
* prevent. A non-bracket (or unresolvable) value takes the pre-existing path
|
|
784
|
+
* byte-identically.
|
|
785
|
+
*
|
|
786
|
+
* REQUIRED, not optional — the same tripwire `scanMilestonePhaseIds` carries,
|
|
787
|
+
* and for the sharper reason: a blind call here fails OPEN (the guard quietly
|
|
788
|
+
* ACCEPTS a window-narrowing description) rather than merely miscounting, so a
|
|
789
|
+
* future call site must fail to COMPILE. The census today is one caller,
|
|
790
|
+
* `assertDescriptionPreservesMilestoneScope`, which pays nothing for it.
|
|
593
791
|
*/
|
|
594
|
-
function findMilestoneScopeHeadingLines(text) {
|
|
792
|
+
function findMilestoneScopeHeadingLines(text, convention) {
|
|
595
793
|
const out = [];
|
|
596
794
|
for (const h of (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(text)) {
|
|
597
795
|
if (h.level > 3)
|
|
@@ -600,6 +798,22 @@ function findMilestoneScopeHeadingLines(text) {
|
|
|
600
798
|
continue;
|
|
601
799
|
if (MILESTONE_HEADING_SIGNAL_PATTERN.test(h.text) || /🔄/.test(h.text)) {
|
|
602
800
|
out.push(h.text.trim());
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
// #612: the bracket arm, routed through the SAME single-owner
|
|
804
|
+
// phase-vs-milestone discriminator `computeBracketSectionEnd` consults —
|
|
805
|
+
// never a second bracket-heading grammar here.
|
|
806
|
+
//
|
|
807
|
+
// `selectedBracketId` is deliberately `null`, so the same-milestone
|
|
808
|
+
// CONTINUATION exemption never fires and a value naming the ACTIVE
|
|
809
|
+
// milestone (`## [GSD.02] Foundation (Phase Details)`) is flagged even
|
|
810
|
+
// though the real parser would treat it as a continuation. That is the
|
|
811
|
+
// third instance of this function's stated conservatism and rests on the
|
|
812
|
+
// same argument as the other two: WHICH milestone is active is a property
|
|
813
|
+
// of the document at write time, not of the text being validated, and
|
|
814
|
+
// over-rejecting is one-directional (reject more, never less).
|
|
815
|
+
if (convention === 'bracket' && isBracketMilestoneBoundary(h.text, h.level, null)) {
|
|
816
|
+
out.push(h.text.trim());
|
|
603
817
|
}
|
|
604
818
|
}
|
|
605
819
|
return out;
|
|
@@ -695,7 +909,42 @@ function extractCurrentMilestoneScoped(content, cwd, ws, phaseIdConvention) {
|
|
|
695
909
|
}
|
|
696
910
|
const documentHasPhaseEntries = hasPhaseEntries(stripShippedMilestones(content), phaseIdConvention);
|
|
697
911
|
const summaryPattern = new RegExp(`<summary[^>]*>([^<]*${(0, pattern_cjs_1.escapeRegex)(version)}[^<]*)<\\/summary>`, 'i');
|
|
698
|
-
|
|
912
|
+
// #3184 keeps the version-heading locator single-owned. #612 adds a gated
|
|
913
|
+
// bracket candidate source only when that owner finds no version-bearing
|
|
914
|
+
// heading; it never replaces or re-derives the legacy lookup.
|
|
915
|
+
let headingMatches = locateMilestoneHeadings(content, version);
|
|
916
|
+
// #2761 B3: resolve the boundary convention independently of whether the
|
|
917
|
+
// version-heading owner already selected a match. Preserve an explicitly
|
|
918
|
+
// threaded convention; otherwise resolve from the same workstream whose
|
|
919
|
+
// STATE/ROADMAP this call reads (#2761 B1).
|
|
920
|
+
let bracketScopeConvention = phaseIdConvention ?? null;
|
|
921
|
+
if (phaseIdConvention === undefined) {
|
|
922
|
+
try {
|
|
923
|
+
bracketScopeConvention = resolvePhaseIdConvention(cwd, ws);
|
|
924
|
+
}
|
|
925
|
+
catch { /* unresolvable convention → preserve the legacy fallback */ }
|
|
926
|
+
}
|
|
927
|
+
if (headingMatches.length === 0 && bracketScopeConvention === 'bracket') {
|
|
928
|
+
const vMatch = version.match(/^v(\d+)/i);
|
|
929
|
+
const milestoneInt = vMatch ? parseInt(vMatch[1], 10) : NaN;
|
|
930
|
+
if (Number.isSafeInteger(milestoneInt)) {
|
|
931
|
+
// #2761 M3: the phase-id owner supplies both the bracket intro grammar
|
|
932
|
+
// and canonical pad2 spelling; `[CODE.2]` therefore cannot bound a
|
|
933
|
+
// section whose phase headings the bracket grammar rejects.
|
|
934
|
+
// #612 round-5: HeadingToken.offset is the line start, so require the
|
|
935
|
+
// `#` there to preserve the old line-start anchor's indentation parity.
|
|
936
|
+
// For every survivor, rebuilding [fullLine, fullLine] plus `.index`
|
|
937
|
+
// retains the match shape and first-match order expected downstream.
|
|
938
|
+
const bracketMilestoneHeadingRe = new RegExp(`^${bracketMilestoneIntroSrcFor(milestoneInt)}`, 'i');
|
|
939
|
+
headingMatches = (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(content)
|
|
940
|
+
.filter((h) => h.level <= 3 && content[h.offset] === '#' && bracketMilestoneHeadingRe.test(h.text))
|
|
941
|
+
.map((h) => {
|
|
942
|
+
const lineEnd = content.indexOf('\n', h.offset);
|
|
943
|
+
const fullLine = content.slice(h.offset, lineEnd === -1 ? content.length : lineEnd);
|
|
944
|
+
return Object.assign([fullLine, fullLine], { index: h.offset });
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
}
|
|
699
948
|
if (headingMatches.length === 0) {
|
|
700
949
|
const summaryMatch = content.match(summaryPattern);
|
|
701
950
|
if (summaryMatch) {
|
|
@@ -748,16 +997,174 @@ function extractCurrentMilestoneScoped(content, cwd, ws, phaseIdConvention) {
|
|
|
748
997
|
// #3184: selection collapses to the sole owner; `allMatches` is still needed
|
|
749
998
|
// below (offsets, detailsMatch search), so only the selection itself routes
|
|
750
999
|
// through `selectMilestoneHeading` rather than the whole block.
|
|
751
|
-
|
|
1000
|
+
// Preserve the canonical legacy selector, then fall back to the gated
|
|
1001
|
+
// bracket candidates above when a name-only bracket milestone carries no
|
|
1002
|
+
// version token for that selector to find.
|
|
1003
|
+
const selected = selectMilestoneHeading(content, version)
|
|
1004
|
+
?? allMatches.find((m) => !isClosed(m[1]))
|
|
1005
|
+
?? firstMatch;
|
|
752
1006
|
const sectionStart = selected.index;
|
|
753
|
-
|
|
1007
|
+
// #2761 B1: a bracket heading bearing the selected milestone's own id is
|
|
1008
|
+
// a continuation, not a boundary. Derive the selected id once and compose
|
|
1009
|
+
// the shared discriminator with upstream's centralized section-end walk.
|
|
1010
|
+
const bracketBoundaryActive = bracketScopeConvention === 'bracket';
|
|
1011
|
+
const selectedBracketMatch = bracketBoundaryActive
|
|
1012
|
+
? selected[0].match(new RegExp(`^#{1,3}\\s+\\[(${BRACKET_ID_SRC})\\]`, 'i'))
|
|
1013
|
+
: null;
|
|
1014
|
+
const selectedBracketId = selectedBracketMatch ? foldBracketId(selectedBracketMatch[1]) : null;
|
|
1015
|
+
// #2761 B3: tokenize once for both the centralized section-end owner and
|
|
1016
|
+
// the bracket preamble scan below. This keeps both boundary decisions
|
|
1017
|
+
// fence-aware without restoring the local section walker retired by #3184.
|
|
1018
|
+
const currentMilestoneHeadings = (0, markdown_sectionizer_cjs_1.tokenizeHeadings)(content);
|
|
1019
|
+
const bracketBoundary = bracketBoundaryActive
|
|
1020
|
+
? (heading) => isBracketMilestoneBoundary(heading.text, heading.level, selectedBracketId)
|
|
1021
|
+
: undefined;
|
|
1022
|
+
const sectionEnd = computeMilestoneSectionEnd(content, selected[0], sectionStart, bracketBoundary, currentMilestoneHeadings);
|
|
754
1023
|
const anyMilestonePattern = /^#{1,3}\s+(?!Phase\s+\S)(?:.*v\d+\.\d+|✅|📋|🚧)/im;
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
1024
|
+
let earliestMilestoneIndex;
|
|
1025
|
+
if (!bracketBoundaryActive) {
|
|
1026
|
+
// #2761 B3: the LEGACY (non-bracket-shaped) path stays a raw
|
|
1027
|
+
// `content.match` — byte-identical to before this fix, including its
|
|
1028
|
+
// fence-blindness. That hazard is real (a fenced `## Milestone v9.0`
|
|
1029
|
+
// example in the preamble reads identically wrong at base, round-1, and
|
|
1030
|
+
// HEAD — repro12's LEGACY control) but is PRE-EXISTING and shared with
|
|
1031
|
+
// the ORIGINAL (pre-#612) code path, not introduced by this branch —
|
|
1032
|
+
// fixing it is explicitly out of scope (round-2 review's own
|
|
1033
|
+
// minimal-fix note).
|
|
1034
|
+
const versionMilestoneMatch = content.match(anyMilestonePattern);
|
|
1035
|
+
earliestMilestoneIndex = versionMilestoneMatch ? versionMilestoneMatch.index : null;
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
// #2761 Major 1 (round-3 fix): on the BRACKET branch, derive the
|
|
1039
|
+
// version/emoji half of "earliest milestone-shaped heading" from the
|
|
1040
|
+
// SAME fence-aware `currentMilestoneHeadings` token list too, instead of
|
|
1041
|
+
// the raw `content.match` above. Round-2 (ff6bf0a8) fixed the BRACKET
|
|
1042
|
+
// half's fence-blindness but left THIS half a raw regex even on this
|
|
1043
|
+
// branch: a fenced VERSION-BEARING example heading in a bracket repo's
|
|
1044
|
+
// preamble (`` ```markdown\n## Milestone v9.0: Example\n``` ``, ADR-612's
|
|
1045
|
+
// own docs illustrate the LEGACY heading shape exactly this way) was
|
|
1046
|
+
// still textually the earliest match for the raw regex, winning the old
|
|
1047
|
+
// min() and un-suppressing a wrong persisted 75% that base correctly
|
|
1048
|
+
// suppressed (rv-attack3c fixture C1) — B3 fixed only the half of the
|
|
1049
|
+
// asymmetry it introduced, not this pre-existing half once it also
|
|
1050
|
+
// started reaching the bracket branch. The predicate below (`h.text`
|
|
1051
|
+
// against the same `/^Phase\s+\S/i` / `/v\d+\.\d+|✅|📋|🚧/i` pair
|
|
1052
|
+
// `computeSectionEnd` already uses) never sees a fenced heading at all,
|
|
1053
|
+
// because tokenizeHeadings never produces a token for one.
|
|
1054
|
+
//
|
|
1055
|
+
// Hardened post-round-3: the raw `content.match(anyMilestonePattern)`
|
|
1056
|
+
// this replaced was anchored `^#{1,3}\s+…` — a level cap the token loop
|
|
1057
|
+
// dropped entirely. A level-4+ version-bearing heading in the preamble
|
|
1058
|
+
// (`#### v2.0 notes`) would win this scan where the raw pattern on the
|
|
1059
|
+
// legacy path ignores it outright, cutting the preamble at a heading
|
|
1060
|
+
// neither the selector nor `isMilestoneBounded` would ever treat as a
|
|
1061
|
+
// milestone marker. Mirrors the depth-sanity cap
|
|
1062
|
+
// `isBracketMilestoneBoundary` already applies to the bracket half.
|
|
1063
|
+
earliestMilestoneIndex = null;
|
|
1064
|
+
for (const h of currentMilestoneHeadings) {
|
|
1065
|
+
if (h.level > 3)
|
|
1066
|
+
continue;
|
|
1067
|
+
if (/^Phase\s+\S/i.test(h.text))
|
|
1068
|
+
continue;
|
|
1069
|
+
if (/v\d+\.\d+|✅|📋|🚧/i.test(h.text)) {
|
|
1070
|
+
earliestMilestoneIndex = h.offset;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (bracketBoundaryActive) {
|
|
1076
|
+
// #2761 B3: scans the SAME fence-aware `currentMilestoneHeadings` token
|
|
1077
|
+
// list computeSectionEnd consumes, instead of a raw `content.matchAll` —
|
|
1078
|
+
// closes the asymmetry between the two halves of one boundary semantic.
|
|
1079
|
+
// Before this fix, a fenced markdown example containing a bracket
|
|
1080
|
+
// heading (ADR-612's own docs do exactly this) was textually the
|
|
1081
|
+
// earliest `#{1,3} [CODE.MM]` match, so `preambleCutoff` landed INSIDE
|
|
1082
|
+
// the fence, `preamble` ended with an unclosed opener, and
|
|
1083
|
+
// `getMilestonePhaseFilter`'s tokenizeHeadings(scope) call then saw an
|
|
1084
|
+
// unbalanced fence and swallowed every real heading, degrading to a
|
|
1085
|
+
// pass-all filter (repro11). tokenizeHeadings already strips fenced
|
|
1086
|
+
// lines before a heading candidate is ever produced, so a heading INSIDE
|
|
1087
|
+
// a fence is never a candidate here at all.
|
|
1088
|
+
//
|
|
1089
|
+
// `h.text` is ALREADY hash-stripped and trimmed (HeadingToken's own
|
|
1090
|
+
// shape) — isBracketMilestoneBoundary is built to consume exactly that,
|
|
1091
|
+
// so no `^#{1,3}\s+` re-derivation is needed (that spelling would not
|
|
1092
|
+
// match `h.text` — it still carries the hashes in a raw regex match).
|
|
1093
|
+
for (let i = 0; i < currentMilestoneHeadings.length; i++) {
|
|
1094
|
+
const h = currentMilestoneHeadings[i];
|
|
1095
|
+
let isBoundary;
|
|
1096
|
+
if (h.offset === sectionStart) {
|
|
1097
|
+
// #2761 B1 (round-3 fix): the SELECTED heading's own occurrence is
|
|
1098
|
+
// ALWAYS a correct earliest answer to "where does milestone content
|
|
1099
|
+
// begin" — bypass BOTH the same-milestone check inside
|
|
1100
|
+
// isBracketMilestoneBoundary (which would otherwise reject this
|
|
1101
|
+
// heading against ITSELF, since `selectedBracketId` is its own id)
|
|
1102
|
+
// and the same-id-child rule below (which would reject a genuinely
|
|
1103
|
+
// childless CURRENT milestone, e.g. one with no phases populated
|
|
1104
|
+
// yet). Without this, a same-milestone heading EARLIER than the
|
|
1105
|
+
// selected one (a version-less checklist/overview split, or the
|
|
1106
|
+
// version-bearing heading landing on the LATER half of such a
|
|
1107
|
+
// split — Blocker 1 round-3 cases A/B) would incorrectly win via the
|
|
1108
|
+
// OLD `null`-everywhere behaviour, or (with the same-milestone
|
|
1109
|
+
// check alone reinstated) the selected heading would incorrectly
|
|
1110
|
+
// reject itself and fall through to a stray, unrelated LATER
|
|
1111
|
+
// heading.
|
|
1112
|
+
isBoundary = true;
|
|
1113
|
+
}
|
|
1114
|
+
else if (isBracketMilestoneBoundary(h.text, h.level, selectedBracketId)) {
|
|
1115
|
+
// #2761 B1 (round-3 fix, Blocker 1 case D): bracket-shaped, not
|
|
1116
|
+
// phase-tail-shaped, and not the SAME id as the selected milestone
|
|
1117
|
+
// is not enough — an unrelated bracket-shaped PROSE heading
|
|
1118
|
+
// (`## [ADR.612] Heading convention used by this roadmap`) reads as
|
|
1119
|
+
// a genuine boundary by those rules alone. Require its own next
|
|
1120
|
+
// DEEPER heading to carry ITS bracket id too — the property every
|
|
1121
|
+
// genuine sibling MILESTONE has (its own phase children) and no
|
|
1122
|
+
// unrelated prose heading does.
|
|
1123
|
+
//
|
|
1124
|
+
// #2761 round-4 Minor 1 (docstring correction — no code change): a
|
|
1125
|
+
// heading rejected here (no same-id PHASE child — see
|
|
1126
|
+
// bracketHeadingHasMatchingChild's own comment) leaves its WHOLE
|
|
1127
|
+
// SUBTREE in the preamble, not merely its own inert heading text.
|
|
1128
|
+
// That subtree can still contain a DIFFERENT-id bracket PHASE
|
|
1129
|
+
// heading, which DOES form a qualified key and CAN admit a foreign
|
|
1130
|
+
// directory (F7: `## [GSD.01] Setup` / `### [GSD.07] 01: Foreign` —
|
|
1131
|
+
// no same-id child, so `[GSD.01] Setup` is not a boundary, and
|
|
1132
|
+
// `GSD.07-01-foreign`'s directory is admitted into the CURRENT
|
|
1133
|
+
// milestone's filter, reading 3/2/67%). This is NOT a regression —
|
|
1134
|
+
// base, round-1 and HEAD all read 3/2/67% on F7 (base via its own
|
|
1135
|
+
// pass-all degrade) — and it remains the declared OVER-inclusive,
|
|
1136
|
+
// never under-inclusive, safe direction; it is a narrower and more
|
|
1137
|
+
// honest claim than "contributes nothing to any phase count", which
|
|
1138
|
+
// is true of the candidate's OWN text but not of what its subtree
|
|
1139
|
+
// can carry.
|
|
1140
|
+
isBoundary = bracketHeadingHasMatchingChild(currentMilestoneHeadings, i);
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
isBoundary = false;
|
|
1144
|
+
}
|
|
1145
|
+
if (!isBoundary)
|
|
1146
|
+
continue;
|
|
1147
|
+
if (earliestMilestoneIndex === null || h.offset < earliestMilestoneIndex) {
|
|
1148
|
+
earliestMilestoneIndex = h.offset;
|
|
1149
|
+
}
|
|
1150
|
+
break;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
const preambleCutoff = earliestMilestoneIndex !== null
|
|
1154
|
+
? earliestMilestoneIndex
|
|
758
1155
|
: firstMatch.index;
|
|
759
1156
|
const beforeMilestones = content.slice(0, preambleCutoff);
|
|
760
|
-
|
|
1157
|
+
// #3982: newest-first roadmaps collapse their archives into <details>
|
|
1158
|
+
// blocks BELOW the active milestone, whose titles live in <summary> tags —
|
|
1159
|
+
// not headings — so no milestone-shaped heading bounds the section walk and
|
|
1160
|
+
// the raw slice runs to end-of-document. Strip CLOSED milestone details
|
|
1161
|
+
// blocks here so the window never feeds archived phases to the
|
|
1162
|
+
// lowest-outstanding scan. Deliberately NOT a blanket strip: the active
|
|
1163
|
+
// milestone may legitimately hold its own collapsed <details> (#1341), and
|
|
1164
|
+
// removing that would trade this bug for the phase_count: 0 class (#557).
|
|
1165
|
+
// Gated on the same isClosedMilestoneHeading the file already applies to
|
|
1166
|
+
// <summary> lines, per the issue's prescribed narrower fix.
|
|
1167
|
+
const currentSection = stripClosedMilestoneDetails(content.slice(sectionStart, sectionEnd));
|
|
761
1168
|
// Multi-milestone roadmaps split each added milestone across two version-bearing
|
|
762
1169
|
// headings: a `## Phases` checklist subsection (early) and a dedicated
|
|
763
1170
|
// `## Milestone … (Phase Details)` section (late) holding the `### Phase N:`
|
|
@@ -779,7 +1186,7 @@ function extractCurrentMilestoneScoped(content, cwd, ws, phaseIdConvention) {
|
|
|
779
1186
|
(m.index ?? 0) >= sectionEnd);
|
|
780
1187
|
if (detailsMatch) {
|
|
781
1188
|
const detailsStart = detailsMatch.index ?? 0;
|
|
782
|
-
detailsSection = content.slice(detailsStart, computeMilestoneSectionEnd(content, detailsMatch[0], detailsStart));
|
|
1189
|
+
detailsSection = content.slice(detailsStart, computeMilestoneSectionEnd(content, detailsMatch[0], detailsStart, bracketBoundary, currentMilestoneHeadings));
|
|
783
1190
|
}
|
|
784
1191
|
// #2947: the preamble strip removes `### Phase N:` detail headings from the
|
|
785
1192
|
// pre-milestone region so they don't duplicate the ones inside the selected
|
|
@@ -1305,6 +1712,23 @@ function getMilestoneInfo(cwd) {
|
|
|
1305
1712
|
*/
|
|
1306
1713
|
function getMilestonePhaseFilter(cwd, versionOverride, phaseIdConvention, ws) {
|
|
1307
1714
|
const milestonePhaseNums = new Set();
|
|
1715
|
+
// #612: the milestone-QUALIFIED form (`{CODE}.{MM}-{PP}`) of each in-scope
|
|
1716
|
+
// bracket heading, kept in its OWN set — deliberately not in
|
|
1717
|
+
// milestonePhaseNums. A qualified id ALWAYS contains a hyphen, so putting one
|
|
1718
|
+
// there would flip `roadmapUsesHyphenedIds` below on EVERY bracket repo, which
|
|
1719
|
+
// swaps `numericRe` to the continuation-segment variant and silently moves the
|
|
1720
|
+
// LEGACY dir path. Separate set; `phaseCount` is unchanged.
|
|
1721
|
+
//
|
|
1722
|
+
// Stated exactly, because the narrower claim is the true one: this keeps
|
|
1723
|
+
// QUALIFIED IDS out of that flag's input, not hyphens in general. A heading
|
|
1724
|
+
// whose TOKEN carries its own hyphen (`### [GSD.02] Phase 02-01:`) still flips
|
|
1725
|
+
// it through milestonePhaseNums — as it also does at base, which matches that
|
|
1726
|
+
// spelling through the un-widened intro. See the token-hyphen guard below.
|
|
1727
|
+
const milestoneQualifiedIds = new Set();
|
|
1728
|
+
// Hoisted out of the try so the DIR side can select the same grammar the
|
|
1729
|
+
// HEADING side selected. The two halves of this one filter reading different
|
|
1730
|
+
// conventions is exactly the defect the bracket branch below closes.
|
|
1731
|
+
let headingConvention;
|
|
1308
1732
|
let missingExplicitVersion = false;
|
|
1309
1733
|
let versionScoped = false;
|
|
1310
1734
|
let versionSectionFound = false;
|
|
@@ -1373,12 +1797,21 @@ function getMilestonePhaseFilter(cwd, versionOverride, phaseIdConvention, ws) {
|
|
|
1373
1797
|
documentHasPhaseEntries,
|
|
1374
1798
|
});
|
|
1375
1799
|
}
|
|
1376
|
-
//
|
|
1377
|
-
//
|
|
1378
|
-
//
|
|
1379
|
-
|
|
1800
|
+
// Resolve once, then thread the same answer through the shared scan and
|
|
1801
|
+
// directory matcher. Resolve an omitted value from this call's `ws`;
|
|
1802
|
+
// explicit null still means "resolved and non-bracket." A split convention
|
|
1803
|
+
// would widen the ROADMAP side while leaving bracket directories unmatched.
|
|
1804
|
+
headingConvention = phaseIdConvention === undefined
|
|
1805
|
+
? resolvePhaseIdConvention(cwd, ws)
|
|
1806
|
+
: phaseIdConvention;
|
|
1807
|
+
// #3262 remains the single owner of the phase-set scan. #612 extends its
|
|
1808
|
+
// return with qualified bracket ids rather than restoring the superseded
|
|
1809
|
+
// inline duplicate this commit was originally written against.
|
|
1810
|
+
const scanned = scanMilestonePhaseIdSets(roadmap, headingConvention);
|
|
1811
|
+
for (const id of scanned.ids)
|
|
1380
1812
|
milestonePhaseNums.add(id);
|
|
1381
|
-
|
|
1813
|
+
for (const qualified of scanned.qualifiedIds)
|
|
1814
|
+
milestoneQualifiedIds.add(qualified);
|
|
1382
1815
|
}
|
|
1383
1816
|
catch {
|
|
1384
1817
|
/* best-effort (#2245 audit): the real throw source is platformReadSync
|
|
@@ -1429,6 +1862,28 @@ function getMilestonePhaseFilter(cwd, versionOverride, phaseIdConvention, ws) {
|
|
|
1429
1862
|
// phase-id-owner: the [A-Za-z] letter class does real case handling here — this regex carries NO /i flag; kept literal, not source-byte-equal to the canonical PHASE_NUMBER_TOKEN_SOURCE.
|
|
1430
1863
|
: /^0*(\d+[A-Za-z]?(?:\.\d+)*)/;
|
|
1431
1864
|
function isDirInMilestone(dirName) {
|
|
1865
|
+
// #612: the DIR side of this filter, selected by the same convention the
|
|
1866
|
+
// heading side selected. Without it the heading scan's new bracket reach was
|
|
1867
|
+
// half a fix: `milestonePhaseNums` became non-empty, so the pass-all degrade
|
|
1868
|
+
// stopped firing, but no bracket directory could satisfy the three legacy
|
|
1869
|
+
// checks below (numericRe fails on `GSD.02-05-five`, the custom-id match
|
|
1870
|
+
// captures the project code `GSD`, and stripProjectCodePrefix does not strip
|
|
1871
|
+
// a dotted prefix) — so EVERY bracket directory was rejected and
|
|
1872
|
+
// completed_phases / total_plans / completed_plans / percent collapsed to 0
|
|
1873
|
+
// while `state sync` went on writing a percent off the unfiltered disk.
|
|
1874
|
+
//
|
|
1875
|
+
// Matching is delegated to phaseTokenMatches against the milestone-QUALIFIED
|
|
1876
|
+
// id, not the bare token: READING-B puts the milestone in the bracket, so
|
|
1877
|
+
// `GSD.01-01-old-one` and `GSD.02-01-one` share the token `01` and only the
|
|
1878
|
+
// qualified key separates them. That is the scoping this filter exists to do.
|
|
1879
|
+
// ADDITIVE: on a miss we fall through to the three legacy checks, so a
|
|
1880
|
+
// bracket repo carrying legacy-shaped directories reads exactly as before.
|
|
1881
|
+
if (headingConvention === 'bracket') {
|
|
1882
|
+
for (const qualified of milestoneQualifiedIds) {
|
|
1883
|
+
if (phaseTokenMatches(dirName, qualified, 'bracket'))
|
|
1884
|
+
return true;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1432
1887
|
const m2 = dirName.match(numericRe);
|
|
1433
1888
|
if (m2 && normalized.has(normalizePhaseIdSegments(m2[1]).toLowerCase()))
|
|
1434
1889
|
return true;
|
|
@@ -1496,6 +1951,24 @@ function getMilestonePhaseFilter(cwd, versionOverride, phaseIdConvention, ws) {
|
|
|
1496
1951
|
* `computeMilestoneSectionEnd` owner (#3184), so there is no separate copy to
|
|
1497
1952
|
* keep in sync. Returns null when there is no versioned active milestone;
|
|
1498
1953
|
* callers then fall back to whole-content mutation (the prior behaviour).
|
|
1954
|
+
*
|
|
1955
|
+
* #2761 (round-2 review, Minor 3 — latent, currently harmless): this function
|
|
1956
|
+
* consumes #3184's shared owners, but it does not pass the bracket-specific
|
|
1957
|
+
* B1/B2 boundary predicate and still has no bracket-fallback SELECTION branch:
|
|
1958
|
+
* it returns null when the version-string owner finds nothing, unlike
|
|
1959
|
+
* `extractCurrentMilestoneScoped`. The read owner can therefore scope a
|
|
1960
|
+
* bracket ROADMAP this write-range consumer still calls unscoped. Probed and
|
|
1961
|
+
* confirmed harmless TODAY: this
|
|
1962
|
+
* function's single consumer (`mutateMilestonePhase`, src/phase.cts) falls
|
|
1963
|
+
* back to whole-content mutation when it returns null, and every mutation
|
|
1964
|
+
* inside that caller is still `Phase`-labelled-only (not bracket-widened) per
|
|
1965
|
+
* the changeset's own "READ-path opt-in until the migrator and write path
|
|
1966
|
+
* land" — so a bracket ROADMAP's checkbox/heading patterns never match inside
|
|
1967
|
+
* that fallback and nothing is mutated cross-milestone. The moment the write
|
|
1968
|
+
* path is widened (PR-3+), this divergence becomes live: the whole-content
|
|
1969
|
+
* fallback would become a cross-milestone writer, which is exactly what this
|
|
1970
|
+
* note exists to prevent. Bracket-widen this function in lockstep with the
|
|
1971
|
+
* write path landing, not before.
|
|
1499
1972
|
*/
|
|
1500
1973
|
function currentMilestoneRawRanges(content, cwd) {
|
|
1501
1974
|
if (!cwd)
|