This repository was archived by the owner on Jul 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
fix(sprint-compare): resolve descriptive slug keys via existing resolver #36
Open
Pawel-N-pl
wants to merge
3
commits into
main
Choose a base branch
from
fix/sprint-compare-key-format
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import io | ||
| import json | ||
| import tempfile | ||
| import textwrap | ||
| import unittest | ||
| from contextlib import redirect_stdout | ||
| from pathlib import Path | ||
|
|
||
| from story_automator.commands.state import cmd_sprint_compare | ||
| from story_automator.core.sprint import sprint_status_done_in_text | ||
|
|
||
|
|
||
| SPRINT_STATUS = textwrap.dedent( | ||
| """\ | ||
| development_status: | ||
| epic-1: in-progress | ||
| 1-1-host-feasibility-probe: done | ||
| 1-2-docker-dev-test-environment: done | ||
| 1-3-database-wrapper-migrations: done | ||
| 1-4-redis-wrapper-clock: done | ||
| 2-1-users-schema-permanent-admin: in-progress | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| class SprintStatusDoneInTextTests(unittest.TestCase): | ||
| """`sprint_status_done_in_text` must resolve dotted IDs against descriptive | ||
| slug keys -- the BMAD default `sprint-status.yaml` format.""" | ||
|
|
||
| def test_dotted_id_resolves_descriptive_slug(self) -> None: | ||
| self.assertTrue(sprint_status_done_in_text(SPRINT_STATUS, "1.1")) | ||
|
|
||
| def test_dashed_prefix_resolves_descriptive_slug(self) -> None: | ||
| self.assertTrue(sprint_status_done_in_text(SPRINT_STATUS, "1-1")) | ||
|
|
||
| def test_full_slug_key_exact_match(self) -> None: | ||
| self.assertTrue(sprint_status_done_in_text(SPRINT_STATUS, "1-1-host-feasibility-probe")) | ||
|
|
||
| def test_not_done_is_false(self) -> None: | ||
| self.assertFalse(sprint_status_done_in_text(SPRINT_STATUS, "2.1")) | ||
|
|
||
| def test_missing_story_is_false(self) -> None: | ||
| self.assertFalse(sprint_status_done_in_text(SPRINT_STATUS, "9.9")) | ||
|
|
||
| def test_descriptive_slug_wins_over_bare_prefix_regardless_of_order(self) -> None: | ||
| # When both a bare prefix key and a descriptive slug key exist for the | ||
| # same story, the descriptive slug must win deterministically (matching | ||
| # `_best_status_match` / `sprint_status_get`), not whichever comes first. | ||
| prefix_first = textwrap.dedent( | ||
| """\ | ||
| development_status: | ||
| 1-1: in-progress | ||
| 1-1-host-feasibility-probe: done | ||
| """ | ||
| ) | ||
| slug_first = textwrap.dedent( | ||
| """\ | ||
| development_status: | ||
| 1-1-host-feasibility-probe: done | ||
| 1-1: in-progress | ||
| """ | ||
| ) | ||
| self.assertTrue(sprint_status_done_in_text(prefix_first, "1.1")) | ||
| self.assertTrue(sprint_status_done_in_text(slug_first, "1.1")) | ||
|
|
||
|
|
||
| class SprintCompareCommandTests(unittest.TestCase): | ||
| """End-to-end regression for the false-positive `incomplete` bug: dotted | ||
| `storyRange` vs descriptive-slug `sprint-status.yaml` keys.""" | ||
|
|
||
| def setUp(self) -> None: | ||
| self.tmp = tempfile.TemporaryDirectory() | ||
| root = Path(self.tmp.name) | ||
| self.sprint = root / "sprint-status.yaml" | ||
| self.sprint.write_text(SPRINT_STATUS) | ||
| self.state = root / "orchestration.md" | ||
| self.state.write_text( | ||
| textwrap.dedent( | ||
| """\ | ||
| --- | ||
| storyRange: ["1.1", "1.2", "1.3", "1.4", "2.1"] | ||
| currentStory: 2.1 | ||
| --- | ||
| # Orchestration | ||
| """ | ||
| ) | ||
| ) | ||
|
|
||
| def tearDown(self) -> None: | ||
| self.tmp.cleanup() | ||
|
|
||
| def _run(self) -> dict: | ||
| buf = io.StringIO() | ||
| with redirect_stdout(buf): | ||
| rc = cmd_sprint_compare(["--state", str(self.state), "--sprint", str(self.sprint)]) | ||
| self.assertEqual(rc, 0) | ||
| return json.loads(buf.getvalue()) | ||
|
|
||
| def test_all_earlier_done_reports_nothing_incomplete(self) -> None: | ||
| result = self._run() | ||
| self.assertEqual(result["checked"], ["1.1", "1.2", "1.3", "1.4"]) | ||
| self.assertEqual(result["incomplete"], []) | ||
|
|
||
| def test_flags_genuinely_incomplete_story(self) -> None: | ||
| # 2.1 is in-progress; if it were an earlier story it must be flagged. | ||
| self.state.write_text( | ||
| textwrap.dedent( | ||
| """\ | ||
| --- | ||
| storyRange: ["1.1", "2.1", "1.2"] | ||
| currentStory: 1.2 | ||
| --- | ||
| """ | ||
| ) | ||
| ) | ||
| result = self._run() | ||
| self.assertEqual(result["checked"], ["1.1", "2.1"]) | ||
| self.assertEqual(result["incomplete"], ["2.1"]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd_sprint_compareaccepts explicit--stateand--sprintpaths, but this now feeds the ambient project root into the text-backed resolver. When that root is absent or points at a different project, a child row likerelease-3-phase-2-1-title: donecan satisfy predecessorrelease.3, so the predecessor gate reports no incomplete story.Repro:
Output:
{"ok":true,"incomplete":[],"checked":["release.3"]}Suggested fix: make the text-backed lookup disambiguate from the supplied sprint content, or derive/reject a project root tied to the explicit sprint path, so unmatched predecessors fail closed.