devflow-toolkit 0.3.13__tar.gz → 0.3.14__tar.gz

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.
Files changed (77) hide show
  1. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/CHANGELOG.md +15 -0
  2. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/PKG-INFO +15 -10
  3. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/README.md +14 -9
  4. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/pyproject.toml +1 -1
  5. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/cli.py +1 -1
  6. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/approve.py +1 -1
  7. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/discovery.py +27 -7
  8. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/spec_workflow.py +1 -0
  9. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_discovery.py +59 -0
  10. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_harness_adapters.py +23 -1
  11. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_spec_workflow.py +37 -1
  12. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/.gitignore +0 -0
  13. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/LICENSE +0 -0
  14. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/__init__.py +0 -0
  15. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/__init__.py +0 -0
  16. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/agents.py +0 -0
  17. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/base.py +0 -0
  18. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/claude_code.py +0 -0
  19. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/codex.py +0 -0
  20. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/detector.py +0 -0
  21. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/instructions.py +0 -0
  22. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/kiro.py +0 -0
  23. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/opencode.py +0 -0
  24. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/adapters/registry.py +0 -0
  25. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/__init__.py +0 -0
  26. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/doctor.py +0 -0
  27. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/harness.py +0 -0
  28. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/init.py +0 -0
  29. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/recover.py +0 -0
  30. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/spec.py +0 -0
  31. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/commands/status.py +0 -0
  32. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/__init__.py +0 -0
  33. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/architecture.py +0 -0
  34. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/artifacts/__init__.py +0 -0
  35. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/artifacts/errors.py +0 -0
  36. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/artifacts/models.py +0 -0
  37. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/artifacts/store.py +0 -0
  38. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/clock.py +0 -0
  39. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/config.py +0 -0
  40. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/constitution.py +0 -0
  41. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/ports.py +0 -0
  42. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/profile_manager.py +0 -0
  43. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/project.py +0 -0
  44. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/recovery.py +0 -0
  45. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/specification.py +0 -0
  46. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/__init__.py +0 -0
  47. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/errors.py +0 -0
  48. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/events.py +0 -0
  49. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/locator.py +0 -0
  50. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/lock.py +0 -0
  51. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/manager.py +0 -0
  52. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/models.py +0 -0
  53. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/core/state/transitions.py +0 -0
  54. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/models/__init__.py +0 -0
  55. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/models/profile.py +0 -0
  56. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/models/project.py +0 -0
  57. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
  58. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
  59. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/base/constitution/architecture.md +0 -0
  60. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
  61. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/base/constitution/constitution.md +0 -0
  62. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/base/profile.yaml +0 -0
  63. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
  64. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/django-backend/profile.yaml +0 -0
  65. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
  66. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
  67. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/prompts/__init__.py +0 -0
  68. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/prompts/discovery.md +0 -0
  69. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/prompts/spec.greenfield.md +0 -0
  70. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/src/devflow/prompts/spec.md +0 -0
  71. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_cli.py +0 -0
  72. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_event_log.py +0 -0
  73. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_greenfield.py +0 -0
  74. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_hardening.py +0 -0
  75. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_recovery.py +0 -0
  76. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_state.py +0 -0
  77. {devflow_toolkit-0.3.13 → devflow_toolkit-0.3.14}/tests/test_state_replay.py +0 -0
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to DevFlow Toolkit are documented in this file.
4
4
 
5
+ ## 0.3.14 - 2026-11-05
6
+
7
+ ### Fixed
8
+
9
+ - The deterministic planner no longer marks Discovery complete when a
10
+ request only matches generic data vocabulary. A request such as
11
+ "Quiero crear categorias de libros al momento de cargarlos a la base
12
+ de datos" now gets a generic blocking scope question instead of
13
+ skipping the harness with zero questions.
14
+ - Interactive runs now guarantee at least one Discovery question when
15
+ no specific heuristic matches, so the selected harness is always
16
+ invoked before a specification is generated. Non-interactive runs
17
+ keep the previous deterministic behavior for concrete requests.
18
+ - Package version is `0.3.14`.
19
+
5
20
  ## 0.3.13 - 2026-11-05
6
21
 
7
22
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.13
3
+ Version: 0.3.14
4
4
  Summary: Specification workflow toolkit for AI-assisted software changes
5
5
  Author: DevFlow contributors
6
6
  License-Expression: MIT
@@ -42,7 +42,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
42
42
  selected agent harness is only the execution backend that drafts the
43
43
  specification.
44
44
 
45
- This is the `0.3.13` MVP. It implements the **discovery and
45
+ This is the `0.3.14` MVP. It implements the **discovery and
46
46
  specification stages only**. It supports two specification contexts:
47
47
  **Existing Project** (the default) and **Greenfield**. It is not a
48
48
  complete SDD platform and does not include planning, implementation or
@@ -118,7 +118,7 @@ pip install devflow-toolkit
118
118
  To install a specific built artifact instead:
119
119
 
120
120
  ```bash
121
- pip install devflow_toolkit-0.3.13-py3-none-any.whl
121
+ pip install devflow_toolkit-0.3.14-py3-none-any.whl
122
122
  ```
123
123
 
124
124
  Verify the installation:
@@ -297,7 +297,7 @@ as an architectural constraint when it is present.
297
297
 
298
298
  ### Harnesses
299
299
 
300
- | Harness | Status in 0.3.13 |
300
+ | Harness | Status in 0.3.14 |
301
301
  | --- | --- |
302
302
  | OpenCode | Verified end-to-end in non-interactive mode |
303
303
  | Codex | Integration files are generated, but not verified for this release |
@@ -412,9 +412,14 @@ generated.
412
412
 
413
413
  The deterministic planner recognizes contact pages, forms, comments,
414
414
  authentication, persistence, deployments and architecture boundaries in
415
- English and Spanish. If a short request does not match any known feature
416
- vocabulary, the planner adds a generic blocking scope question instead
417
- of marking Discovery complete with no questions.
415
+ English and Spanish. Generic data vocabulary such as `datos`, `data` or
416
+ `database` does not by itself prove that the feature scope is understood:
417
+ when it is the only match, the planner adds a generic blocking scope
418
+ question instead of marking Discovery complete. Interactive runs always
419
+ produce at least one question when no specific question matches, so the
420
+ selected harness is invoked instead of being skipped with an empty
421
+ Discovery. Non-interactive runs keep the deterministic behavior for
422
+ concrete requests such as `Add a health endpoint`.
418
423
 
419
424
  For user-generated content, Discovery must also resolve who writes it,
420
425
  who may create, edit or delete it, moderation, authentication
@@ -475,7 +480,7 @@ specification that still lists open questions.
475
480
  8. If artifacts exist without workflow state, diagnose with
476
481
  `devflow doctor <id>` and repair with `devflow recover <id>`.
477
482
 
478
- Available commands in `0.3.13`:
483
+ Available commands in `0.3.14`:
479
484
 
480
485
  | Command | Status |
481
486
  | --- | --- |
@@ -667,7 +672,7 @@ devflow approve 001 --stage spec
667
672
  ```
668
673
 
669
674
  Approval is explicit and binds the decision to the current artifact
670
- digests. For a `0.3.13` change it binds `spec.md`, `discovery.yaml` and,
675
+ digests. For a `0.3.14` change it binds `spec.md`, `discovery.yaml` and,
671
676
  when a manifest applies, the architecture manifest digest. Repeating the
672
677
  same approval is a no-op. If an artifact changes after validation,
673
678
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -678,7 +683,7 @@ and names the pending questions and assumptions. Approval also rejects a
678
683
  specification whose section 7 still lists open questions. Legacy `0.2.0`
679
684
  changes without `discovery.yaml` remain approvable with a warning.
680
685
 
681
- Only the `spec` stage is available in `0.3.13`. `--stage plan` and
686
+ Only the `spec` stage is available in `0.3.14`. `--stage plan` and
682
687
  `--stage review` are rejected. There are no `plan`, `implement` or
683
688
  `review` commands in this release.
684
689
 
@@ -10,7 +10,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
10
10
  selected agent harness is only the execution backend that drafts the
11
11
  specification.
12
12
 
13
- This is the `0.3.13` MVP. It implements the **discovery and
13
+ This is the `0.3.14` MVP. It implements the **discovery and
14
14
  specification stages only**. It supports two specification contexts:
15
15
  **Existing Project** (the default) and **Greenfield**. It is not a
16
16
  complete SDD platform and does not include planning, implementation or
@@ -86,7 +86,7 @@ pip install devflow-toolkit
86
86
  To install a specific built artifact instead:
87
87
 
88
88
  ```bash
89
- pip install devflow_toolkit-0.3.13-py3-none-any.whl
89
+ pip install devflow_toolkit-0.3.14-py3-none-any.whl
90
90
  ```
91
91
 
92
92
  Verify the installation:
@@ -265,7 +265,7 @@ as an architectural constraint when it is present.
265
265
 
266
266
  ### Harnesses
267
267
 
268
- | Harness | Status in 0.3.13 |
268
+ | Harness | Status in 0.3.14 |
269
269
  | --- | --- |
270
270
  | OpenCode | Verified end-to-end in non-interactive mode |
271
271
  | Codex | Integration files are generated, but not verified for this release |
@@ -380,9 +380,14 @@ generated.
380
380
 
381
381
  The deterministic planner recognizes contact pages, forms, comments,
382
382
  authentication, persistence, deployments and architecture boundaries in
383
- English and Spanish. If a short request does not match any known feature
384
- vocabulary, the planner adds a generic blocking scope question instead
385
- of marking Discovery complete with no questions.
383
+ English and Spanish. Generic data vocabulary such as `datos`, `data` or
384
+ `database` does not by itself prove that the feature scope is understood:
385
+ when it is the only match, the planner adds a generic blocking scope
386
+ question instead of marking Discovery complete. Interactive runs always
387
+ produce at least one question when no specific question matches, so the
388
+ selected harness is invoked instead of being skipped with an empty
389
+ Discovery. Non-interactive runs keep the deterministic behavior for
390
+ concrete requests such as `Add a health endpoint`.
386
391
 
387
392
  For user-generated content, Discovery must also resolve who writes it,
388
393
  who may create, edit or delete it, moderation, authentication
@@ -443,7 +448,7 @@ specification that still lists open questions.
443
448
  8. If artifacts exist without workflow state, diagnose with
444
449
  `devflow doctor <id>` and repair with `devflow recover <id>`.
445
450
 
446
- Available commands in `0.3.13`:
451
+ Available commands in `0.3.14`:
447
452
 
448
453
  | Command | Status |
449
454
  | --- | --- |
@@ -635,7 +640,7 @@ devflow approve 001 --stage spec
635
640
  ```
636
641
 
637
642
  Approval is explicit and binds the decision to the current artifact
638
- digests. For a `0.3.13` change it binds `spec.md`, `discovery.yaml` and,
643
+ digests. For a `0.3.14` change it binds `spec.md`, `discovery.yaml` and,
639
644
  when a manifest applies, the architecture manifest digest. Repeating the
640
645
  same approval is a no-op. If an artifact changes after validation,
641
646
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -646,7 +651,7 @@ and names the pending questions and assumptions. Approval also rejects a
646
651
  specification whose section 7 still lists open questions. Legacy `0.2.0`
647
652
  changes without `discovery.yaml` remain approvable with a warning.
648
653
 
649
- Only the `spec` stage is available in `0.3.13`. `--stage plan` and
654
+ Only the `spec` stage is available in `0.3.14`. `--stage plan` and
650
655
  `--stage review` are rejected. There are no `plan`, `implement` or
651
656
  `review` commands in this release.
652
657
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "devflow-toolkit"
7
- version = "0.3.13"
7
+ version = "0.3.14"
8
8
  description = "Specification workflow toolkit for AI-assisted software changes"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -35,7 +35,7 @@ def version() -> None:
35
35
  try:
36
36
  current_version = package_version("devflow-toolkit")
37
37
  except PackageNotFoundError:
38
- current_version = "0.3.13"
38
+ current_version = "0.3.14"
39
39
  console.print(f"DevFlow v{current_version}")
40
40
 
41
41
 
@@ -57,7 +57,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
57
57
  normalized = stage.strip().lower()
58
58
  if normalized != "spec":
59
59
  msg = (
60
- f"Stage '{stage}' is not available in DevFlow 0.3.13. "
60
+ f"Stage '{stage}' is not available in DevFlow 0.3.14. "
61
61
  "Only the 'spec' stage can be approved."
62
62
  )
63
63
  raise UnsupportedStageError(msg)
@@ -417,6 +417,11 @@ _PLANNER_SIGNAL_WORDS = (
417
417
  | _ARCHITECTURE_WORDS
418
418
  | _VAGUE_TERMS
419
419
  )
420
+ # Generic data words describe where something is stored, not what the user
421
+ # will be able to do. Matching only this vocabulary is not enough evidence
422
+ # that the planner understood the feature, so it must still ask for scope.
423
+ _WEAK_SIGNAL_WORDS = _DATA_WORDS | _VAGUE_TERMS
424
+ _STRONG_SIGNAL_WORDS = _PLANNER_SIGNAL_WORDS - _WEAK_SIGNAL_WORDS
420
425
 
421
426
 
422
427
  class DiscoveryError(Exception):
@@ -1116,8 +1121,14 @@ class DiscoveryPlanner:
1116
1121
  has_tests: bool,
1117
1122
  architecture: ArchitectureManifest | None,
1118
1123
  now: str,
1124
+ require_question: bool = False,
1119
1125
  ) -> DiscoveryDocument:
1120
- """Return a deterministic discovery record for a request."""
1126
+ """Return a deterministic discovery record for a request.
1127
+
1128
+ ``require_question`` guarantees that at least one question is
1129
+ produced when no specific heuristic matches. Interactive runs use it
1130
+ so the selected harness is never skipped with an empty Discovery.
1131
+ """
1121
1132
  text = _normalize(request)
1122
1133
  words = _words(text)
1123
1134
  questions: list[DiscoveryQuestion] = []
@@ -1532,17 +1543,26 @@ class DiscoveryPlanner:
1532
1543
 
1533
1544
  if (
1534
1545
  not questions
1535
- and len(keywords) < 6
1536
- and not (words & _PLANNER_SIGNAL_WORDS)
1546
+ and (
1547
+ require_question
1548
+ or (
1549
+ len(keywords) < 6
1550
+ and not (words & _PLANNER_SIGNAL_WORDS)
1551
+ )
1552
+ or (
1553
+ words & _WEAK_SIGNAL_WORDS
1554
+ and not (words & _STRONG_SIGNAL_WORDS)
1555
+ )
1556
+ )
1537
1557
  ):
1538
1558
  add_question(
1539
1559
  "functional_scope",
1540
1560
  "What exact user-visible behavior should this change add, and "
1541
1561
  "how should it be verified?",
1542
- "The request is short and does not match a known feature "
1543
- "pattern, so DevFlow cannot confirm the scope, the expected "
1544
- "behavior or the acceptance criteria without an explicit "
1545
- "decision.",
1562
+ "The request does not identify a feature pattern that DevFlow "
1563
+ "can turn into requirements on its own, so it cannot confirm "
1564
+ "the scope, the expected behavior or the acceptance criteria "
1565
+ "without an explicit decision.",
1546
1566
  (
1547
1567
  "Describe the intended behavior and acceptance criteria.",
1548
1568
  "Reuse an existing feature (describe it).",
@@ -250,6 +250,7 @@ class SpecWorkflow:
250
250
  has_tests=prepared.analysis.has_tests,
251
251
  architecture=architecture,
252
252
  now=now,
253
+ require_question=request.execution_mode == "interactive",
253
254
  )
254
255
  discovery_path, discovery_digest = discovery_manager.write(
255
256
  prepared.directory,
@@ -210,6 +210,65 @@ def test_planner_completes_a_concrete_request(tmp_path: Path) -> None:
210
210
  assert document.pending_assumptions == ()
211
211
 
212
212
 
213
+ def test_planner_asks_scope_when_only_a_data_word_matches(
214
+ tmp_path: Path,
215
+ ) -> None:
216
+ document = DiscoveryPlanner().build(
217
+ request=(
218
+ "Quiero crear categorias de libros al momento de cargarlos a la "
219
+ "base de datos"
220
+ ),
221
+ spec_id="003",
222
+ change="003-quiero-crear-categorias-de-libros",
223
+ project_mode="existing",
224
+ project=Project(
225
+ root=tmp_path,
226
+ name="demo",
227
+ project_type="django",
228
+ databases=("default",),
229
+ ),
230
+ profiles=(),
231
+ reference_paths=(),
232
+ category_paths={},
233
+ has_tests=True,
234
+ architecture=None,
235
+ now="2026-11-05T00:00:00Z",
236
+ )
237
+
238
+ assert document.status == DISCOVERY_AWAITING
239
+ assert not document.is_complete
240
+ assert len(document.questions) == 1
241
+ assert document.questions[0].category == "functional_scope"
242
+
243
+
244
+ def test_planner_require_question_prevents_empty_completion(
245
+ tmp_path: Path,
246
+ ) -> None:
247
+ document = DiscoveryPlanner().build(
248
+ request="Add a health endpoint",
249
+ spec_id="001",
250
+ change="001-add-a-health-endpoint",
251
+ project_mode="existing",
252
+ project=Project(
253
+ root=tmp_path,
254
+ name="demo",
255
+ project_type="unknown",
256
+ ),
257
+ profiles=(),
258
+ reference_paths=(),
259
+ category_paths={},
260
+ has_tests=True,
261
+ architecture=None,
262
+ now="2026-11-05T00:00:00Z",
263
+ require_question=True,
264
+ )
265
+
266
+ assert document.status == DISCOVERY_AWAITING
267
+ assert not document.is_complete
268
+ assert len(document.questions) == 1
269
+ assert document.questions[0].category == "functional_scope"
270
+
271
+
213
272
  def test_planner_blocks_a_contact_form_and_proposes_assumption(
214
273
  tmp_path: Path,
215
274
  ) -> None:
@@ -125,7 +125,23 @@ def _fake_harness(
125
125
  directory: Path,
126
126
  name: str,
127
127
  output: str,
128
+ *,
129
+ answer_discovery: bool = False,
128
130
  ) -> Path:
131
+ answer_script = ""
132
+ if answer_discovery:
133
+ answer_script = """
134
+ for f in .devflow/specs/*/discovery.yaml; do
135
+ if [ -f "$f" ]; then
136
+ /bin/sed -i \\
137
+ -e 's/^ status: pending$/ status: answered/' \\
138
+ -e 's/^ answer: null$/ answer: Use the existing behavior./' \\
139
+ -e 's/^ answered_by: null$/ answered_by: user/' \\
140
+ -e "s/^ answered_at: null$/ answered_at: '2026-11-05T00:00:00Z'/" \\
141
+ "$f"
142
+ fi
143
+ done
144
+ """
129
145
  path = directory / name
130
146
  script = f"""#!/bin/sh
131
147
  out=""
@@ -135,6 +151,7 @@ while [ $# -gt 0 ]; do
135
151
  *) shift ;;
136
152
  esac
137
153
  done
154
+ {answer_script}
138
155
  digest=""
139
156
  for f in .devflow/specs/*/discovery.yaml; do
140
157
  if [ -f "$f" ]; then
@@ -536,7 +553,12 @@ def test_interactive_spec_stops_after_discovery_and_resumes(
536
553
  assert _init(tmp_path, "--harness", "codex").exit_code == 0
537
554
  fake_bin = tmp_path / "bin"
538
555
  fake_bin.mkdir()
539
- _fake_harness(fake_bin, "codex", VALID_SPEC)
556
+ _fake_harness(
557
+ fake_bin,
558
+ "codex",
559
+ VALID_SPEC,
560
+ answer_discovery=True,
561
+ )
540
562
  monkeypatch.setenv("PATH", str(fake_bin))
541
563
  original_execution_mode = spec_module._execution_mode
542
564
 
@@ -16,6 +16,7 @@ from devflow.core.config import (
16
16
  ConfigManager,
17
17
  DevFlowConfig,
18
18
  )
19
+ from devflow.core.discovery import DiscoveryManager
19
20
  from devflow.core.ports import (
20
21
  FileChange,
21
22
  HarnessPort,
@@ -249,9 +250,28 @@ def test_workflow_stops_after_discovery_when_requested(
249
250
  config = _config(tmp_path)
250
251
  adapter = FakeAdapter()
251
252
 
253
+ def executor(invocation: Invocation) -> InvocationResult:
254
+ assert adapter.run_context is not None
255
+ manager = DiscoveryManager(invocation.cwd)
256
+ directory = adapter.run_context.spec_directory
257
+ document = manager.load(directory, required=True)
258
+ for question in document.pending_questions:
259
+ document = manager.answer(
260
+ document,
261
+ question.id,
262
+ "Use the existing project behavior.",
263
+ )
264
+ manager.write(directory, document)
265
+ return InvocationResult(
266
+ returncode=0,
267
+ stdout="",
268
+ stderr="",
269
+ )
270
+
252
271
  result = _run(
253
272
  config,
254
273
  adapter=adapter,
274
+ executor=executor,
255
275
  mode="interactive",
256
276
  stop_after_discovery=True,
257
277
  )
@@ -261,7 +281,7 @@ def test_workflow_stops_after_discovery_when_requested(
261
281
  assert result.spec is None
262
282
  assert result.discovery is not None
263
283
  assert result.discovery.is_complete
264
- assert adapter.run_context is None
284
+ assert adapter.run_context is not None
265
285
  assert not (
266
286
  tmp_path / ".devflow" / "specs" / "001-add-a-health-endpoint" /
267
287
  "spec.md"
@@ -373,6 +393,22 @@ def test_workflow_accepts_interactive_spec_written_by_agent(
373
393
 
374
394
  def executor(invocation: Invocation) -> InvocationResult:
375
395
  assert adapter.run_context is not None
396
+ if "Discovery Task" in adapter.run_context.prompt:
397
+ manager = DiscoveryManager(invocation.cwd)
398
+ directory = adapter.run_context.spec_directory
399
+ document = manager.load(directory, required=True)
400
+ for question in document.pending_questions:
401
+ document = manager.answer(
402
+ document,
403
+ question.id,
404
+ "Use the existing project behavior.",
405
+ )
406
+ manager.write(directory, document)
407
+ return InvocationResult(
408
+ returncode=0,
409
+ stdout="discovery recorded",
410
+ stderr="",
411
+ )
376
412
  adapter.run_context.spec_path.parent.mkdir(
377
413
  parents=True,
378
414
  exist_ok=True,