devflow-toolkit 0.3.3__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/spec.py +3 -3
- devflow/commands/status.py +1 -0
- devflow/core/discovery.py +317 -26
- devflow/core/spec_workflow.py +115 -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.3.dist-info → devflow_toolkit-0.3.4.dist-info}/METADATA +52 -30
- {devflow_toolkit-0.3.3.dist-info → devflow_toolkit-0.3.4.dist-info}/RECORD +17 -17
- {devflow_toolkit-0.3.3.dist-info → devflow_toolkit-0.3.4.dist-info}/WHEEL +0 -0
- {devflow_toolkit-0.3.3.dist-info → devflow_toolkit-0.3.4.dist-info}/entry_points.txt +0 -0
- {devflow_toolkit-0.3.3.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/spec.py
CHANGED
|
@@ -245,7 +245,7 @@ def _create_specification(
|
|
|
245
245
|
if result.discovery is not None:
|
|
246
246
|
console.print(
|
|
247
247
|
f"[bold]Discovery:[/bold] {result.discovery.status} "
|
|
248
|
-
f"({len(result.discovery.
|
|
248
|
+
f"({len(result.discovery.pending_questions)} pending, "
|
|
249
249
|
f"{len(result.discovery.pending_assumptions)} assumptions)"
|
|
250
250
|
)
|
|
251
251
|
if result.discovery_digest:
|
|
@@ -568,6 +568,6 @@ def _print_result(
|
|
|
568
568
|
f"[bold]Discovery:[/bold] {result.discovery.status}"
|
|
569
569
|
)
|
|
570
570
|
console.print(
|
|
571
|
-
"\nNext: review the specification
|
|
572
|
-
"
|
|
571
|
+
"\nNext: review the specification and approve it before "
|
|
572
|
+
"implementation."
|
|
573
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/spec_workflow.py
CHANGED
|
@@ -53,10 +53,25 @@ from devflow.prompts import (
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
class SpecOpenQuestionsError(Exception):
|
|
57
|
+
"""Raised when the specification agent leaves decisions unresolved."""
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
questions: tuple[str, ...],
|
|
62
|
+
warnings: tuple[str, ...] = (),
|
|
63
|
+
) -> None:
|
|
64
|
+
self.questions = questions
|
|
65
|
+
self.warnings = warnings
|
|
66
|
+
super().__init__(
|
|
67
|
+
"the specification agent left open questions that belong in "
|
|
68
|
+
"Discovery"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
56
72
|
@dataclass(frozen=True)
|
|
57
73
|
class SpecWorkflowRequest:
|
|
58
74
|
"""Everything the workflow needs to generate one specification."""
|
|
59
|
-
|
|
60
75
|
description: str
|
|
61
76
|
config: DevFlowConfig
|
|
62
77
|
execution_mode: str
|
|
@@ -534,17 +549,78 @@ class SpecWorkflow:
|
|
|
534
549
|
warnings.extend(adapter.permission_warnings(run_context))
|
|
535
550
|
|
|
536
551
|
invocation = adapter.build_run(run_context)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
552
|
+
try:
|
|
553
|
+
spec, run_warnings = self._run_agent(
|
|
554
|
+
prepared=prepared,
|
|
555
|
+
adapter=adapter,
|
|
556
|
+
invocation=invocation,
|
|
557
|
+
execution_mode=request.execution_mode,
|
|
558
|
+
output_path=output_path,
|
|
559
|
+
project_mode=project_mode,
|
|
560
|
+
architecture=architecture,
|
|
561
|
+
discovery_digest=discovery_digest,
|
|
562
|
+
archive=archive_existing,
|
|
563
|
+
)
|
|
564
|
+
except SpecOpenQuestionsError as error:
|
|
565
|
+
if prepared.path.is_file():
|
|
566
|
+
ArtifactStore(prepared.root).archive(prepared.path)
|
|
567
|
+
prepared.path.unlink(missing_ok=True)
|
|
568
|
+
discovery = discovery_manager.add_questions(
|
|
569
|
+
discovery,
|
|
570
|
+
error.questions,
|
|
571
|
+
)
|
|
572
|
+
discovery_path, discovery_digest = discovery_manager.write(
|
|
573
|
+
prepared.directory,
|
|
574
|
+
discovery,
|
|
575
|
+
)
|
|
576
|
+
discovery = discovery_manager.load(
|
|
577
|
+
prepared.directory,
|
|
578
|
+
required=True,
|
|
579
|
+
)
|
|
580
|
+
discovery_digest = self._discovery_digest(
|
|
581
|
+
discovery_manager,
|
|
582
|
+
prepared.directory,
|
|
583
|
+
)
|
|
584
|
+
prepared = self.manager.prepare(
|
|
585
|
+
description=description,
|
|
586
|
+
config=config,
|
|
587
|
+
project=project,
|
|
588
|
+
constitution=constitution,
|
|
589
|
+
profiles=profiles,
|
|
590
|
+
project_mode=project_mode,
|
|
591
|
+
architecture=architecture,
|
|
592
|
+
discovery=discovery,
|
|
593
|
+
discovery_digest=discovery_digest,
|
|
594
|
+
directory=prepared.directory,
|
|
595
|
+
spec_id=prepared.spec_id,
|
|
596
|
+
)
|
|
597
|
+
self.manager.materialize_context(prepared)
|
|
598
|
+
warnings.append(
|
|
599
|
+
"the specification agent found decisions that were not "
|
|
600
|
+
"answered during Discovery. They were added to discovery.yaml "
|
|
601
|
+
"and no specification was written."
|
|
602
|
+
)
|
|
603
|
+
return self._build_result(
|
|
604
|
+
spec=None,
|
|
605
|
+
harness_name=adapter.display_name,
|
|
606
|
+
execution_mode=request.execution_mode,
|
|
607
|
+
warnings=warnings,
|
|
608
|
+
run_warnings=list(error.warnings),
|
|
609
|
+
setup_result=setup_result,
|
|
610
|
+
constitution=constitution,
|
|
611
|
+
project_mode=project_mode,
|
|
612
|
+
architecture=architecture,
|
|
613
|
+
discovery=discovery,
|
|
614
|
+
discovery_digest=discovery_digest,
|
|
615
|
+
discovery_path=discovery_path,
|
|
616
|
+
discovery_source="agent",
|
|
617
|
+
discovery_created=discovery_created,
|
|
618
|
+
blocked=True,
|
|
619
|
+
spec_written=False,
|
|
620
|
+
spec_reused=False,
|
|
621
|
+
continuation=continuation,
|
|
622
|
+
directory=prepared.directory,
|
|
623
|
+
)
|
|
548
624
|
return self._build_result(
|
|
549
625
|
spec=spec,
|
|
550
626
|
harness_name=adapter.display_name,
|
|
@@ -762,6 +838,11 @@ class SpecWorkflow:
|
|
|
762
838
|
)
|
|
763
839
|
if prepared.path.is_file():
|
|
764
840
|
content = prepared.path.read_text(encoding="utf-8")
|
|
841
|
+
self._raise_if_open_questions(
|
|
842
|
+
content,
|
|
843
|
+
discovery_digest,
|
|
844
|
+
run_warnings,
|
|
845
|
+
)
|
|
765
846
|
valid, reason = self.manager.validate(
|
|
766
847
|
content,
|
|
767
848
|
project_mode=project_mode,
|
|
@@ -813,6 +894,11 @@ class SpecWorkflow:
|
|
|
813
894
|
)
|
|
814
895
|
|
|
815
896
|
content = run_result.file_output or run_result.stdout
|
|
897
|
+
self._raise_if_open_questions(
|
|
898
|
+
content,
|
|
899
|
+
discovery_digest,
|
|
900
|
+
run_warnings,
|
|
901
|
+
)
|
|
816
902
|
valid, reason = self.manager.validate(
|
|
817
903
|
content,
|
|
818
904
|
project_mode=project_mode,
|
|
@@ -842,6 +928,23 @@ class SpecWorkflow:
|
|
|
842
928
|
if output_path is not None:
|
|
843
929
|
output_path.unlink(missing_ok=True)
|
|
844
930
|
|
|
931
|
+
def _raise_if_open_questions(
|
|
932
|
+
self,
|
|
933
|
+
content: str,
|
|
934
|
+
discovery_digest: str,
|
|
935
|
+
run_warnings: list[str],
|
|
936
|
+
) -> None:
|
|
937
|
+
"""Return agent-discovered decisions to Discovery instead of a spec."""
|
|
938
|
+
if not discovery_digest:
|
|
939
|
+
return
|
|
940
|
+
cleaned = self.manager.clean_agent_output(content)
|
|
941
|
+
questions = self.manager.extract_open_questions(cleaned)
|
|
942
|
+
if questions:
|
|
943
|
+
raise SpecOpenQuestionsError(
|
|
944
|
+
questions,
|
|
945
|
+
tuple(run_warnings),
|
|
946
|
+
)
|
|
947
|
+
|
|
845
948
|
def _profile_warnings(
|
|
846
949
|
self,
|
|
847
950
|
config: DevFlowConfig,
|
devflow/core/specification.py
CHANGED
|
@@ -921,6 +921,8 @@ class SpecificationManager:
|
|
|
921
921
|
if source == "static"
|
|
922
922
|
else self.extract_open_questions(cleaned) or prepared.questions
|
|
923
923
|
)
|
|
924
|
+
if prepared.discovery is not None and prepared.discovery.is_complete:
|
|
925
|
+
questions = ()
|
|
924
926
|
return GeneratedSpec(
|
|
925
927
|
spec_id=prepared.spec_id,
|
|
926
928
|
title=prepared.title,
|
|
@@ -980,6 +982,12 @@ class SpecificationManager:
|
|
|
980
982
|
False,
|
|
981
983
|
"the Discovery digest is missing from the specification",
|
|
982
984
|
)
|
|
985
|
+
if discovery_digest and self.extract_open_questions(cleaned):
|
|
986
|
+
return (
|
|
987
|
+
False,
|
|
988
|
+
"section 7 lists open questions; every question must be "
|
|
989
|
+
"answered in Discovery before the specification is valid",
|
|
990
|
+
)
|
|
983
991
|
if mode == "greenfield":
|
|
984
992
|
return self._validate_greenfield(cleaned, architecture)
|
|
985
993
|
return True, ""
|
|
@@ -1318,31 +1326,7 @@ class SpecificationManager:
|
|
|
1318
1326
|
for blocker in discovery.blockers():
|
|
1319
1327
|
lines.append(f"- {blocker}")
|
|
1320
1328
|
return lines
|
|
1321
|
-
|
|
1322
|
-
"Discovery is complete. No blocking open questions remain.",
|
|
1323
|
-
]
|
|
1324
|
-
decisions = discovery.decisions()
|
|
1325
|
-
if decisions:
|
|
1326
|
-
lines.extend(
|
|
1327
|
-
[
|
|
1328
|
-
"",
|
|
1329
|
-
"Decisions consolidated during Discovery:",
|
|
1330
|
-
"",
|
|
1331
|
-
]
|
|
1332
|
-
)
|
|
1333
|
-
for decision in decisions:
|
|
1334
|
-
lines.append(f"- {decision}")
|
|
1335
|
-
if questions:
|
|
1336
|
-
lines.extend(
|
|
1337
|
-
[
|
|
1338
|
-
"",
|
|
1339
|
-
"Non-blocking questions recorded by static analysis:",
|
|
1340
|
-
"",
|
|
1341
|
-
]
|
|
1342
|
-
)
|
|
1343
|
-
for index, question in enumerate(questions, start=1):
|
|
1344
|
-
lines.append(f"{index}. {question}")
|
|
1345
|
-
return lines
|
|
1329
|
+
return ["None."]
|
|
1346
1330
|
|
|
1347
1331
|
if questions:
|
|
1348
1332
|
return [
|
devflow/core/state/manager.py
CHANGED
|
@@ -64,6 +64,7 @@ from devflow.core.state.transitions import (
|
|
|
64
64
|
ensure_transition,
|
|
65
65
|
required_artifacts,
|
|
66
66
|
)
|
|
67
|
+
from devflow.core.specification import SpecificationManager
|
|
67
68
|
|
|
68
69
|
_PROJECTION_HEADER = (
|
|
69
70
|
"# DevFlow workflow state.\n"
|
|
@@ -522,6 +523,28 @@ class WorkflowStateManager:
|
|
|
522
523
|
spec_record = state.artifacts.get("spec")
|
|
523
524
|
architecture_digest = ""
|
|
524
525
|
if spec_record is not None:
|
|
526
|
+
if discovery_digest:
|
|
527
|
+
spec_path = self._artifact_path(spec_record.path)
|
|
528
|
+
try:
|
|
529
|
+
spec_content = spec_path.read_text(encoding="utf-8")
|
|
530
|
+
except (OSError, UnicodeDecodeError) as error:
|
|
531
|
+
msg = (
|
|
532
|
+
"Cannot approve stage 'spec': spec.md cannot be read. "
|
|
533
|
+
"Regenerate the specification."
|
|
534
|
+
)
|
|
535
|
+
raise StaleArtifactError(msg) from error
|
|
536
|
+
questions = SpecificationManager().extract_open_questions(
|
|
537
|
+
spec_content
|
|
538
|
+
)
|
|
539
|
+
if questions:
|
|
540
|
+
msg = (
|
|
541
|
+
"Cannot approve stage 'spec': section 7 still contains "
|
|
542
|
+
f"{len(questions)} open question(s). They must be "
|
|
543
|
+
"answered in Discovery and the specification generated "
|
|
544
|
+
f"again with 'devflow spec --continue "
|
|
545
|
+
f"{location.spec_id}'."
|
|
546
|
+
)
|
|
547
|
+
raise ArtifactNotValidatedError(msg)
|
|
525
548
|
architecture_digest = str(
|
|
526
549
|
spec_record.metadata.get("architecture_digest", "")
|
|
527
550
|
)
|
devflow/prompts/__init__.py
CHANGED
|
@@ -147,18 +147,23 @@ def _discovery_mode_instructions(
|
|
|
147
147
|
if execution_mode != "interactive":
|
|
148
148
|
return (
|
|
149
149
|
"Discovery is incomplete. Do not write a specification and do "
|
|
150
|
-
"not invent answers. Report
|
|
150
|
+
"not invent answers. Report every pending question, not only the "
|
|
151
|
+
"blocking ones, and stop."
|
|
151
152
|
)
|
|
152
153
|
if not permissions.allow_spec_write:
|
|
153
154
|
return (
|
|
154
155
|
"Discovery is incomplete, but artifact writes are disabled. Ask "
|
|
155
|
-
"the user for explicit answers
|
|
156
|
+
"the user for explicit answers to every pending question and for "
|
|
157
|
+
"explicit acceptance of every assumption, then report them "
|
|
156
158
|
"verbatim. Do not write the specification."
|
|
157
159
|
)
|
|
158
160
|
return (
|
|
159
161
|
"You are running interactively. Read the discovery record and ask "
|
|
160
|
-
"the user
|
|
161
|
-
"
|
|
162
|
+
"the user about every pending question and every proposed "
|
|
163
|
+
"assumption, whether or not a question is marked blocking. If "
|
|
164
|
+
"reading the request or context reveals a missing decision, append "
|
|
165
|
+
"a new question with the next `Qn` identifier before continuing. "
|
|
166
|
+
"Record only explicit answers. Update the same "
|
|
162
167
|
f"`{discovery_path}` file in place, preserving every existing id, "
|
|
163
168
|
"category, blocking flag and question text. Set an answered "
|
|
164
169
|
"question to `status: answered` with `answer`, `answered_by: user` "
|
|
@@ -166,8 +171,8 @@ def _discovery_mode_instructions(
|
|
|
166
171
|
"assumption to `status: accepted` with `accepted_by: user` and "
|
|
167
172
|
"`accepted_at`. Never accept an assumption on the user's behalf. "
|
|
168
173
|
"Never change the request, project_mode, spec_id or change. Do not "
|
|
169
|
-
"write or modify `spec.md` in this phase. When no pending
|
|
170
|
-
"
|
|
174
|
+
"write or modify `spec.md` in this phase. When no pending question "
|
|
175
|
+
"and no unaccepted assumption remains, stop and report that "
|
|
171
176
|
"Discovery is complete."
|
|
172
177
|
)
|
|
173
178
|
|
|
@@ -180,26 +185,38 @@ def _mode_instructions(
|
|
|
180
185
|
if execution_mode == "interactive":
|
|
181
186
|
if permissions.allow_spec_write:
|
|
182
187
|
return (
|
|
183
|
-
"You are running interactively.
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
|
|
187
|
-
"
|
|
188
|
-
"
|
|
188
|
+
"You are running interactively. Discovery is complete, so use "
|
|
189
|
+
"its recorded answers and accepted assumptions as settled "
|
|
190
|
+
"decisions. Do not reopen them. If you find a genuinely new "
|
|
191
|
+
"decision that Discovery did not cover, do not write the "
|
|
192
|
+
"specification: report the unresolved decision as a numbered "
|
|
193
|
+
"item in section 7 so DevFlow can return it to Discovery. "
|
|
194
|
+
"Otherwise write the complete specification to "
|
|
195
|
+
f"`{spec_path}` using the available file tools. Section 7 must "
|
|
196
|
+
"be exactly `None.` when no new decision is needed. Do not "
|
|
197
|
+
"finish until that file exists and contains the complete "
|
|
198
|
+
"document."
|
|
189
199
|
)
|
|
190
200
|
return (
|
|
191
201
|
"You are running interactively, but specification writes are "
|
|
192
|
-
"disabled.
|
|
202
|
+
"disabled. Use Discovery decisions as settled. If a new decision "
|
|
203
|
+
"is missing, put each unresolved item as a numbered item in "
|
|
204
|
+
"section 7 so DevFlow can return it to Discovery; otherwise "
|
|
205
|
+
"section 7 must be exactly `None.`. Return the complete "
|
|
193
206
|
"specification as your final message. DevFlow will record the "
|
|
194
207
|
"deterministic fallback specification."
|
|
195
208
|
)
|
|
196
209
|
|
|
197
210
|
return (
|
|
198
211
|
"You are running non-interactively. Do not ask the user questions "
|
|
199
|
-
"and do not write files.
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
|
|
212
|
+
"and do not write files. Discovery decisions are settled; do not "
|
|
213
|
+
"reopen them or invent answers. Section 7 must be exactly `None.` "
|
|
214
|
+
"when the specification is complete. If a decision is missing, "
|
|
215
|
+
"list each unresolved question as a numbered item in section 7; "
|
|
216
|
+
"DevFlow will reject the specification and return those questions "
|
|
217
|
+
"to Discovery for a human answer. Return only the complete Markdown "
|
|
218
|
+
"specification as your final answer. DevFlow will validate it and "
|
|
219
|
+
f"write it to `{spec_path}`."
|
|
203
220
|
)
|
|
204
221
|
|
|
205
222
|
|
devflow/prompts/discovery.md
CHANGED
|
@@ -20,15 +20,57 @@ Discovery decides whether the request is ready to become a
|
|
|
20
20
|
specification. It does not write the specification and it does not
|
|
21
21
|
change application code.
|
|
22
22
|
|
|
23
|
+
Discovery is requirement gathering, not a formality. Before asking the
|
|
24
|
+
first question, read the request and context and identify every
|
|
25
|
+
decision that changes behavior, data, security, permissions, lifecycle
|
|
26
|
+
or scope. Add those decisions to the discovery record as new questions
|
|
27
|
+
with the next `Qn` identifiers. Do not wait for the static analysis
|
|
28
|
+
planner to guess them.
|
|
29
|
+
|
|
23
30
|
A specification may only be generated when:
|
|
24
31
|
|
|
25
|
-
- every question
|
|
32
|
+
- every question has an explicit answer, whether or not it is marked
|
|
33
|
+
`blocking`; and
|
|
26
34
|
- every proposed assumption has been explicitly accepted.
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
question
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
`blocking` only prioritizes the conversation. A pending non-blocking
|
|
37
|
+
question still prevents specification generation. Never change a
|
|
38
|
+
question from blocking to non-blocking to avoid asking it, and never
|
|
39
|
+
mark Discovery complete while any question is unanswered.
|
|
40
|
+
|
|
41
|
+
## Required Requirement Checklist
|
|
42
|
+
|
|
43
|
+
For every feature that creates, changes or exposes data, cover these
|
|
44
|
+
areas before completing Discovery. Ask only the questions that the
|
|
45
|
+
request and context do not already answer, but never skip an area
|
|
46
|
+
silently:
|
|
47
|
+
|
|
48
|
+
- **Interpretation:** what the user means by ambiguous nouns, actors or
|
|
49
|
+
relationships, and which entity owns the new behavior.
|
|
50
|
+
- **Authentication and authorization:** who may perform each action,
|
|
51
|
+
how identity is established, and which permission checks apply.
|
|
52
|
+
- **Security:** untrusted input, authorization bypass, injection,
|
|
53
|
+
disclosure, rate limiting and other abuse cases that change the
|
|
54
|
+
design.
|
|
55
|
+
- **Moderation and publication:** whether content is public
|
|
56
|
+
immediately, needs review, or has an approval workflow.
|
|
57
|
+
- **Data lifecycle:** retention, cascade deletion, anonymization and
|
|
58
|
+
behavior when related records are deleted.
|
|
59
|
+
- **Validation:** required fields, size limits, formats and
|
|
60
|
+
sanitization.
|
|
61
|
+
- **Ordering and pagination:** display order, limits and stable
|
|
62
|
+
pagination.
|
|
63
|
+
- **Administration:** whether operators need admin registration,
|
|
64
|
+
search, filters or audit visibility.
|
|
65
|
+
- **Compatibility:** existing data, URLs, templates, clients and
|
|
66
|
+
migrations that must keep working.
|
|
67
|
+
- **Out of scope:** what this change explicitly does not include.
|
|
68
|
+
|
|
69
|
+
For user-generated content such as comments, at minimum resolve:
|
|
70
|
+
authorship, interpretation of who writes the content, create/edit/
|
|
71
|
+
delete permissions, moderation, authentication mechanism, validation,
|
|
72
|
+
ordering, lifecycle on parent deletion, admin registration,
|
|
73
|
+
compatibility and out-of-scope items.
|
|
32
74
|
|
|
33
75
|
## Non-Negotiable Boundaries
|
|
34
76
|
|
|
@@ -41,6 +83,8 @@ dependencies, deployment or architecture boundaries.
|
|
|
41
83
|
explicit human action.
|
|
42
84
|
- Preserve every existing id, question text, category, blocking flag,
|
|
43
85
|
option, request, `spec_id`, `change` and `project_mode`.
|
|
86
|
+
- When you discover a requirement gap, append a new question instead
|
|
87
|
+
of hiding it in an answer or an assumption.
|
|
44
88
|
- Record only what the user explicitly said. Do not summarize away
|
|
45
89
|
details that change scope.
|
|
46
90
|
|
|
@@ -92,8 +136,8 @@ An answered question requires `answer`, `answered_by` and
|
|
|
92
136
|
`accepted_at`. A pending item must not contain those fields.
|
|
93
137
|
|
|
94
138
|
Update `updated_at` whenever the file changes. Set `status` to
|
|
95
|
-
`awaiting_clarification` while
|
|
96
|
-
|
|
139
|
+
`awaiting_clarification` while any question is unanswered or any
|
|
140
|
+
assumption is unaccepted, and to `complete` only when nothing remains.
|
|
97
141
|
|
|
98
142
|
## Conversation Rules
|
|
99
143
|
|
|
@@ -101,11 +145,16 @@ remains, and to `complete` only when nothing does.
|
|
|
101
145
|
- Explain why the answer changes the specification.
|
|
102
146
|
- Offer the recorded options when they exist, but accept a free-form
|
|
103
147
|
answer when it is clearer.
|
|
148
|
+
- Prefer a concrete, secure default as one of the options, but never
|
|
149
|
+
select it without an explicit answer.
|
|
104
150
|
- For each proposed assumption, state the proposal and ask for
|
|
105
151
|
explicit acceptance or rejection. If rejected, ask what to do
|
|
106
152
|
instead.
|
|
107
|
-
- Stop asking
|
|
108
|
-
|
|
153
|
+
- Stop asking only when every question is answered and every
|
|
154
|
+
assumption is accepted. A question is not optional because it is
|
|
155
|
+
marked non-blocking.
|
|
156
|
+
- If the answer to one question raises a new decision, append a new
|
|
157
|
+
question before marking Discovery complete.
|
|
109
158
|
|
|
110
159
|
## Execution Instructions
|
|
111
160
|
|
|
@@ -32,7 +32,9 @@ over generic preferences.
|
|
|
32
32
|
dependencies.
|
|
33
33
|
- Write only the DevFlow specification. Never create implementation
|
|
34
34
|
files, scaffolding or Docker definitions.
|
|
35
|
-
- Do not invent requirements.
|
|
35
|
+
- Do not invent requirements. Every decision must already be recorded in
|
|
36
|
+
Discovery. If a decision is genuinely missing, return it to Discovery
|
|
37
|
+
instead of writing an open question into an approvable specification.
|
|
36
38
|
- Do not duplicate or replace the project constitution. Reference the
|
|
37
39
|
documents that apply.
|
|
38
40
|
- Specs must remain portable between agent harnesses. Do not include
|
|
@@ -120,17 +122,21 @@ renumber the document.
|
|
|
120
122
|
- Section 2 summarizes the system to be built, not an existing system.
|
|
121
123
|
- Section 3 reproduces the declared style, modules, layers and stack
|
|
122
124
|
from the manifest. Do not add components that the manifest does not
|
|
123
|
-
declare;
|
|
125
|
+
declare; report gaps to Discovery instead of inventing them.
|
|
124
126
|
- Section 4 explains the design decisions, quality attributes,
|
|
125
127
|
fitness functions and architectural risks. State clearly that the
|
|
126
128
|
manifest is a declaration, not evidence of implemented code.
|
|
127
129
|
- Section 5 contains complete, testable functional requirements.
|
|
128
130
|
- Section 6 records constraints, the target stack and quality gates.
|
|
129
|
-
- Section 7
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
- Section 7 must be exactly `None.` when Discovery is complete. Do not
|
|
132
|
+
repeat Discovery questions, do not reopen settled decisions and do
|
|
133
|
+
not add assumptions. If a decision is genuinely missing, leave the
|
|
134
|
+
specification invalid by listing the unresolved question as a
|
|
135
|
+
numbered item in section 7; DevFlow will return it to Discovery for a
|
|
136
|
+
human answer. When a Discovery digest is provided, include that exact
|
|
137
|
+
digest in the header table, state that Discovery is complete, and
|
|
138
|
+
reference the recorded answers and accepted assumptions without
|
|
139
|
+
contradicting them.
|
|
134
140
|
- Section 8 maps acceptance criteria to functional requirements and
|
|
135
141
|
architecture boundaries.
|
|
136
142
|
- Section 9 lists the constitution documents that apply and their
|
devflow/prompts/spec.md
CHANGED
|
@@ -28,7 +28,9 @@ assumptions.
|
|
|
28
28
|
dependencies.
|
|
29
29
|
- Write only the DevFlow specification. Never create implementation
|
|
30
30
|
files.
|
|
31
|
-
- Do not invent requirements.
|
|
31
|
+
- Do not invent requirements. Every decision must already be recorded in
|
|
32
|
+
Discovery. If a decision is genuinely missing, return it to Discovery
|
|
33
|
+
instead of writing an open question into an approvable specification.
|
|
32
34
|
- Do not duplicate or replace the project constitution. Reference the
|
|
33
35
|
documents that apply.
|
|
34
36
|
- Specs must remain portable between agent harnesses. Do not include
|
|
@@ -98,11 +100,15 @@ renumber the document.
|
|
|
98
100
|
- Section 4 identifies affected areas and compatibility risks.
|
|
99
101
|
- Section 5 contains complete, testable functional requirements.
|
|
100
102
|
- Section 6 records constraints, dependencies and compatibility rules.
|
|
101
|
-
- Section 7
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
- Section 7 must be exactly `None.` when Discovery is complete. Do not
|
|
104
|
+
repeat Discovery questions, do not reopen settled decisions and do
|
|
105
|
+
not add assumptions. If a decision is genuinely missing, leave the
|
|
106
|
+
specification invalid by listing the unresolved question as a
|
|
107
|
+
numbered item in section 7; DevFlow will return it to Discovery for a
|
|
108
|
+
human answer. When a Discovery digest is provided, include that exact
|
|
109
|
+
digest in the header table, state that Discovery is complete, and
|
|
110
|
+
reference the recorded answers and accepted assumptions without
|
|
111
|
+
contradicting them.
|
|
106
112
|
- Section 8 maps acceptance criteria to functional requirements.
|
|
107
113
|
- Section 9 lists the constitution documents that apply and their
|
|
108
114
|
profile scope. Reference paths, do not copy their contents.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-toolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Specification workflow toolkit for AI-assisted software changes
|
|
5
5
|
Author: DevFlow contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -42,17 +42,21 @@ 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.
|
|
45
|
+
This is the `0.3.4` 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
|
|
49
49
|
review workflows.
|
|
50
50
|
|
|
51
51
|
Discovery decides whether a request is ready to become a
|
|
52
|
-
specification. A specification is only generated when every
|
|
53
|
-
|
|
52
|
+
specification. A specification is only generated when every question
|
|
53
|
+
has an explicit answer and every proposed assumption has been
|
|
54
54
|
explicitly accepted. Discovery is persisted, so an incomplete request
|
|
55
|
-
can be resumed across sessions and agent harnesses.
|
|
55
|
+
can be resumed across sessions and agent harnesses. Discovery is also
|
|
56
|
+
the requirement-gathering stage: ambiguity, authentication,
|
|
57
|
+
permissions, moderation, data lifecycle, validation, ordering,
|
|
58
|
+
administration, compatibility and out-of-scope decisions must be
|
|
59
|
+
resolved there, not in `spec.md`.
|
|
56
60
|
|
|
57
61
|
## The problem it solves
|
|
58
62
|
|
|
@@ -114,7 +118,7 @@ pip install devflow-toolkit
|
|
|
114
118
|
To install a specific built artifact instead:
|
|
115
119
|
|
|
116
120
|
```bash
|
|
117
|
-
pip install devflow_toolkit-0.3.
|
|
121
|
+
pip install devflow_toolkit-0.3.4-py3-none-any.whl
|
|
118
122
|
```
|
|
119
123
|
|
|
120
124
|
Verify the installation:
|
|
@@ -278,7 +282,7 @@ as an architectural constraint when it is present.
|
|
|
278
282
|
|
|
279
283
|
### Harnesses
|
|
280
284
|
|
|
281
|
-
| Harness | Status in 0.3.
|
|
285
|
+
| Harness | Status in 0.3.4 |
|
|
282
286
|
| --- | --- |
|
|
283
287
|
| OpenCode | Verified end-to-end in non-interactive mode |
|
|
284
288
|
| Codex | Integration files are generated, but not verified for this release |
|
|
@@ -361,18 +365,25 @@ assumptions:
|
|
|
361
365
|
```
|
|
362
366
|
|
|
363
367
|
Each question has a `category` and an explicit `blocking` flag. The
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
368
|
+
categories are scope, user-visible behaviour, data and persistence,
|
|
369
|
+
security and authentication, external integrations, architecture
|
|
370
|
+
boundaries, new dependencies and deployment. The `blocking` flag
|
|
371
|
+
prioritizes the conversation; it does not make a question optional.
|
|
372
|
+
Every question, blocking or not, must be answered before
|
|
373
|
+
`discovery.yaml` can be `complete` and before a specification can be
|
|
374
|
+
generated.
|
|
375
|
+
|
|
376
|
+
For user-generated content, Discovery must also resolve who writes it,
|
|
377
|
+
who may create, edit or delete it, moderation, authentication
|
|
378
|
+
mechanism, validation, ordering, lifecycle on parent deletion, admin
|
|
379
|
+
registration, compatibility and explicit out-of-scope items.
|
|
369
380
|
|
|
370
381
|
An assumption proposed by DevFlow uses `source: agent_default` and
|
|
371
382
|
starts as `pending_acceptance`. It never becomes accepted automatically.
|
|
372
383
|
A human must set `status: accepted` with `accepted_by` and `accepted_at`,
|
|
373
384
|
or reject it and record a different decision.
|
|
374
385
|
|
|
375
|
-
While
|
|
386
|
+
While any question or assumption remains unresolved:
|
|
376
387
|
|
|
377
388
|
- `discovery.yaml` and `context.md` are written;
|
|
378
389
|
- no `spec.md` is generated;
|
|
@@ -393,26 +404,35 @@ specification stale, preserves it under `history/`, and generates a new
|
|
|
393
404
|
specification bound to the new Discovery digest.
|
|
394
405
|
|
|
395
406
|
The deterministic `--no-agent` path follows the same rules. It generates
|
|
396
|
-
Discovery, records it, and stops when
|
|
397
|
-
never invents an answer to continue.
|
|
407
|
+
Discovery, records it, and stops when any question or assumption
|
|
408
|
+
remains unresolved. It never invents an answer to continue.
|
|
398
409
|
|
|
399
410
|
Changes created with `0.2.0` that have no `discovery.yaml` remain
|
|
400
411
|
approvable as legacy changes, with an explicit warning. New changes
|
|
401
412
|
require Discovery.
|
|
402
413
|
|
|
414
|
+
A generated specification is valid only when section 7 is exactly
|
|
415
|
+
`None.`. If the specification agent discovers a decision that Discovery
|
|
416
|
+
did not cover, DevFlow rejects the generated document, archives it,
|
|
417
|
+
appends the question to `discovery.yaml`, and returns the change to
|
|
418
|
+
`awaiting_clarification`. The question must be answered before a new
|
|
419
|
+
specification is generated. `devflow approve --stage spec` rejects a
|
|
420
|
+
specification that still lists open questions.
|
|
421
|
+
|
|
403
422
|
## Workflow
|
|
404
423
|
|
|
405
424
|
1. Initialize the project with `devflow init`.
|
|
406
425
|
2. Create a change and run Discovery.
|
|
407
|
-
3. Answer
|
|
426
|
+
3. Answer every question and accept or reject assumptions.
|
|
408
427
|
4. Generate the specification with `devflow spec --continue <id>`.
|
|
409
|
-
5. Review `spec.md
|
|
428
|
+
5. Review `spec.md`. It must have `None.` in section 7; unresolved
|
|
429
|
+
questions belong in Discovery.
|
|
410
430
|
6. Record the approval.
|
|
411
431
|
7. Inspect the state, artifacts and approval digests.
|
|
412
432
|
8. If artifacts exist without workflow state, diagnose with
|
|
413
433
|
`devflow doctor <id>` and repair with `devflow recover <id>`.
|
|
414
434
|
|
|
415
|
-
Available commands in `0.3.
|
|
435
|
+
Available commands in `0.3.4`:
|
|
416
436
|
|
|
417
437
|
| Command | Status |
|
|
418
438
|
| --- | --- |
|
|
@@ -452,7 +472,8 @@ The command:
|
|
|
452
472
|
proposed assumptions;
|
|
453
473
|
5. writes the deterministic evidence or declared architecture to
|
|
454
474
|
`context.md`;
|
|
455
|
-
6. stops without `spec.md` when
|
|
475
|
+
6. stops without `spec.md` when any question or assumption remains
|
|
476
|
+
unresolved;
|
|
456
477
|
7. in an interactive run, stops after Discovery is complete and prints
|
|
457
478
|
the next command, so you can choose the harness for the
|
|
458
479
|
specification;
|
|
@@ -486,13 +507,13 @@ devflow spec --continue 006
|
|
|
486
507
|
```
|
|
487
508
|
|
|
488
509
|
`--continue` is not a new specification. It reuses the stored request
|
|
489
|
-
and project mode, loads Discovery, and stops until
|
|
490
|
-
|
|
491
|
-
Discovery digest still matches;
|
|
492
|
-
specification and generates a new one. If
|
|
493
|
-
complete `discovery.yaml` without
|
|
494
|
-
the missing state and registers
|
|
495
|
-
specification.
|
|
510
|
+
and project mode, loads Discovery, and stops until every question is
|
|
511
|
+
answered and every assumption is accepted. It reuses a current
|
|
512
|
+
validated specification when the Discovery digest still matches;
|
|
513
|
+
otherwise it archives the old specification and generates a new one. If
|
|
514
|
+
an interrupted run left a complete `discovery.yaml` without
|
|
515
|
+
`workflow.yaml`, `--continue` creates the missing state and registers
|
|
516
|
+
Discovery before generating the specification.
|
|
496
517
|
|
|
497
518
|
For an existing project, DevFlow inspects relevant code and
|
|
498
519
|
dependencies. For Greenfield, it uses the declared architecture and
|
|
@@ -593,17 +614,18 @@ devflow approve 001 --stage spec
|
|
|
593
614
|
```
|
|
594
615
|
|
|
595
616
|
Approval is explicit and binds the decision to the current artifact
|
|
596
|
-
digests. For a `0.3.
|
|
617
|
+
digests. For a `0.3.4` change it binds `spec.md`, `discovery.yaml` and,
|
|
597
618
|
when a manifest applies, the architecture manifest digest. Repeating the
|
|
598
619
|
same approval is a no-op. If an artifact changes after validation,
|
|
599
620
|
DevFlow marks it stale and refuses approval until it is regenerated and
|
|
600
621
|
validated again.
|
|
601
622
|
|
|
602
623
|
Discovery must be complete before approval. If it is not, approval fails
|
|
603
|
-
and names the pending questions and assumptions.
|
|
604
|
-
|
|
624
|
+
and names the pending questions and assumptions. Approval also rejects a
|
|
625
|
+
specification whose section 7 still lists open questions. Legacy `0.2.0`
|
|
626
|
+
changes without `discovery.yaml` remain approvable with a warning.
|
|
605
627
|
|
|
606
|
-
Only the `spec` stage is available in `0.3.
|
|
628
|
+
Only the `spec` stage is available in `0.3.4`. `--stage plan` and
|
|
607
629
|
`--stage review` are rejected. There are no `plan`, `implement` or
|
|
608
630
|
`review` commands in this release.
|
|
609
631
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
devflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
devflow/cli.py,sha256=
|
|
2
|
+
devflow/cli.py,sha256=yqUpivQYGuLvAOS_36XFTxOtIXj6kmGpaHugZaT6Xfc,1168
|
|
3
3
|
devflow/adapters/__init__.py,sha256=WcsjXQTKzHNzMAHx82-sdJQeR3ceHRVqLWTUtRlaraE,867
|
|
4
4
|
devflow/adapters/agents.py,sha256=4d54hDfBgnIP4zOKcZqAG-Qa-jfuuxzFL-akZS2qYtw,1309
|
|
5
5
|
devflow/adapters/base.py,sha256=YggY_IwHExdybl5S9NjwZSlmmcw9Y6z7DhQsl3JLvXs,2055
|
|
@@ -11,25 +11,25 @@ devflow/adapters/kiro.py,sha256=8l5y7ZYffg_T9eciM28NKGHil_zgdT96mAdYK4oBZ0U,6111
|
|
|
11
11
|
devflow/adapters/opencode.py,sha256=DonmvAKyWK2v5-X2XrL0n2iptFp7qLgOlh-X8n_8I-w,6492
|
|
12
12
|
devflow/adapters/registry.py,sha256=NLd_tf7dAiZUa6gbQFcwPogurZyjbMNbzjjXozAD4xs,1177
|
|
13
13
|
devflow/commands/__init__.py,sha256=yOLtd_4R4xdlMgAzihzIT35oyV_qcz0br-aoLebRj1c,157
|
|
14
|
-
devflow/commands/approve.py,sha256=
|
|
14
|
+
devflow/commands/approve.py,sha256=KDjeyF8NZIMCdne4098QXc6uudboxVCAqauvaDMP2VE,2740
|
|
15
15
|
devflow/commands/doctor.py,sha256=vYk2i3OksbGpHEUFsqi7c4w44mAXRmY0OeEdO8h5j_M,4161
|
|
16
16
|
devflow/commands/harness.py,sha256=r_RSAi7gXK8QNucC6eV-RzXHJycmmR03dzihqLVgdiU,2791
|
|
17
17
|
devflow/commands/init.py,sha256=B-rW-etZ-Rptt9YW43YZ5mN_l3gfGczuXW9kpmHDOWQ,15420
|
|
18
18
|
devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
|
|
19
|
-
devflow/commands/spec.py,sha256=
|
|
20
|
-
devflow/commands/status.py,sha256=
|
|
19
|
+
devflow/commands/spec.py,sha256=B-hwDUX1zP_m0aMDGzGlj-AFYNNwIL4k4ICKz7rYoyI,15728
|
|
20
|
+
devflow/commands/status.py,sha256=doFXRmK0Ys-oP-w-sd6cI33n1NoAEPtq4CJAtUstyHg,4423
|
|
21
21
|
devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
|
|
22
22
|
devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
|
|
23
23
|
devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
|
|
24
24
|
devflow/core/config.py,sha256=Ft37K1r6zm3QsU6YtuqBjq2Yr9sDscC5QiqAUrsHpUw,22108
|
|
25
25
|
devflow/core/constitution.py,sha256=nPHyy7BuIyyqkn4y85UyWn2E7f5AWHbg4iZ0frF9SfE,4581
|
|
26
|
-
devflow/core/discovery.py,sha256=
|
|
26
|
+
devflow/core/discovery.py,sha256=ed0gScDUbic4YEY-1XQzc2kVlQ6-lcLXWloubyFX7dc,44204
|
|
27
27
|
devflow/core/ports.py,sha256=R6ybjAdJEdtTKFc4FMFTX0TVwRfDwPoWCsu-BHrhI5A,4071
|
|
28
28
|
devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
|
|
29
29
|
devflow/core/project.py,sha256=SINU6KSRIpX5rPlPy8nWMfQuHas_VF1bAIVafhbcgCg,13330
|
|
30
30
|
devflow/core/recovery.py,sha256=W2If6Ymb3ISwMN8IVQYCwptDUzhxejlF-P2NvMYyZP0,8818
|
|
31
|
-
devflow/core/spec_workflow.py,sha256=
|
|
32
|
-
devflow/core/specification.py,sha256=
|
|
31
|
+
devflow/core/spec_workflow.py,sha256=_GTCMewFo-Vf3XPQPRFB6YnWUqH1Menj2W9EWsXuf1A,32660
|
|
32
|
+
devflow/core/specification.py,sha256=vVlhHCdBFlnuIfA_IJPxY4sa0S0t6oX27cn_nFyevGM,65399
|
|
33
33
|
devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
|
|
34
34
|
devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
|
|
35
35
|
devflow/core/artifacts/models.py,sha256=xJjmY8jUAHxqYN9u1JEu8CbJB-IJg1xb9P-LDaP5_Hw,2049
|
|
@@ -39,7 +39,7 @@ devflow/core/state/errors.py,sha256=dgF-x4TCxQTXc1OifyT8UZSU-0PBhATjO1x6OTMagac,
|
|
|
39
39
|
devflow/core/state/events.py,sha256=IfwFCC0jbrQsH1tzADyqwm8HtWo5fR7QDD85M6JH8N0,20698
|
|
40
40
|
devflow/core/state/locator.py,sha256=J6ZnVzcY_KzwKqBXbAOnfG9FrRzSCaYMqFeMQ7ptjIc,3256
|
|
41
41
|
devflow/core/state/lock.py,sha256=94llvwHtCc5WOw-Uq8kDCu4iOBpRM4ccp6Q6fLZpYZ0,2089
|
|
42
|
-
devflow/core/state/manager.py,sha256=
|
|
42
|
+
devflow/core/state/manager.py,sha256=_KI88ZEvw2f9t0GD3N620B3I-4sWeeLC4UL5oV1sezU,28984
|
|
43
43
|
devflow/core/state/models.py,sha256=4GTrS34ymbJIyBeZkcCi0z0e1bsq67vdxRSnSQ9O3gc,4654
|
|
44
44
|
devflow/core/state/transitions.py,sha256=Go0zLhxcujWhaZEGg7JMqcC_UJU_nEFEBbpKIqrCtrs,3581
|
|
45
45
|
devflow/models/__init__.py,sha256=hXX3IDZbHgklmuzVVlpiRs5SSPnrkO5kN1-k2hIEk7E,156
|
|
@@ -55,12 +55,12 @@ devflow/profiles/django-backend/profile.yaml,sha256=SNj7a3yamdJx-P69GvIJmLkC2svO
|
|
|
55
55
|
devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOpEmgIadcaVdf6OVmll8Oec0jEjcJ4C8MfwhQ,2052
|
|
56
56
|
devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
|
|
57
57
|
devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
|
|
58
|
-
devflow/prompts/__init__.py,sha256=
|
|
59
|
-
devflow/prompts/discovery.md,sha256=
|
|
60
|
-
devflow/prompts/spec.greenfield.md,sha256=
|
|
61
|
-
devflow/prompts/spec.md,sha256=
|
|
62
|
-
devflow_toolkit-0.3.
|
|
63
|
-
devflow_toolkit-0.3.
|
|
64
|
-
devflow_toolkit-0.3.
|
|
65
|
-
devflow_toolkit-0.3.
|
|
66
|
-
devflow_toolkit-0.3.
|
|
58
|
+
devflow/prompts/__init__.py,sha256=hdixkEhocz84S3-Vvx7Xmje03VordXE8jUtqGUZMqbs,8332
|
|
59
|
+
devflow/prompts/discovery.md,sha256=EGxzDYNoH_kOL3pptTkTG89SFB9-7f43Pfew4KrUDqc,6126
|
|
60
|
+
devflow/prompts/spec.greenfield.md,sha256=BEKTN7G0B_P0bAevNeShzb_54dYu6j95_B3YqyhYK40,5154
|
|
61
|
+
devflow/prompts/spec.md,sha256=zXrNA--c8IiQJBMyxidTtLVHUIrn7Ynj6935dyje1SY,3801
|
|
62
|
+
devflow_toolkit-0.3.4.dist-info/METADATA,sha256=W7IIHKzktvTIqFQF8FjMhFhD478K4oskR-0qICYRZp8,27192
|
|
63
|
+
devflow_toolkit-0.3.4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
64
|
+
devflow_toolkit-0.3.4.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
|
|
65
|
+
devflow_toolkit-0.3.4.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
|
|
66
|
+
devflow_toolkit-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|