devflow-toolkit 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl
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.
- devflow/cli.py +1 -1
- devflow/commands/approve.py +1 -1
- devflow/commands/doctor.py +12 -0
- devflow/commands/spec.py +43 -4
- devflow/commands/status.py +1 -0
- devflow/core/discovery.py +317 -26
- devflow/core/recovery.py +45 -0
- devflow/core/spec_workflow.py +145 -12
- devflow/core/specification.py +9 -25
- devflow/core/state/manager.py +23 -0
- devflow/prompts/__init__.py +34 -17
- devflow/prompts/discovery.md +58 -9
- devflow/prompts/spec.greenfield.md +13 -7
- devflow/prompts/spec.md +12 -6
- {devflow_toolkit-0.3.2.dist-info → devflow_toolkit-0.3.4.dist-info}/METADATA +92 -31
- {devflow_toolkit-0.3.2.dist-info → devflow_toolkit-0.3.4.dist-info}/RECORD +19 -19
- {devflow_toolkit-0.3.2.dist-info → devflow_toolkit-0.3.4.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.3.2.dist-info → devflow_toolkit-0.3.4.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.3.2.dist-info → devflow_toolkit-0.3.4.dist-info}/licenses/LICENSE +0 -0
devflow/cli.py
CHANGED
devflow/commands/approve.py
CHANGED
|
@@ -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.
|
|
60
|
+
f"Stage '{stage}' is not available in DevFlow 0.3.4. "
|
|
61
61
|
"Only the 'spec' stage can be approved."
|
|
62
62
|
)
|
|
63
63
|
raise UnsupportedStageError(msg)
|
devflow/commands/doctor.py
CHANGED
|
@@ -91,6 +91,18 @@ def _doctor(spec_id: str, path: Path) -> bool:
|
|
|
91
91
|
"[bold]Next:[/bold] "
|
|
92
92
|
f"devflow recover {location.spec_id} {root}"
|
|
93
93
|
)
|
|
94
|
+
elif inspection.can_resume:
|
|
95
|
+
console.print(
|
|
96
|
+
"\n[bold yellow]Diagnosis: Discovery is complete but the "
|
|
97
|
+
"specification is missing.[/bold yellow]"
|
|
98
|
+
)
|
|
99
|
+
console.print(
|
|
100
|
+
"[bold]Next:[/bold] "
|
|
101
|
+
f"devflow spec --continue {location.spec_id} {root}"
|
|
102
|
+
)
|
|
103
|
+
console.print(
|
|
104
|
+
"[dim]The existing Discovery record will be reused.[/dim]"
|
|
105
|
+
)
|
|
94
106
|
else:
|
|
95
107
|
console.print(
|
|
96
108
|
"\n[bold yellow]Diagnosis: needs attention.[/bold yellow]"
|
devflow/commands/spec.py
CHANGED
|
@@ -30,6 +30,7 @@ from devflow.core.constitution import ConstitutionError
|
|
|
30
30
|
from devflow.core.discovery import DiscoveryError
|
|
31
31
|
from devflow.core.profile_manager import ProfileError
|
|
32
32
|
from devflow.core.project import ProjectDetector
|
|
33
|
+
from devflow.core.recovery import ensure_resumable_state
|
|
33
34
|
from devflow.core.spec_workflow import (
|
|
34
35
|
SpecWorkflow,
|
|
35
36
|
SpecWorkflowRequest,
|
|
@@ -103,6 +104,15 @@ def spec(
|
|
|
103
104
|
"Defaults to the configured language."
|
|
104
105
|
),
|
|
105
106
|
),
|
|
107
|
+
auto: bool = typer.Option(
|
|
108
|
+
False,
|
|
109
|
+
"--auto",
|
|
110
|
+
help=(
|
|
111
|
+
"Run Discovery and Specification in one invocation. By default an "
|
|
112
|
+
"interactive run stops after Discovery so you can choose the "
|
|
113
|
+
"specification harness."
|
|
114
|
+
),
|
|
115
|
+
),
|
|
106
116
|
) -> None:
|
|
107
117
|
"""Generate or resume a specification for a change request."""
|
|
108
118
|
try:
|
|
@@ -115,6 +125,7 @@ def spec(
|
|
|
115
125
|
project_mode,
|
|
116
126
|
continue_id,
|
|
117
127
|
language,
|
|
128
|
+
auto,
|
|
118
129
|
)
|
|
119
130
|
except (
|
|
120
131
|
ArchitectureError,
|
|
@@ -142,6 +153,7 @@ def _create_specification(
|
|
|
142
153
|
project_mode: Optional[str],
|
|
143
154
|
continue_id: Optional[str],
|
|
144
155
|
language: Optional[str] = None,
|
|
156
|
+
auto: bool = False,
|
|
145
157
|
) -> None:
|
|
146
158
|
request = (description or "").strip()
|
|
147
159
|
resume = (continue_id or "").strip() or None
|
|
@@ -199,6 +211,13 @@ def _create_specification(
|
|
|
199
211
|
)
|
|
200
212
|
adapter = adapter_for(selected_harness) if selected_harness else None
|
|
201
213
|
|
|
214
|
+
stop_after_discovery = (
|
|
215
|
+
not auto
|
|
216
|
+
and resume is None
|
|
217
|
+
and selected_harness is not None
|
|
218
|
+
and execution_mode == "interactive"
|
|
219
|
+
)
|
|
220
|
+
|
|
202
221
|
workflow = SpecWorkflow(executor=execute_invocation)
|
|
203
222
|
result = workflow.run(
|
|
204
223
|
SpecWorkflowRequest(
|
|
@@ -210,6 +229,7 @@ def _create_specification(
|
|
|
210
229
|
project_mode=effective_project_mode,
|
|
211
230
|
continue_spec_id=resume,
|
|
212
231
|
language=documentation_language,
|
|
232
|
+
stop_after_discovery=stop_after_discovery,
|
|
213
233
|
)
|
|
214
234
|
)
|
|
215
235
|
|
|
@@ -225,7 +245,7 @@ def _create_specification(
|
|
|
225
245
|
if result.discovery is not None:
|
|
226
246
|
console.print(
|
|
227
247
|
f"[bold]Discovery:[/bold] {result.discovery.status} "
|
|
228
|
-
f"({len(result.discovery.
|
|
248
|
+
f"({len(result.discovery.pending_questions)} pending, "
|
|
229
249
|
f"{len(result.discovery.pending_assumptions)} assumptions)"
|
|
230
250
|
)
|
|
231
251
|
if result.discovery_digest:
|
|
@@ -243,7 +263,25 @@ def _create_specification(
|
|
|
243
263
|
print_setup_result(result.setup_result, config.root, console)
|
|
244
264
|
_print_warnings(list(result.run_warnings))
|
|
245
265
|
|
|
246
|
-
if result.
|
|
266
|
+
if result.stopped_after_discovery:
|
|
267
|
+
stopped = WorkflowLocator(
|
|
268
|
+
config.specifications_path
|
|
269
|
+
).from_directory(result.directory)
|
|
270
|
+
console.print(
|
|
271
|
+
"\n[bold green]Discovery complete.[/bold green] "
|
|
272
|
+
"The specification was not generated."
|
|
273
|
+
)
|
|
274
|
+
next_command = (
|
|
275
|
+
f"devflow spec --continue {stopped.spec_id} ."
|
|
276
|
+
)
|
|
277
|
+
if selected_harness is not None:
|
|
278
|
+
next_command += f" --harness {selected_harness}"
|
|
279
|
+
console.print(f"[bold]Next:[/bold] {next_command}")
|
|
280
|
+
console.print(
|
|
281
|
+
"[dim]Choose another harness with --harness, or run both phases "
|
|
282
|
+
"in one invocation with --auto.[/dim]"
|
|
283
|
+
)
|
|
284
|
+
elif result.blocked:
|
|
247
285
|
_print_blocked(result=result, config=config)
|
|
248
286
|
elif result.spec_reused and result.spec is not None:
|
|
249
287
|
console.print(
|
|
@@ -272,6 +310,7 @@ def _ensure_continuable(config: DevFlowConfig, selector: str) -> None:
|
|
|
272
310
|
project_root=config.root,
|
|
273
311
|
)
|
|
274
312
|
location = WorkflowLocator(config.specifications_path).find(selector)
|
|
313
|
+
ensure_resumable_state(config, location)
|
|
275
314
|
state = manager.load(location)
|
|
276
315
|
allowed = {
|
|
277
316
|
WorkflowStatus.DRAFT.value,
|
|
@@ -529,6 +568,6 @@ def _print_result(
|
|
|
529
568
|
f"[bold]Discovery:[/bold] {result.discovery.status}"
|
|
530
569
|
)
|
|
531
570
|
console.print(
|
|
532
|
-
"\nNext: review the specification
|
|
533
|
-
"
|
|
571
|
+
"\nNext: review the specification and approve it before "
|
|
572
|
+
"implementation."
|
|
534
573
|
)
|
devflow/commands/status.py
CHANGED
|
@@ -128,6 +128,7 @@ def _print_discovery(
|
|
|
128
128
|
return
|
|
129
129
|
console.print(
|
|
130
130
|
f" status: {discovery.status} · "
|
|
131
|
+
f"{len(discovery.pending_questions)} pending · "
|
|
131
132
|
f"{len(discovery.pending_blocking)} blocking · "
|
|
132
133
|
f"{len(discovery.pending_assumptions)} assumptions"
|
|
133
134
|
)
|
devflow/core/discovery.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Discovery is deliberately separate from specification. It records the
|
|
4
4
|
questions that change scope, the answers supplied by a human, and the
|
|
5
5
|
technical assumptions proposed by DevFlow. A specification may only be
|
|
6
|
-
generated when every
|
|
6
|
+
generated when every question is answered and every proposed
|
|
7
7
|
assumption has been explicitly accepted.
|
|
8
8
|
"""
|
|
9
9
|
|
|
@@ -232,6 +232,79 @@ _COMMENT_DECISION_WORDS = {
|
|
|
232
232
|
"usuario",
|
|
233
233
|
"user",
|
|
234
234
|
}
|
|
235
|
+
_COMMENT_AUTHOR_WORDS = {
|
|
236
|
+
"author",
|
|
237
|
+
"autor",
|
|
238
|
+
"autora",
|
|
239
|
+
"escritor",
|
|
240
|
+
"writer",
|
|
241
|
+
}
|
|
242
|
+
_COMMENT_EDIT_WORDS = {
|
|
243
|
+
"actualizar",
|
|
244
|
+
"borrar",
|
|
245
|
+
"crud",
|
|
246
|
+
"delete",
|
|
247
|
+
"editar",
|
|
248
|
+
"edit",
|
|
249
|
+
"eliminar",
|
|
250
|
+
"update",
|
|
251
|
+
}
|
|
252
|
+
_COMMENT_MODERATION_WORDS = {
|
|
253
|
+
"approve",
|
|
254
|
+
"aprobar",
|
|
255
|
+
"moderacion",
|
|
256
|
+
"moderar",
|
|
257
|
+
"moderation",
|
|
258
|
+
"moderator",
|
|
259
|
+
"review",
|
|
260
|
+
"revision",
|
|
261
|
+
"revisar",
|
|
262
|
+
}
|
|
263
|
+
_COMMENT_VALIDATION_WORDS = {
|
|
264
|
+
"length",
|
|
265
|
+
"longitud",
|
|
266
|
+
"sanitize",
|
|
267
|
+
"sanitizar",
|
|
268
|
+
"validacion",
|
|
269
|
+
"validate",
|
|
270
|
+
"validation",
|
|
271
|
+
}
|
|
272
|
+
_COMMENT_ORDER_WORDS = {
|
|
273
|
+
"latest",
|
|
274
|
+
"order",
|
|
275
|
+
"orden",
|
|
276
|
+
"ordenar",
|
|
277
|
+
"pagination",
|
|
278
|
+
"paginacion",
|
|
279
|
+
"recent",
|
|
280
|
+
"sort",
|
|
281
|
+
}
|
|
282
|
+
_COMMENT_LIFECYCLE_WORDS = {
|
|
283
|
+
"anonymize",
|
|
284
|
+
"anonimizar",
|
|
285
|
+
"cascade",
|
|
286
|
+
"cascada",
|
|
287
|
+
"lifecycle",
|
|
288
|
+
"soft",
|
|
289
|
+
}
|
|
290
|
+
_COMMENT_ADMIN_WORDS = {"admin", "administracion"}
|
|
291
|
+
_COMMENT_COMPATIBILITY_WORDS = {
|
|
292
|
+
"backward",
|
|
293
|
+
"compatibilidad",
|
|
294
|
+
"compatibility",
|
|
295
|
+
"legacy",
|
|
296
|
+
"retrocompatible",
|
|
297
|
+
}
|
|
298
|
+
_AUTH_MECHANISM_WORDS = {
|
|
299
|
+
"allauth",
|
|
300
|
+
"cookie",
|
|
301
|
+
"jwt",
|
|
302
|
+
"login",
|
|
303
|
+
"oauth",
|
|
304
|
+
"session",
|
|
305
|
+
"sesion",
|
|
306
|
+
"token",
|
|
307
|
+
}
|
|
235
308
|
_PERSISTENCE_DECISIONS = {
|
|
236
309
|
"archivo",
|
|
237
310
|
"database",
|
|
@@ -408,6 +481,14 @@ class DiscoveryDocument:
|
|
|
408
481
|
if question.blocking and not question.is_answered
|
|
409
482
|
)
|
|
410
483
|
|
|
484
|
+
@property
|
|
485
|
+
def pending_questions(self) -> tuple[DiscoveryQuestion, ...]:
|
|
486
|
+
return tuple(
|
|
487
|
+
question
|
|
488
|
+
for question in self.questions
|
|
489
|
+
if not question.is_answered
|
|
490
|
+
)
|
|
491
|
+
|
|
411
492
|
@property
|
|
412
493
|
def pending_assumptions(
|
|
413
494
|
self,
|
|
@@ -420,7 +501,7 @@ class DiscoveryDocument:
|
|
|
420
501
|
|
|
421
502
|
@property
|
|
422
503
|
def derived_status(self) -> str:
|
|
423
|
-
if self.
|
|
504
|
+
if self.pending_questions or self.pending_assumptions:
|
|
424
505
|
return DISCOVERY_AWAITING
|
|
425
506
|
if self.status == DISCOVERY_PENDING:
|
|
426
507
|
return DISCOVERY_PENDING
|
|
@@ -432,7 +513,7 @@ class DiscoveryDocument:
|
|
|
432
513
|
|
|
433
514
|
def blockers(self) -> tuple[str, ...]:
|
|
434
515
|
messages: list[str] = []
|
|
435
|
-
for question in self.
|
|
516
|
+
for question in self.pending_questions:
|
|
436
517
|
messages.append(f"{question.id}: {question.question}")
|
|
437
518
|
for assumption in self.pending_assumptions:
|
|
438
519
|
messages.append(
|
|
@@ -544,13 +625,13 @@ class DiscoveryManager:
|
|
|
544
625
|
if (
|
|
545
626
|
document.status == DISCOVERY_COMPLETE
|
|
546
627
|
and (
|
|
547
|
-
document.
|
|
628
|
+
document.pending_questions
|
|
548
629
|
or document.pending_assumptions
|
|
549
630
|
)
|
|
550
631
|
):
|
|
551
632
|
msg = (
|
|
552
633
|
"Discovery is marked complete but still has pending "
|
|
553
|
-
"
|
|
634
|
+
"questions or assumptions."
|
|
554
635
|
)
|
|
555
636
|
raise DiscoveryError(msg)
|
|
556
637
|
return replace(document, status=document.derived_status)
|
|
@@ -618,6 +699,69 @@ class DiscoveryManager:
|
|
|
618
699
|
)
|
|
619
700
|
return replace(updated, status=updated.derived_status)
|
|
620
701
|
|
|
702
|
+
def add_questions(
|
|
703
|
+
self,
|
|
704
|
+
document: DiscoveryDocument,
|
|
705
|
+
questions: tuple[str, ...] | list[str],
|
|
706
|
+
*,
|
|
707
|
+
category: str = "functional_scope",
|
|
708
|
+
reason: str = (
|
|
709
|
+
"The specification agent found a decision that must be recorded "
|
|
710
|
+
"during Discovery."
|
|
711
|
+
),
|
|
712
|
+
blocking: bool = True,
|
|
713
|
+
at: str | None = None,
|
|
714
|
+
) -> DiscoveryDocument:
|
|
715
|
+
"""Append unresolved specification questions to Discovery.
|
|
716
|
+
|
|
717
|
+
New questions receive the next ``Qn`` identifiers. Duplicate
|
|
718
|
+
question text is ignored. The document is marked awaiting
|
|
719
|
+
clarification until every added question is answered.
|
|
720
|
+
"""
|
|
721
|
+
if category not in QUESTION_CATEGORIES:
|
|
722
|
+
msg = f"Invalid discovery question category: {category!r}"
|
|
723
|
+
raise DiscoveryError(msg)
|
|
724
|
+
timestamp = at or format_timestamp(self.clock.now())
|
|
725
|
+
next_number = 1
|
|
726
|
+
for question in document.questions:
|
|
727
|
+
match = re.match(r"^Q(\d+)$", question.id)
|
|
728
|
+
if match:
|
|
729
|
+
next_number = max(next_number, int(match.group(1)) + 1)
|
|
730
|
+
|
|
731
|
+
known = {
|
|
732
|
+
question.question.strip().casefold()
|
|
733
|
+
for question in document.questions
|
|
734
|
+
}
|
|
735
|
+
additions: list[DiscoveryQuestion] = []
|
|
736
|
+
for value in questions:
|
|
737
|
+
text = value.strip()
|
|
738
|
+
if not text:
|
|
739
|
+
continue
|
|
740
|
+
if len(text) > MAX_TEXT_LENGTH:
|
|
741
|
+
text = text[:MAX_TEXT_LENGTH].rstrip()
|
|
742
|
+
if text.casefold() in known:
|
|
743
|
+
continue
|
|
744
|
+
known.add(text.casefold())
|
|
745
|
+
additions.append(
|
|
746
|
+
DiscoveryQuestion(
|
|
747
|
+
id=f"Q{next_number}",
|
|
748
|
+
category=category,
|
|
749
|
+
question=text,
|
|
750
|
+
reason=reason,
|
|
751
|
+
blocking=blocking,
|
|
752
|
+
)
|
|
753
|
+
)
|
|
754
|
+
next_number += 1
|
|
755
|
+
|
|
756
|
+
if not additions:
|
|
757
|
+
return document
|
|
758
|
+
updated = replace(
|
|
759
|
+
document,
|
|
760
|
+
questions=tuple([*document.questions, *additions]),
|
|
761
|
+
updated_at=timestamp,
|
|
762
|
+
)
|
|
763
|
+
return replace(updated, status=updated.derived_status)
|
|
764
|
+
|
|
621
765
|
def accept(
|
|
622
766
|
self,
|
|
623
767
|
document: DiscoveryDocument,
|
|
@@ -758,13 +902,13 @@ class DiscoveryManager:
|
|
|
758
902
|
if (
|
|
759
903
|
document.status == DISCOVERY_COMPLETE
|
|
760
904
|
and (
|
|
761
|
-
document.
|
|
905
|
+
document.pending_questions
|
|
762
906
|
or document.pending_assumptions
|
|
763
907
|
)
|
|
764
908
|
):
|
|
765
909
|
msg = (
|
|
766
910
|
"Discovery is marked complete but still has pending "
|
|
767
|
-
"
|
|
911
|
+
"questions or assumptions."
|
|
768
912
|
)
|
|
769
913
|
raise DiscoveryError(msg)
|
|
770
914
|
return document
|
|
@@ -1103,24 +1247,171 @@ class DiscoveryPlanner:
|
|
|
1103
1247
|
)
|
|
1104
1248
|
)
|
|
1105
1249
|
|
|
1106
|
-
if
|
|
1107
|
-
words &
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
)
|
|
1250
|
+
if words & _COMMENT_WORDS:
|
|
1251
|
+
if words & _COMMENT_AUTHOR_WORDS:
|
|
1252
|
+
add_question(
|
|
1253
|
+
"functional_scope",
|
|
1254
|
+
"What does 'comments by the book author' mean here: comments "
|
|
1255
|
+
"written by users about a book and its author, or comments "
|
|
1256
|
+
"written by the book's author? Which entity does a comment "
|
|
1257
|
+
"belong to?",
|
|
1258
|
+
"The interpretation changes the actors, the data model and "
|
|
1259
|
+
"the permissions of the feature.",
|
|
1260
|
+
(
|
|
1261
|
+
"Users comment on a book; the author is only the subject.",
|
|
1262
|
+
"The book's author writes comments on their own book.",
|
|
1263
|
+
"Other (describe the intended meaning).",
|
|
1264
|
+
),
|
|
1265
|
+
)
|
|
1266
|
+
|
|
1267
|
+
if not (words & _COMMENT_DECISION_WORDS):
|
|
1268
|
+
add_question(
|
|
1269
|
+
"security_authentication",
|
|
1270
|
+
"Who may create, edit or delete comments, and which "
|
|
1271
|
+
"authentication mechanism identifies them (session login, "
|
|
1272
|
+
"API token, other)?",
|
|
1273
|
+
"Comment ownership, authentication and moderation change "
|
|
1274
|
+
"permissions, data fields and API behavior.",
|
|
1275
|
+
(
|
|
1276
|
+
"Any visitor may comment without authentication.",
|
|
1277
|
+
"Only authenticated users may comment.",
|
|
1278
|
+
"Only authenticated users may comment, edit or delete their "
|
|
1279
|
+
"own comments.",
|
|
1280
|
+
"Comments require review before publication.",
|
|
1281
|
+
),
|
|
1282
|
+
)
|
|
1283
|
+
elif not (words & _AUTH_MECHANISM_WORDS):
|
|
1284
|
+
add_question(
|
|
1285
|
+
"security_authentication",
|
|
1286
|
+
"Which authentication mechanism must a user use before "
|
|
1287
|
+
"commenting (session login, API token, OAuth, other)?",
|
|
1288
|
+
"The authentication method changes routes, dependencies, "
|
|
1289
|
+
"session handling and security tests.",
|
|
1290
|
+
(
|
|
1291
|
+
"Reuse the existing session login.",
|
|
1292
|
+
"Use API tokens for a JSON API.",
|
|
1293
|
+
"Use an external identity provider.",
|
|
1294
|
+
"Other (describe).",
|
|
1295
|
+
),
|
|
1296
|
+
)
|
|
1297
|
+
|
|
1298
|
+
if not (words & _COMMENT_EDIT_WORDS):
|
|
1299
|
+
add_question(
|
|
1300
|
+
"user_behavior",
|
|
1301
|
+
"May users edit or delete their own comments after creating "
|
|
1302
|
+
"them? May administrators or moderators delete any comment?",
|
|
1303
|
+
"Edit and delete rules change permissions, auditing, "
|
|
1304
|
+
"endpoints and acceptance criteria.",
|
|
1305
|
+
(
|
|
1306
|
+
"No editing or deletion after creation.",
|
|
1307
|
+
"Users may edit and delete only their own comments.",
|
|
1308
|
+
"Users may edit their own comments; administrators may "
|
|
1309
|
+
"delete any comment.",
|
|
1310
|
+
),
|
|
1311
|
+
)
|
|
1312
|
+
|
|
1313
|
+
if not (words & _COMMENT_MODERATION_WORDS):
|
|
1314
|
+
add_question(
|
|
1315
|
+
"user_behavior",
|
|
1316
|
+
"Are comments published immediately, or do they require "
|
|
1317
|
+
"moderation or review before they are visible?",
|
|
1318
|
+
"Moderation changes visibility, status fields, permissions "
|
|
1319
|
+
"and the user-visible workflow.",
|
|
1320
|
+
(
|
|
1321
|
+
"Publish immediately.",
|
|
1322
|
+
"Hold every comment for moderation.",
|
|
1323
|
+
"Only hold comments that match a risk rule.",
|
|
1324
|
+
),
|
|
1325
|
+
)
|
|
1326
|
+
|
|
1327
|
+
if not (words & _COMMENT_VALIDATION_WORDS):
|
|
1328
|
+
add_question(
|
|
1329
|
+
"user_behavior",
|
|
1330
|
+
"What validation applies to comment text: required non-empty "
|
|
1331
|
+
"content, minimum or maximum length, and sanitization?",
|
|
1332
|
+
"Validation rules change storage limits, error handling and "
|
|
1333
|
+
"security tests.",
|
|
1334
|
+
(
|
|
1335
|
+
"Only reject empty comments.",
|
|
1336
|
+
"Set a maximum length and reject empty comments.",
|
|
1337
|
+
"Other (describe the limits).",
|
|
1338
|
+
),
|
|
1339
|
+
)
|
|
1340
|
+
|
|
1341
|
+
if not (words & _COMMENT_ORDER_WORDS):
|
|
1342
|
+
add_question(
|
|
1343
|
+
"functional_scope",
|
|
1344
|
+
"In what order should comments be displayed, and should all "
|
|
1345
|
+
"comments be shown or only a limited page?",
|
|
1346
|
+
"Ordering and pagination change the query, API contract and "
|
|
1347
|
+
"user-visible behavior.",
|
|
1348
|
+
(
|
|
1349
|
+
"Newest first, show all comments.",
|
|
1350
|
+
"Oldest first, show all comments.",
|
|
1351
|
+
"Newest first with pagination.",
|
|
1352
|
+
),
|
|
1353
|
+
)
|
|
1354
|
+
|
|
1355
|
+
if not (words & _COMMENT_LIFECYCLE_WORDS):
|
|
1356
|
+
add_question(
|
|
1357
|
+
"data_persistence",
|
|
1358
|
+
"What should happen to comments when the related book or the "
|
|
1359
|
+
"commenting user is deleted: cascade delete, anonymize, or "
|
|
1360
|
+
"prevent deletion?",
|
|
1361
|
+
"Data lifecycle rules change foreign keys, migrations and "
|
|
1362
|
+
"retention behavior.",
|
|
1363
|
+
(
|
|
1364
|
+
"Delete comments in cascade.",
|
|
1365
|
+
"Anonymize comments and keep them.",
|
|
1366
|
+
"Prevent deleting a book or user that has comments.",
|
|
1367
|
+
),
|
|
1368
|
+
)
|
|
1369
|
+
|
|
1370
|
+
if not (words & _COMMENT_ADMIN_WORDS):
|
|
1371
|
+
add_question(
|
|
1372
|
+
"functional_scope",
|
|
1373
|
+
"Should the new comment model be registered in the admin "
|
|
1374
|
+
"site, and which list, search or filter fields are required?",
|
|
1375
|
+
"Admin registration changes the operability of the feature "
|
|
1376
|
+
"and the fields that must be searchable.",
|
|
1377
|
+
(
|
|
1378
|
+
"Register comments in the admin with basic list fields.",
|
|
1379
|
+
"Register comments with search and filters.",
|
|
1380
|
+
"Do not register comments in the admin.",
|
|
1381
|
+
),
|
|
1382
|
+
)
|
|
1383
|
+
|
|
1384
|
+
if not (words & _COMMENT_COMPATIBILITY_WORDS):
|
|
1385
|
+
add_question(
|
|
1386
|
+
"user_behavior",
|
|
1387
|
+
"Are there backward-compatibility requirements for existing "
|
|
1388
|
+
"data, models, URLs, templates or API clients?",
|
|
1389
|
+
"Compatibility constraints change migrations, routing and "
|
|
1390
|
+
"the allowed scope of the change.",
|
|
1391
|
+
(
|
|
1392
|
+
"Keep existing models, URLs and template behavior unchanged.",
|
|
1393
|
+
"Migrations may change existing behavior.",
|
|
1394
|
+
"Other (describe the compatibility rules).",
|
|
1395
|
+
),
|
|
1396
|
+
)
|
|
1397
|
+
|
|
1398
|
+
if not _has_phrase(
|
|
1399
|
+
text,
|
|
1400
|
+
{"out of scope", "fuera de alcance", "out-of-scope"},
|
|
1401
|
+
):
|
|
1402
|
+
add_question(
|
|
1403
|
+
"functional_scope",
|
|
1404
|
+
"What is explicitly out of scope for this comment feature "
|
|
1405
|
+
"(for example editing, moderation, ratings, notifications or "
|
|
1406
|
+
"an external API)?",
|
|
1407
|
+
"An explicit exclusion prevents the specification from "
|
|
1408
|
+
"silently expanding the change.",
|
|
1409
|
+
(
|
|
1410
|
+
"Only create and list comments.",
|
|
1411
|
+
"Include editing and deleting own comments.",
|
|
1412
|
+
"Other (describe the exclusions).",
|
|
1413
|
+
),
|
|
1414
|
+
)
|
|
1124
1415
|
|
|
1125
1416
|
if (
|
|
1126
1417
|
words & _DATA_WORDS
|
|
@@ -1206,7 +1497,7 @@ class DiscoveryPlanner:
|
|
|
1206
1497
|
),
|
|
1207
1498
|
)
|
|
1208
1499
|
|
|
1209
|
-
questions = questions[:
|
|
1500
|
+
questions = questions[:10]
|
|
1210
1501
|
question_ids = {question.id for question in questions}
|
|
1211
1502
|
assumptions = [
|
|
1212
1503
|
assumption
|
devflow/core/recovery.py
CHANGED
|
@@ -55,6 +55,17 @@ class ChangeInspection:
|
|
|
55
55
|
and not self.orphans
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
+
@property
|
|
59
|
+
def can_resume(self) -> bool:
|
|
60
|
+
"""Return whether Discovery is complete but the spec is missing."""
|
|
61
|
+
return (
|
|
62
|
+
not self.events_present
|
|
63
|
+
and not self.workflow_present
|
|
64
|
+
and self.discovery_present
|
|
65
|
+
and self.discovery_complete
|
|
66
|
+
and not self.spec_present
|
|
67
|
+
)
|
|
68
|
+
|
|
58
69
|
|
|
59
70
|
@dataclass(frozen=True)
|
|
60
71
|
class RecoveryResult:
|
|
@@ -181,6 +192,40 @@ def inspect_change(
|
|
|
181
192
|
)
|
|
182
193
|
|
|
183
194
|
|
|
195
|
+
def ensure_resumable_state(
|
|
196
|
+
config: DevFlowConfig,
|
|
197
|
+
location: ChangeLocation,
|
|
198
|
+
) -> bool:
|
|
199
|
+
"""Create missing workflow state so ``spec --continue`` can resume.
|
|
200
|
+
|
|
201
|
+
Discovery is registered with its current digest. The specification is
|
|
202
|
+
not required or created. Returns ``True`` when state was created.
|
|
203
|
+
"""
|
|
204
|
+
if location.events_path.is_file() or location.workflow_path.is_file():
|
|
205
|
+
return False
|
|
206
|
+
discovery_path = location.directory / "discovery.yaml"
|
|
207
|
+
if not discovery_path.is_file():
|
|
208
|
+
return False
|
|
209
|
+
|
|
210
|
+
inspection = inspect_change(config, location)
|
|
211
|
+
manager = WorkflowStateManager(
|
|
212
|
+
config.specifications_path,
|
|
213
|
+
project_root=config.root,
|
|
214
|
+
)
|
|
215
|
+
manager.initialize_change(location.directory)
|
|
216
|
+
location = WorkflowLocator(config.specifications_path).from_directory(
|
|
217
|
+
location.directory
|
|
218
|
+
)
|
|
219
|
+
manager.record_artifact(
|
|
220
|
+
location,
|
|
221
|
+
stage="discovery",
|
|
222
|
+
path=discovery_path,
|
|
223
|
+
validated=inspection.discovery_complete,
|
|
224
|
+
source="existing",
|
|
225
|
+
)
|
|
226
|
+
return True
|
|
227
|
+
|
|
228
|
+
|
|
184
229
|
def recover_change(
|
|
185
230
|
config: DevFlowConfig,
|
|
186
231
|
location: ChangeLocation,
|