devflow-toolkit 0.3.28__py3-none-any.whl → 0.4.1__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/commands/spec.py CHANGED
@@ -191,6 +191,16 @@ def _create_specification(
191
191
  detector = ProjectDetector()
192
192
  root = detector.find_root(path)
193
193
  config = ConfigManager(root).load()
194
+ if config.discovery.uses_legacy_defaults:
195
+ _print_warnings(
196
+ [
197
+ "Discovery uses the old limits (follow_up 3, maximum 12, "
198
+ "max_rounds 3), which can stop Discovery before every security "
199
+ "control is covered. Set discovery.question_budget.follow_up: 6, "
200
+ "maximum: 20 and discovery.interaction.max_rounds: 5 in "
201
+ ".devflow/config.yaml."
202
+ ]
203
+ )
194
204
 
195
205
  if resume is not None:
196
206
  _ensure_continuable(config, resume)
@@ -20,6 +20,10 @@ from devflow.core.discovery import (
20
20
  DiscoveryManager,
21
21
  )
22
22
  from devflow.core.project import ProjectDetector
23
+ from devflow.core.security_baseline import (
24
+ applicable_areas,
25
+ uncovered_controls,
26
+ )
23
27
  from devflow.core.state import (
24
28
  ChangeLocation,
25
29
  ChangeStatus,
@@ -29,6 +33,7 @@ from devflow.core.state import (
29
33
  WorkflowStatus,
30
34
  artifact_blockers,
31
35
  )
36
+ from devflow.prompts import coverage_texts, security_texts
32
37
 
33
38
  console = Console()
34
39
  error_console = Console(stderr=True)
@@ -245,6 +250,31 @@ def _print_discovery(
245
250
  soft_wrap=True,
246
251
  )
247
252
 
253
+ areas = applicable_areas(security_texts("", discovery))
254
+ if areas:
255
+ console.print(
256
+ " security baseline: "
257
+ + ", ".join(area.label for area in areas),
258
+ soft_wrap=True,
259
+ )
260
+ missing = uncovered_controls(areas, coverage_texts(discovery))
261
+ if missing:
262
+ console.print(
263
+ " [yellow]level-1 controls not cited by any decision: "
264
+ + ", ".join(control.asvs_id for control in missing)
265
+ + "[/yellow]",
266
+ soft_wrap=True,
267
+ )
268
+ for risk in discovery.accepted_risks:
269
+ state = (
270
+ f"accepted by {risk.accepted_by}"
271
+ if risk.is_accepted
272
+ else "pending acceptance"
273
+ )
274
+ console.print(
275
+ f" {risk.id} [security risk] {state}: {risk.risk}",
276
+ soft_wrap=True,
277
+ )
248
278
  for note in discovery.notes:
249
279
  console.print(f" [yellow]corrected: {note}[/yellow]", soft_wrap=True)
250
280
 
devflow/core/config.py CHANGED
@@ -24,6 +24,9 @@ DEFAULT_PLANS_PATH = Path(".devflow") / "plans"
24
24
  DEFAULT_TEMPLATES_PATH = Path(".devflow") / "templates"
25
25
  DEFAULT_DOCUMENTATION_LANGUAGE = "en"
26
26
  MAX_DISCOVERY_BUDGET = 100
27
+ # follow_up, maximum and max_rounds written by `devflow init` before
28
+ # 0.4.1. They were too small once Discovery covered security levels.
29
+ LEGACY_DISCOVERY_LIMITS = (3, 12, 3)
27
30
 
28
31
  _LANGUAGE_ALIASES = {
29
32
  "aleman": "de",
@@ -214,10 +217,19 @@ class DiscoverySettings:
214
217
  """Deterministic limits for the Discovery decision loop."""
215
218
 
216
219
  question_budget_initial: int = 6
217
- question_budget_follow_up: int = 3
218
- question_budget_maximum: int = 12
219
- max_rounds: int = 3
220
+ question_budget_follow_up: int = 6
221
+ question_budget_maximum: int = 20
222
+ max_rounds: int = 5
220
223
  batch_size: int = 6
224
+
225
+ @property
226
+ def uses_legacy_defaults(self) -> bool:
227
+ """Return whether the limits are the pre-0.4.1 defaults."""
228
+ return (
229
+ self.question_budget_follow_up,
230
+ self.question_budget_maximum,
231
+ self.max_rounds,
232
+ ) == LEGACY_DISCOVERY_LIMITS
221
233
  assumptions_enabled: bool = True
222
234
  require_explicit_acceptance: bool = True
223
235
 
@@ -490,12 +502,12 @@ class ConfigManager:
490
502
  "discovery": {
491
503
  "question_budget": {
492
504
  "initial": 6,
493
- "follow_up": 3,
494
- "maximum": 12,
505
+ "follow_up": 6,
506
+ "maximum": 20,
495
507
  },
496
508
  "interaction": {
497
509
  "batch_size": 6,
498
- "max_rounds": 3,
510
+ "max_rounds": 5,
499
511
  },
500
512
  "assumptions": {
501
513
  "enabled": True,
@@ -782,13 +794,13 @@ class ConfigManager:
782
794
  maximum=100,
783
795
  )
784
796
  follow_up = self._bounded_integer(
785
- budget.get("follow_up", 3),
797
+ budget.get("follow_up", 6),
786
798
  "discovery.question_budget.follow_up",
787
799
  minimum=0,
788
800
  maximum=100,
789
801
  )
790
802
  maximum = self._bounded_integer(
791
- budget.get("maximum", 12),
803
+ budget.get("maximum", 20),
792
804
  "discovery.question_budget.maximum",
793
805
  minimum=0,
794
806
  maximum=MAX_DISCOVERY_BUDGET,
@@ -810,7 +822,7 @@ class ConfigManager:
810
822
  question_budget_follow_up=follow_up,
811
823
  question_budget_maximum=maximum,
812
824
  max_rounds=self._bounded_integer(
813
- interaction.get("max_rounds", 3),
825
+ interaction.get("max_rounds", 5),
814
826
  "discovery.interaction.max_rounds",
815
827
  minimum=1,
816
828
  maximum=20,
devflow/core/discovery.py CHANGED
@@ -157,6 +157,7 @@ ASSUMPTION_SOURCES = ("agent_default", "human", "existing_convention")
157
157
  _QUESTION_ID = re.compile(r"^Q\d{1,3}$")
158
158
  _RECOMMENDED = re.compile(r"recom+end", re.IGNORECASE)
159
159
  _ASSUMPTION_ID = re.compile(r"^A\d{1,3}$")
160
+ _RISK_ID = re.compile(r"^R\d{1,3}$")
160
161
 
161
162
  _STOPWORDS = {
162
163
  "a",
@@ -714,6 +715,41 @@ class DiscoveryAssumption:
714
715
  }
715
716
 
716
717
 
718
+ @dataclass(frozen=True)
719
+ class AcceptedRisk:
720
+ """A security control the user explicitly decided not to apply now."""
721
+
722
+ id: str
723
+ risk: str
724
+ reason: str
725
+ control: str | None = None
726
+ status: str = ASSUMPTION_PENDING
727
+ accepted_by: str | None = None
728
+ accepted_at: str | None = None
729
+ review_by: str | None = None
730
+
731
+ @property
732
+ def is_accepted(self) -> bool:
733
+ return self.status == ASSUMPTION_ACCEPTED
734
+
735
+ def to_dict(self) -> dict[str, Any]:
736
+ data: dict[str, Any] = {"id": self.id}
737
+ if self.control:
738
+ data["control"] = self.control
739
+ data.update(
740
+ {
741
+ "risk": self.risk,
742
+ "reason": self.reason,
743
+ "status": self.status,
744
+ "accepted_by": self.accepted_by,
745
+ "accepted_at": self.accepted_at,
746
+ }
747
+ )
748
+ if self.review_by:
749
+ data["review_by"] = self.review_by
750
+ return data
751
+
752
+
717
753
  @dataclass(frozen=True)
718
754
  class DiscoveryDocument:
719
755
  """Persistent discovery record for one change."""
@@ -729,6 +765,7 @@ class DiscoveryDocument:
729
765
  questions: tuple[DiscoveryQuestion, ...] = ()
730
766
  assumptions: tuple[DiscoveryAssumption, ...] = ()
731
767
  deferred: tuple[DeferredItem, ...] = ()
768
+ accepted_risks: tuple[AcceptedRisk, ...] = ()
732
769
  # Minor problems DevFlow corrected while reading the record. They are
733
770
  # reported to the user and never written back by themselves.
734
771
  notes: tuple[str, ...] = ()
@@ -800,9 +837,20 @@ class DiscoveryDocument:
800
837
  if not assumption.is_accepted
801
838
  )
802
839
 
840
+ @property
841
+ def pending_risks(self) -> tuple[AcceptedRisk, ...]:
842
+ """Return risks that still need explicit acceptance by a person."""
843
+ return tuple(
844
+ risk for risk in self.accepted_risks if not risk.is_accepted
845
+ )
846
+
803
847
  @property
804
848
  def derived_status(self) -> str:
805
- if self.pending_questions or self.pending_assumptions:
849
+ if (
850
+ self.pending_questions
851
+ or self.pending_assumptions
852
+ or self.pending_risks
853
+ ):
806
854
  return DISCOVERY_AWAITING
807
855
  if self.status == DISCOVERY_PENDING:
808
856
  return DISCOVERY_PENDING
@@ -834,6 +882,11 @@ class DiscoveryDocument:
834
882
  f"{assumption.id}: proposed assumption requires acceptance: "
835
883
  f"{assumption.value}"
836
884
  )
885
+ for risk in self.pending_risks:
886
+ messages.append(
887
+ f"{risk.id}: security risk requires explicit acceptance: "
888
+ f"{risk.risk}"
889
+ )
837
890
  if not messages and self.status == DISCOVERY_PENDING:
838
891
  messages.append("Discovery has not been completed.")
839
892
  return tuple(messages)
@@ -898,6 +951,15 @@ class DiscoveryDocument:
898
951
  if self.deferred
899
952
  else {}
900
953
  ),
954
+ **(
955
+ {
956
+ "accepted_risks": [
957
+ risk.to_dict() for risk in self.accepted_risks
958
+ ]
959
+ }
960
+ if self.accepted_risks
961
+ else {}
962
+ ),
901
963
  }
902
964
 
903
965
 
@@ -1279,6 +1341,17 @@ class DiscoveryManager:
1279
1341
  self._deferred(item, index, question_ids)
1280
1342
  for index, item in enumerate(deferred_data, start=1)
1281
1343
  )
1344
+ risks_data = _list(mapping.get("accepted_risks"), "accepted_risks")
1345
+ if len(risks_data) > MAX_ASSUMPTIONS:
1346
+ msg = f"At most {MAX_ASSUMPTIONS} accepted risks are allowed."
1347
+ raise DiscoveryError(msg)
1348
+ accepted_risks = tuple(
1349
+ self._risk(item, index, notes=notes, default_time=updated_at)
1350
+ for index, item in enumerate(risks_data, start=1)
1351
+ )
1352
+ if len({risk.id for risk in accepted_risks}) != len(accepted_risks):
1353
+ msg = "Accepted risk ids must be unique."
1354
+ raise DiscoveryError(msg)
1282
1355
 
1283
1356
  document = DiscoveryDocument(
1284
1357
  version=version,
@@ -1292,6 +1365,7 @@ class DiscoveryManager:
1292
1365
  questions=questions,
1293
1366
  assumptions=assumptions,
1294
1367
  deferred=deferred,
1368
+ accepted_risks=accepted_risks,
1295
1369
  notes=tuple(notes),
1296
1370
  )
1297
1371
  return document
@@ -1498,6 +1572,63 @@ class DiscoveryManager:
1498
1572
  next_level=next_level,
1499
1573
  )
1500
1574
 
1575
+ def _risk(
1576
+ self,
1577
+ data: object,
1578
+ index: int,
1579
+ *,
1580
+ notes: list[str],
1581
+ default_time: str,
1582
+ ) -> AcceptedRisk:
1583
+ mapping = _mapping(data, f"accepted_risks[{index}]")
1584
+ identifier = _text(mapping.get("id"), "accepted risk id")
1585
+ if not _RISK_ID.fullmatch(identifier):
1586
+ msg = f"Invalid accepted risk id: {identifier!r}"
1587
+ raise DiscoveryError(msg)
1588
+ status = _text(mapping.get("status"), f"{identifier}.status")
1589
+ if status not in ASSUMPTION_STATUSES:
1590
+ notes.append(
1591
+ f"{identifier}: unknown status {status!r} read as "
1592
+ f"{ASSUMPTION_PENDING!r}."
1593
+ )
1594
+ status = ASSUMPTION_PENDING
1595
+ accepted_by = _optional_text(
1596
+ mapping.get("accepted_by"),
1597
+ f"{identifier}.accepted_by",
1598
+ )
1599
+ accepted_at = _optional_text(
1600
+ mapping.get("accepted_at"),
1601
+ f"{identifier}.accepted_at",
1602
+ )
1603
+ if status == ASSUMPTION_ACCEPTED:
1604
+ if not accepted_by:
1605
+ accepted_by = "user"
1606
+ notes.append(f"{identifier}: missing accepted_by read as user.")
1607
+ if not accepted_at:
1608
+ accepted_at = default_time
1609
+ notes.append(
1610
+ f"{identifier}: missing accepted_at read as {default_time}."
1611
+ )
1612
+ else:
1613
+ accepted_by = None
1614
+ accepted_at = None
1615
+ return AcceptedRisk(
1616
+ id=identifier,
1617
+ control=_optional_text(
1618
+ mapping.get("control"),
1619
+ f"{identifier}.control",
1620
+ ),
1621
+ risk=_limited_text(mapping.get("risk"), f"{identifier}.risk"),
1622
+ reason=_limited_text(mapping.get("reason"), f"{identifier}.reason"),
1623
+ status=status,
1624
+ accepted_by=accepted_by,
1625
+ accepted_at=accepted_at,
1626
+ review_by=_optional_text(
1627
+ mapping.get("review_by"),
1628
+ f"{identifier}.review_by",
1629
+ ),
1630
+ )
1631
+
1501
1632
  def _deferred(
1502
1633
  self,
1503
1634
  data: object,
@@ -0,0 +1,366 @@
1
+ """Security baseline derived from OWASP ASVS 5.0.
2
+
3
+ DevFlow detects which security areas a change touches and gives
4
+ Discovery the level-1 controls to ask or inform, and the level-2
5
+ controls to offer as the next level. Detection is deterministic and
6
+ spends no tokens. Requirement identifiers follow ASVS 5.0; the control
7
+ texts are short summaries, not the normative wording.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import re
13
+ import unicodedata
14
+ from collections.abc import Iterable
15
+ from dataclasses import dataclass
16
+
17
+ ASVS_VERSION = "5.0"
18
+ ASVS_URL = (
19
+ "https://owasp.org/www-project-application-security-verification-standard/"
20
+ )
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class Control:
25
+ """One ASVS requirement summarized for Discovery."""
26
+
27
+ asvs_id: str
28
+ summary: str
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class SecurityArea:
33
+ """An ASVS chapter that a change can touch."""
34
+
35
+ key: str
36
+ chapter: str
37
+ signals: tuple[str, ...]
38
+ level1: tuple[Control, ...]
39
+ level2: tuple[Control, ...]
40
+
41
+ @property
42
+ def label(self) -> str:
43
+ return f"ASVS {ASVS_VERSION} {self.chapter}"
44
+
45
+
46
+ _AUTH_SIGNALS = (
47
+ "login",
48
+ "logout",
49
+ "log in",
50
+ "sign in",
51
+ "sign up",
52
+ "signup",
53
+ "register",
54
+ "registr",
55
+ "password",
56
+ "contrasena",
57
+ "clave",
58
+ "autentic",
59
+ "authent",
60
+ "iniciar sesion",
61
+ "cerrar sesion",
62
+ "inicio de sesion",
63
+ "crear cuenta",
64
+ "create account",
65
+ "user account",
66
+ "cuenta de usuario",
67
+ "credencial",
68
+ "credential",
69
+ "oauth",
70
+ "jwt",
71
+ )
72
+
73
+ AREAS: tuple[SecurityArea, ...] = (
74
+ SecurityArea(
75
+ key="authentication",
76
+ chapter="V6 Authentication",
77
+ signals=_AUTH_SIGNALS,
78
+ level1=(
79
+ Control("6.2.1", "Passwords of at least 8 characters (15 recommended)."),
80
+ Control("6.2.4", "Reject common passwords at registration and change."),
81
+ Control("6.2.3", "Password change asks for the current password."),
82
+ Control("6.3.1", "Defend against brute force and credential stuffing."),
83
+ Control("6.4.2", "No password hints or secret questions."),
84
+ ),
85
+ level2=(
86
+ Control("6.2.12", "Reject passwords found in known breaches."),
87
+ Control("6.3.3", "Multi-factor authentication."),
88
+ Control("6.4.3", "Secure reset of a forgotten password."),
89
+ ),
90
+ ),
91
+ SecurityArea(
92
+ key="session",
93
+ chapter="V7 Session Management",
94
+ signals=(*_AUTH_SIGNALS, "session", "sesion", "cookie", "token"),
95
+ level1=(
96
+ Control("7.2.4", "Issue a new session token at login."),
97
+ Control("7.4.1", "Logout or expiry makes the session unusable."),
98
+ Control("7.4.2", "End all sessions when an account is disabled."),
99
+ ),
100
+ level2=(
101
+ Control("7.3.1", "Inactivity timeout."),
102
+ Control("7.3.2", "Absolute maximum session lifetime."),
103
+ Control("7.4.3", "End other sessions after a password change."),
104
+ ),
105
+ ),
106
+ SecurityArea(
107
+ key="authorization",
108
+ chapter="V8 Authorization",
109
+ signals=(
110
+ "permiso",
111
+ "permission",
112
+ "rol",
113
+ "roles",
114
+ "role",
115
+ "admin",
116
+ "acceso",
117
+ "access",
118
+ "propietario",
119
+ "owner",
120
+ "privad",
121
+ "private",
122
+ "restring",
123
+ "restrict",
124
+ "proteg",
125
+ "protect",
126
+ ),
127
+ level1=(
128
+ Control("8.2.1", "Each function is limited to users allowed to use it."),
129
+ Control("8.2.2", "Each record is limited to users allowed to see it."),
130
+ Control("8.3.1", "Authorization is enforced on the server."),
131
+ ),
132
+ level2=(
133
+ Control("8.2.3", "Field-level access rules."),
134
+ ),
135
+ ),
136
+ SecurityArea(
137
+ key="input",
138
+ chapter="V2 Validation and V1 Encoding",
139
+ signals=(
140
+ "formulario",
141
+ "form",
142
+ "input",
143
+ "campo",
144
+ "field",
145
+ "crear",
146
+ "create",
147
+ "editar",
148
+ "edit",
149
+ "actualizar",
150
+ "update",
151
+ "buscar",
152
+ "search",
153
+ "busqueda",
154
+ "filtr",
155
+ "filter",
156
+ "comentario",
157
+ "comment",
158
+ "contacto",
159
+ "contact",
160
+ ),
161
+ level1=(
162
+ Control("2.2.1", "Validate input against the expected values."),
163
+ Control("2.2.2", "Validate on the server, not only in the browser."),
164
+ Control("1.2.4", "Parameterized queries or the ORM, no raw SQL."),
165
+ Control("1.2.1", "Encode output for its context (prevents XSS)."),
166
+ ),
167
+ level2=(
168
+ Control("2.4.1", "Anti-automation: limit excessive requests."),
169
+ Control("2.3.3", "Transactions: an operation completes or rolls back."),
170
+ ),
171
+ ),
172
+ SecurityArea(
173
+ key="web",
174
+ chapter="V3 Web Frontend Security",
175
+ signals=(
176
+ "html",
177
+ "pagina",
178
+ "page",
179
+ "plantilla",
180
+ "template",
181
+ "vista",
182
+ "view",
183
+ "frontend",
184
+ "navegador",
185
+ "browser",
186
+ "cookie",
187
+ ),
188
+ level1=(
189
+ Control("3.5.3", "Sensitive actions use POST, never GET."),
190
+ Control("3.3.1", "Cookies are marked Secure."),
191
+ Control("3.4.1", "HSTS header on every response."),
192
+ ),
193
+ level2=(
194
+ Control("3.3.4", "Session cookies are HttpOnly."),
195
+ Control("3.4.3", "Content-Security-Policy header."),
196
+ ),
197
+ ),
198
+ SecurityArea(
199
+ key="files",
200
+ chapter="V5 File Handling",
201
+ signals=(
202
+ "archivo",
203
+ "file",
204
+ "upload",
205
+ "subir",
206
+ "imagen",
207
+ "image",
208
+ "adjunt",
209
+ "attachment",
210
+ "pdf",
211
+ "csv",
212
+ ),
213
+ level1=(
214
+ Control("5.2.1", "Limit the size of accepted files."),
215
+ Control("5.2.2", "Check the extension and type of each file."),
216
+ Control("5.3.1", "Uploaded files are never executed by the server."),
217
+ Control("5.3.2", "Never build paths from user-supplied file names."),
218
+ ),
219
+ level2=(
220
+ Control("5.4.3", "Scan uploaded files with an antivirus."),
221
+ ),
222
+ ),
223
+ SecurityArea(
224
+ key="api",
225
+ chapter="V4 API and Web Service",
226
+ signals=(
227
+ "api",
228
+ "endpoint",
229
+ "rest",
230
+ "json",
231
+ "graphql",
232
+ "webhook",
233
+ ),
234
+ level1=(
235
+ Control("4.1.1", "Every response declares the right Content-Type."),
236
+ Control("8.3.1", "API authorization is enforced on the server."),
237
+ ),
238
+ level2=(
239
+ Control("2.4.1", "Rate limiting on the API."),
240
+ Control("4.1.2", "Only user-facing endpoints redirect HTTP to HTTPS."),
241
+ ),
242
+ ),
243
+ SecurityArea(
244
+ key="data",
245
+ chapter="V14 Data Protection",
246
+ signals=(
247
+ "datos personales",
248
+ "personal data",
249
+ "correo",
250
+ "email",
251
+ "telefono",
252
+ "phone",
253
+ "direccion",
254
+ "address",
255
+ "pago",
256
+ "payment",
257
+ "tarjeta",
258
+ "card",
259
+ "datos de salud",
260
+ "health data",
261
+ "sensibl",
262
+ "sensitive",
263
+ "cedula",
264
+ "identidad",
265
+ ),
266
+ level1=(
267
+ Control("14.2.1", "Sensitive data never travels in URLs."),
268
+ Control("14.3.1", "Clear signed-in data from the browser on logout."),
269
+ ),
270
+ level2=(
271
+ Control("14.1.1", "Identify and classify sensitive data."),
272
+ Control("14.3.2", "Cache-Control: no-store for sensitive responses."),
273
+ ),
274
+ ),
275
+ SecurityArea(
276
+ key="configuration",
277
+ chapter="V13 Configuration",
278
+ signals=(
279
+ "deploy",
280
+ "despliegue",
281
+ "desplegar",
282
+ "produccion",
283
+ "production",
284
+ "docker",
285
+ ),
286
+ level1=(
287
+ Control("13.4.1", "Source control metadata (.git) is never served."),
288
+ ),
289
+ level2=(
290
+ Control("13.4.2", "Debug mode is disabled in production."),
291
+ Control("13.3.1", "Secrets live in a secrets manager, not in code."),
292
+ ),
293
+ ),
294
+ )
295
+
296
+
297
+ def _normalize(value: str) -> str:
298
+ decomposed = unicodedata.normalize("NFKD", value)
299
+ plain = "".join(c for c in decomposed if not unicodedata.combining(c))
300
+ return " ".join(plain.lower().split())
301
+
302
+
303
+ def applicable_areas(texts: Iterable[str]) -> tuple[SecurityArea, ...]:
304
+ """Return the areas whose signals appear in the given texts."""
305
+ text = _normalize(" ".join(value for value in texts if value))
306
+ if not text:
307
+ return ()
308
+ return tuple(
309
+ area
310
+ for area in AREAS
311
+ if any(_matches(signal, text) for signal in area.signals)
312
+ )
313
+
314
+
315
+ def _matches(signal: str, text: str) -> bool:
316
+ # Short signals must be whole words ("api", "rest", "form"); longer
317
+ # ones also match as a prefix ("autentic" matches "autenticacion").
318
+ suffix = r"\b" if len(signal) <= 4 else ""
319
+ return re.search(rf"\b{re.escape(signal)}{suffix}", text) is not None
320
+
321
+
322
+ def baseline_lines(areas: Iterable[SecurityArea]) -> list[str]:
323
+ """Render the baseline compactly for the Decision Context."""
324
+ lines: list[str] = []
325
+ for area in areas:
326
+ level1 = "; ".join(
327
+ f"{control.asvs_id} {control.summary.rstrip('.')}"
328
+ for control in area.level1
329
+ )
330
+ level2 = "; ".join(
331
+ f"{control.asvs_id} {control.summary.rstrip('.')}"
332
+ for control in area.level2
333
+ )
334
+ lines.append(f"- {area.label}")
335
+ lines.append(f" - Level 1 (ask or inform): {level1}")
336
+ if level2:
337
+ lines.append(f" - Level 2 (offer as next level): {level2}")
338
+ return lines
339
+
340
+
341
+ def checklist_lines(areas: Iterable[SecurityArea]) -> list[str]:
342
+ """Render the level-1 controls as a review checklist for spec.md."""
343
+ lines: list[str] = []
344
+ for area in areas:
345
+ for control in area.level1:
346
+ lines.append(f"- {area.label} {control.asvs_id}: {control.summary}")
347
+ return lines
348
+
349
+
350
+ def uncovered_controls(
351
+ areas: Iterable[SecurityArea],
352
+ cited: Iterable[str],
353
+ ) -> tuple[Control, ...]:
354
+ """Return level-1 controls whose ASVS id no decision cites yet."""
355
+ text = " ".join(value for value in cited if value)
356
+ missing: list[Control] = []
357
+ seen: set[str] = set()
358
+ for area in areas:
359
+ for control in area.level1:
360
+ if control.asvs_id in seen:
361
+ continue
362
+ seen.add(control.asvs_id)
363
+ pattern = rf"(?<![\d.]){re.escape(control.asvs_id)}(?!\d)"
364
+ if re.search(pattern, text) is None:
365
+ missing.append(control)
366
+ return tuple(missing)
@@ -35,7 +35,12 @@ from devflow.models.project import (
35
35
  Project,
36
36
  canonical_project_mode,
37
37
  )
38
- from devflow.prompts import build_decision_context
38
+ from devflow.core.security_baseline import (
39
+ ASVS_VERSION,
40
+ applicable_areas,
41
+ checklist_lines,
42
+ )
43
+ from devflow.prompts import build_decision_context, security_texts
39
44
 
40
45
  IGNORED_FILENAMES = {
41
46
  "package-lock.json",
@@ -894,6 +899,11 @@ class SpecificationManager:
894
899
  cleaned = prepared.fallback_content
895
900
  source = "static"
896
901
  cleaned = self.with_next_specs(cleaned, prepared.discovery)
902
+ cleaned = self.with_security_sections(
903
+ cleaned,
904
+ prepared.description,
905
+ prepared.discovery,
906
+ )
897
907
  cleaned = self.with_plain_criteria(cleaned)
898
908
  cleaned = self.with_approval_section(
899
909
  cleaned,
@@ -1096,6 +1106,79 @@ class SpecificationManager:
1096
1106
  cleaned = cleaned[start:]
1097
1107
  return cleaned.strip()
1098
1108
 
1109
+ def with_security_sections(
1110
+ self,
1111
+ content: str,
1112
+ request: str,
1113
+ discovery: DiscoveryDocument | None,
1114
+ ) -> str:
1115
+ """Complete the security part of section 4.
1116
+
1117
+ DevFlow writes the accepted risks from Discovery. When the agent did
1118
+ not write its security considerations for an area the change
1119
+ touches, DevFlow adds the level-1 controls as a review checklist.
1120
+ """
1121
+ areas = applicable_areas(security_texts(request, discovery))
1122
+ risks = discovery.accepted_risks if discovery is not None else ()
1123
+ if not areas and not risks:
1124
+ return content
1125
+ section = re.search(
1126
+ r"^##\s+4\.[^\n]*\n(?P<body>.*?)(?=^##\s+5\.|\Z)",
1127
+ content,
1128
+ re.MULTILINE | re.DOTALL,
1129
+ )
1130
+ if section is None:
1131
+ return content
1132
+
1133
+ body = re.sub(
1134
+ r"^###\s+Accepted security risks\b.*?(?=^###\s|\Z)",
1135
+ "",
1136
+ section.group("body"),
1137
+ flags=re.MULTILINE | re.DOTALL,
1138
+ ).rstrip()
1139
+ blocks = [body] if body else []
1140
+ if areas and not re.search(
1141
+ r"^###\s+.*Security considerations",
1142
+ body,
1143
+ re.MULTILINE | re.IGNORECASE,
1144
+ ):
1145
+ blocks.append(
1146
+ "\n".join(
1147
+ [
1148
+ "### Security considerations",
1149
+ "",
1150
+ f"Level-1 controls from OWASP ASVS {ASVS_VERSION} that apply "
1151
+ "to this change. Check that each one is covered by a "
1152
+ "requirement and an acceptance criterion.",
1153
+ "",
1154
+ *checklist_lines(areas),
1155
+ ]
1156
+ )
1157
+ )
1158
+ risk_lines = ["### Accepted security risks", ""]
1159
+ if risks:
1160
+ for risk in risks:
1161
+ control = f" (ASVS {risk.control})" if risk.control else ""
1162
+ review = f" Review by {risk.review_by}." if risk.review_by else ""
1163
+ accepted = (
1164
+ f"Accepted by {risk.accepted_by} at {risk.accepted_at}."
1165
+ if risk.is_accepted
1166
+ else "Awaiting explicit acceptance."
1167
+ )
1168
+ risk_lines.append(
1169
+ f"- **{risk.id}**{control}: {risk.risk} Reason: {risk.reason} "
1170
+ f"{accepted}{review}"
1171
+ )
1172
+ else:
1173
+ risk_lines.append("None.")
1174
+ blocks.append("\n".join(risk_lines))
1175
+ new_body = "\n" + "\n\n".join(blocks).lstrip("\n") + "\n\n"
1176
+ return (
1177
+ content[: section.start("body")]
1178
+ + new_body
1179
+ + content[section.end("body"):]
1180
+ )
1181
+
1099
1182
  def with_plain_criteria(self, content: str) -> str:
1100
1183
  """Remove checkboxes from acceptance criteria.
1101
1184
 
@@ -1571,6 +1654,7 @@ class SpecificationManager:
1571
1654
  )
1572
1655
  spec_path = target_directory / "spec.md"
1573
1656
  decision_context = build_decision_context(
1657
+ request=description,
1574
1658
  project_name=project.name,
1575
1659
  project_type=project.project_type,
1576
1660
  project_mode="greenfield",
@@ -2000,6 +2084,7 @@ class SpecificationManager:
2000
2084
  )
2001
2085
  spec_path = target_directory / "spec.md"
2002
2086
  decision_context = build_decision_context(
2087
+ request=description,
2003
2088
  project_name=project.name,
2004
2089
  project_type=project.project_type,
2005
2090
  project_mode=project_mode,
@@ -15,11 +15,8 @@ PROMPTS_ROOT = Path(__file__).resolve().parent
15
15
  # The decision context is a compact, deterministic digest. The limit is
16
16
  # expressed in characters to stay independent from any tokenizer; a
17
17
  # normal English/Spanish text uses roughly four characters per token.
18
- MAX_DECISION_CONTEXT_CHARS = 8_000
18
+ MAX_DECISION_CONTEXT_CHARS = 12_000
19
19
 
20
- # Missing decisions the specification agent may ask in its own session
21
- # before the change has to return to a separate Discovery session.
22
- MAX_IN_SESSION_DECISIONS = 3
23
20
 
24
21
 
25
22
  class PromptError(Exception):
@@ -210,6 +207,7 @@ def build_decision_context(
210
207
  discovery: DiscoveryDocument | None = None,
211
208
  discovery_digest: str = "",
212
209
  max_chars: int = MAX_DECISION_CONTEXT_CHARS,
210
+ request: str = "",
213
211
  ) -> str:
214
212
  """Render the deterministic, token-capped Decision Context section."""
215
213
  lines: list[str] = [
@@ -253,10 +251,10 @@ def build_decision_context(
253
251
  "- A critical or security decision can never be assumed.",
254
252
  "- Discovery is incomplete while a material decision is pending.",
255
253
  "",
256
- "### Approved decisions",
257
- "",
258
254
  ]
259
255
  )
256
+ lines.extend(_security_lines(request, discovery))
257
+ lines.extend(["### Approved decisions", ""])
260
258
  if discovery is None:
261
259
  lines.append("- No Discovery record has been created yet.")
262
260
  else:
@@ -333,6 +331,95 @@ def build_decision_context(
333
331
  return rendered[:keep].rstrip() + marker
334
332
 
335
333
 
334
+ def _security_lines(
335
+ request: str,
336
+ discovery: DiscoveryDocument | None,
337
+ ) -> list[str]:
338
+ """Render the ASVS baseline and the accepted risks, when they apply."""
339
+ # Imported here: importing devflow.core at module load would create a
340
+ # cycle with the prompts package.
341
+ from devflow.core.security_baseline import (
342
+ ASVS_VERSION,
343
+ applicable_areas,
344
+ baseline_lines,
345
+ uncovered_controls,
346
+ )
347
+
348
+ areas = applicable_areas(security_texts(request, discovery))
349
+ risks = discovery.accepted_risks if discovery is not None else ()
350
+ if not areas and not risks:
351
+ return []
352
+ lines = [
353
+ f"### Security baseline (OWASP ASVS {ASVS_VERSION})",
354
+ "",
355
+ ]
356
+ if areas:
357
+ lines.append(
358
+ "Every level-1 control must be covered by a decision or by an "
359
+ "accepted risk. Offer level-2 controls as the next level."
360
+ )
361
+ lines.append("")
362
+ lines.extend(baseline_lines(areas))
363
+ if discovery is not None:
364
+ missing = uncovered_controls(areas, coverage_texts(discovery))
365
+ lines.append("")
366
+ if missing:
367
+ lines.append(
368
+ "- Level-1 controls no decision cites yet: "
369
+ + ", ".join(control.asvs_id for control in missing)
370
+ + ". Ask or resolve them before Discovery is ready."
371
+ )
372
+ else:
373
+ lines.append("- Every level-1 control is cited by a decision.")
374
+ else:
375
+ lines.append("- No ASVS area detected for this change.")
376
+ lines.extend(["", "### Accepted security risks", ""])
377
+ if risks:
378
+ for risk in risks:
379
+ control = f" (ASVS {risk.control})" if risk.control else ""
380
+ state = (
381
+ f"accepted by {risk.accepted_by} at {risk.accepted_at}"
382
+ if risk.is_accepted
383
+ else "awaiting explicit acceptance"
384
+ )
385
+ lines.append(
386
+ f"- {risk.id}{control}: {_clip(risk.risk, 200)} "
387
+ f"Reason: {_clip(risk.reason, 160)} ({state})"
388
+ )
389
+ else:
390
+ lines.append("- None.")
391
+ lines.append("")
392
+ return lines
393
+
394
+
395
+ def coverage_texts(discovery: DiscoveryDocument) -> list[str]:
396
+ """Return the Discovery texts where covered controls are cited."""
397
+ texts: list[str] = []
398
+ for question in discovery.questions:
399
+ texts.extend([question.question, question.reason])
400
+ if question.answer:
401
+ texts.append(question.answer)
402
+ texts.extend(question.evidence)
403
+ for risk in discovery.accepted_risks:
404
+ texts.extend([risk.control or "", risk.risk, risk.reason])
405
+ return texts
406
+
407
+
408
+ def security_texts(
409
+ request: str,
410
+ discovery: DiscoveryDocument | None,
411
+ ) -> list[str]:
412
+ """Return the texts used to detect the security areas of a change."""
413
+ texts = [request]
414
+ if discovery is not None:
415
+ texts.append(discovery.request)
416
+ for question in discovery.questions:
417
+ texts.append(question.question)
418
+ if question.answer:
419
+ texts.append(question.answer)
420
+ return texts
421
+
422
+
336
423
  _MODE_BLOCK = re.compile(
337
424
  r"<!-- devflow:mode (?P<mode>existing|greenfield) -->\n"
338
425
  r"(?P<body>.*?)"
@@ -474,19 +561,20 @@ def _mode_instructions(
474
561
  "You are running interactively. Discovery is complete; use its "
475
562
  "recorded answers and accepted assumptions as settled decisions. "
476
563
  "Before writing, check that every decision the specification "
477
- "needs is recorded. If up to "
478
- f"{MAX_IN_SESSION_DECISIONS} decisions are missing, ask the user "
479
- "now in one batch, with the structured question tool when "
480
- "available: put the recommended level-1 option first, add one "
481
- "more advanced next-level option with a one-sentence reason, and "
482
- "never assume a security decision. Record each answer in the "
564
+ "needs is recorded, including every level-1 security control "
565
+ "listed in the Decision Context. If decisions are missing, ask "
566
+ "the user about all of them now, in batches of up to six, with "
567
+ "the structured question tool when available: put the "
568
+ "recommended level-1 option first, add a more advanced "
569
+ "next-level option with a one-sentence reason when one exists, "
570
+ "and never assume a security decision. Record each answer in the "
483
571
  "discovery record as a new question with the next `Qn` id, "
484
572
  "`status: resolved`, `resolution_source: user`, the chosen option "
485
573
  "text as `answer`, `answered_by: user`, `answered_at`, `options` "
486
574
  "and `next_level`; DevFlow updates the Discovery digest in the "
487
- "specification header. If more decisions are missing or the user "
488
- "does not answer, append them as questions with `status: "
489
- "pending`, set the root `status` of the record to "
575
+ "specification header. Only if the user does not answer or "
576
+ "prefers to decide later, append the open decisions as questions "
577
+ "with `status: pending`, set the root `status` of the record to "
490
578
  "`awaiting_clarification`, do not write the specification and "
491
579
  "tell the user to exit this session so DevFlow returns to "
492
580
  "Discovery. Otherwise write the complete specification to "
@@ -73,13 +73,37 @@ traces that path instead of solving everything at once.
73
73
  the user with its explanation, as a question option or as a
74
74
  `deferred` item; never as an unstated requirement.
75
75
 
76
+ ## Security Baseline
77
+
78
+ When the Decision Context has a `Security baseline (OWASP ASVS 5.0)`
79
+ section, it lists the security areas this change touches:
80
+
81
+ - Every **level-1** control must end up covered: resolved by project
82
+ evidence, or asked as a question whose recommended option applies it.
83
+ Explain in one sentence why it matters. Group related controls in one
84
+ question (for example "HSTS and Secure cookies in production" covers
85
+ 3.4.1 and 3.3.1).
86
+ - Cite the ASVS identifier of every control you cover (for example
87
+ `6.3.1`) in the question `reason`, the `answer` or the `evidence`.
88
+ DevFlow lists in the Decision Context the level-1 controls that no
89
+ decision cites yet; ask them before reporting Discovery as ready.
90
+ - If the user explicitly decides not to apply a level-1 control now,
91
+ record it in `accepted_risks` with `status: pending_acceptance` and
92
+ ask the user to accept the risk; set `accepted` with `accepted_by` and
93
+ `accepted_at` only after an explicit yes. Never skip a control
94
+ silently and never assume it.
95
+ - Offer **level-2** controls as `next_level` options or `deferred`
96
+ items, not as level-1 requirements.
97
+ - Ignore areas that are not listed.
98
+
76
99
  ## Readiness Check
77
100
 
78
101
  Before reporting Discovery as complete, walk through what the
79
102
  specification will need and confirm a decision exists for each item:
80
103
  every user-facing flow and the interfaces it uses (API, HTML pages,
81
104
  CLI), the data stored and where, error and unauthenticated behavior,
82
- how each level-1 security measure works, and what is out of scope. Ask
105
+ how each level-1 security control is covered (or which risk was
106
+ accepted), and what is out of scope. Ask
83
107
  every missing decision in the same round. The specification writer
84
108
  must not find new decisions.
85
109
 
@@ -168,13 +192,16 @@ assumption or apply the existing convention.
168
192
 
169
193
  - First round: at most {{question_budget_initial}} new questions.
170
194
  - Follow-up rounds: at most {{question_budget_follow_up}} new questions.
171
- - Safety cap: {{question_budget_maximum}} questions in total.
195
+ - Safety cap: {{question_budget_maximum}} questions asked to the user in
196
+ total. Decisions resolved from evidence do not count.
172
197
  - One interaction round: at most {{batch_size}} independent questions.
173
198
  - Maximum interaction rounds: {{max_rounds}}.
174
199
 
175
- The budget limits questions; it never allows ignoring a critical or
176
- material decision. If decisions remain after the cap, keep Discovery
177
- incomplete, report them and request explicit intervention.
200
+ The budget only limits optional questions. Critical and blocking
201
+ decisions are always asked, in this session, even beyond the cap or the
202
+ round limit: never stop Discovery because a limit was reached while one
203
+ of them is still open. Prefer grouping related decisions into one
204
+ question over dropping any.
178
205
 
179
206
  Group independent questions into a single structured question call per
180
207
  round. Do not include a question whose answer depends on another
@@ -255,6 +282,15 @@ deferred:
255
282
  - title: "Limit failed login attempts"
256
283
  why: "Protects accounts from password guessing once login works."
257
284
  question_id: Q1
285
+ accepted_risks:
286
+ - id: R1
287
+ control: "6.3.1"
288
+ risk: "Login has no protection against password guessing yet."
289
+ reason: "Internal tool behind the VPN; planned for the next spec."
290
+ status: pending_acceptance
291
+ accepted_by: null
292
+ accepted_at: null
293
+ review_by: "2026-12-31"
258
294
  ```
259
295
 
260
296
  `next_level` and `deferred` are optional. Add a `next_level` only when
devflow/prompts/spec.md CHANGED
@@ -193,6 +193,12 @@ renumber the document.
193
193
  digest in the header table, state that Discovery is complete, and
194
194
  reference the recorded answers and accepted assumptions without
195
195
  contradicting them.
196
+ - When the change context has a `Security baseline (OWASP ASVS 5.0)`,
197
+ section 4 includes a `### Security considerations` subsection with a
198
+ table `| Threat | Mitigation | AC | ASVS |` covering every level-1
199
+ control that applies; each mitigation is verified by an `AC-XXX`. Do
200
+ not write `### Accepted security risks`: DevFlow writes it from
201
+ Discovery.
196
202
  - Section 8 maps acceptance criteria to functional requirements and,
197
203
  when applicable, architecture boundaries.
198
204
  - Section 9 lists the constitution documents that apply and their
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-toolkit
3
- Version: 0.3.28
3
+ Version: 0.4.1
4
4
  Summary: Specification workflow toolkit for AI-assisted software changes
5
5
  Author: DevFlow contributors
6
6
  License-Expression: MIT
@@ -32,7 +32,7 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  # DevFlow Toolkit
34
34
 
35
- **Current version: `0.3.28`.**
35
+ **Current version: `0.4.1`.**
36
36
 
37
37
  Before any code is written, you and the AI agree on what will be built
38
38
  and approve it as a spec. The agent then implements once, on something
@@ -210,7 +210,7 @@ pip install devflow-toolkit
210
210
  To install a specific built artifact instead:
211
211
 
212
212
  ```bash
213
- pip install devflow_toolkit-0.3.28-py3-none-any.whl
213
+ pip install devflow_toolkit-0.4.1-py3-none-any.whl
214
214
  ```
215
215
 
216
216
  Verify the installation:
@@ -515,7 +515,7 @@ as an architectural constraint when it is present.
515
515
 
516
516
  ### Harnesses
517
517
 
518
- | Harness | Status in 0.3.28 |
518
+ | Harness | Status in 0.4.1 |
519
519
  | --- | --- |
520
520
  | OpenCode | Verified end-to-end; interactive Discovery uses the `question` tool |
521
521
  | Antigravity | Custom agents and scoped permissions generated; `agy` loading and print mode verified |
@@ -698,18 +698,21 @@ decisions into one interaction. The defaults live in `.devflow/config.yaml`:
698
698
  discovery:
699
699
  question_budget:
700
700
  initial: 6
701
- follow_up: 3
702
- maximum: 12
701
+ follow_up: 6
702
+ maximum: 20
703
703
  interaction:
704
704
  batch_size: 6
705
- max_rounds: 3
705
+ max_rounds: 5
706
706
  assumptions:
707
707
  enabled: true
708
708
  ```
709
709
 
710
- The budget limits questions but never permits ignoring a critical
711
- decision. If material decisions remain after the budget is exhausted,
712
- Discovery stays incomplete and asks for intervention.
710
+ The budget only limits optional questions. Critical and blocking
711
+ decisions are always asked in the same session, even beyond the cap or
712
+ the round limit, and decisions resolved from project evidence do not
713
+ count. Projects initialized before `0.4.1` keep the old limits
714
+ (`follow_up: 3`, `maximum: 12`, `max_rounds: 3`); `devflow spec` warns
715
+ about them and suggests the new values.
713
716
 
714
717
  The deterministic planner recognizes contact pages, forms, comments,
715
718
  authentication, persistence, deployments and architecture boundaries in
@@ -780,16 +783,17 @@ specification that still lists open questions.
780
783
  In an interactive run the specification agent checks for missing
781
784
  decisions **before** writing:
782
785
 
783
- - **Up to 3 missing decisions:** it asks you in the same session, with
784
- the same rules as Discovery (recommended level-1 option first, a
785
- next-level option with its reason, security never assumed). Your
786
- answers are recorded in `discovery.yaml` as decisions resolved by you,
787
- and then it writes the spec. DevFlow writes the new Discovery digest
788
- into the spec header, because the agent cannot compute it.
789
- - **More than 3, or no answer:** it records them as `pending`, sets the
790
- record to `awaiting_clarification` and stops without writing
791
- `spec.md`, so no tokens are spent on a document that would be
792
- discarded.
786
+ - **Missing decisions:** it asks you about all of them in the same
787
+ session, in batches of up to six, with the same rules as Discovery
788
+ (recommended level-1 option first, a next-level option with its
789
+ reason, security never assumed). Your answers are recorded in
790
+ `discovery.yaml` as decisions resolved by you, and then it writes the
791
+ spec. DevFlow writes the new Discovery digest into the spec header,
792
+ because the agent cannot compute it.
793
+ - **No answer, or you prefer to decide later:** it records them as
794
+ `pending`, sets the record to `awaiting_clarification` and stops
795
+ without writing `spec.md`, so no tokens are spent on a document that
796
+ would be discarded.
793
797
 
794
798
  If the agent leaves `discovery.yaml` invalid, DevFlow writes no
795
799
  specification and asks you to run `devflow spec --continue`, which
@@ -863,6 +867,55 @@ in `devflow status`, after approval in the `Next:` line, and in
863
867
  that subsection itself, with a ready-to-run `devflow spec "..."` command
864
868
  for each item; the agent does not write it.
865
869
 
870
+ ### Security baseline (OWASP ASVS 5.0)
871
+
872
+ DevFlow organizes security with the
873
+ [OWASP Application Security Verification Standard](https://owasp.org/www-project-application-security-verification-standard/)
874
+ 5.0, which groups controls by level: L1 basic, L2 standard, L3 high.
875
+
876
+ 1. **Detection, without tokens.** DevFlow reads the request and the
877
+ Discovery questions and answers, and detects the ASVS areas the
878
+ change touches: authentication (V6), sessions (V7), authorization
879
+ (V8), input validation and encoding (V2, V1), web frontend (V3), file
880
+ handling (V5), APIs (V4), data protection (V14) and deployment
881
+ configuration (V13).
882
+ 2. **Discovery covers level 1.** The Decision Context lists the
883
+ level-1 controls of each area, with their ASVS identifiers. Every one
884
+ must be covered: by project evidence or by a question whose
885
+ recommended option applies it. Level-2 controls are offered as the
886
+ next level.
887
+ 3. **Accepted risks have an owner.** If you decide not to apply a
888
+ level-1 control now, it is recorded in `accepted_risks` and Discovery
889
+ stays incomplete until you accept it explicitly:
890
+
891
+ ```yaml
892
+ accepted_risks:
893
+ - id: R1
894
+ control: "6.3.1"
895
+ risk: "Login has no protection against password guessing yet."
896
+ reason: "Internal tool behind the VPN; planned for the next spec."
897
+ status: accepted
898
+ accepted_by: jonathan
899
+ accepted_at: "2026-11-10T09:00:00Z"
900
+ review_by: "2026-12-31"
901
+ ```
902
+
903
+ 4. **The spec shows the security work.** Section 4 contains
904
+ `### Security considerations`, a table of threat, mitigation,
905
+ acceptance criterion and ASVS control written by the agent. If the
906
+ agent omits it, DevFlow adds the level-1 controls as a review
907
+ checklist. DevFlow always writes `### Accepted security risks` from
908
+ Discovery.
909
+
910
+ DevFlow also checks, without tokens, which level-1 controls no question,
911
+ answer, evidence or accepted risk cites by its ASVS identifier, and
912
+ lists them in the Decision Context and in `devflow status`, so
913
+ Discovery covers them before the spec is written.
914
+
915
+ `devflow status` lists the detected areas and the accepted risks. The
916
+ control texts are short summaries; the ASVS document is the normative
917
+ reference.
918
+
866
919
  ## Workflow
867
920
 
868
921
  1. Initialize the project with `devflow init`.
@@ -876,7 +929,7 @@ for each item; the agent does not write it.
876
929
  8. If artifacts exist without workflow state, diagnose with
877
930
  `devflow doctor <id>` and repair with `devflow recover <id>`.
878
931
 
879
- Available commands in `0.3.28`:
932
+ Available commands in `0.4.1`:
880
933
 
881
934
  | Command | Status |
882
935
  | --- | --- |
@@ -1109,7 +1162,7 @@ devflow approve 001
1109
1162
  ```
1110
1163
 
1111
1164
  Approval is explicit and binds the decision to the current artifact
1112
- digests. For a `0.3.28` change it binds `spec.md`, `discovery.yaml` and,
1165
+ digests. For a `0.4.1` change it binds `spec.md`, `discovery.yaml` and,
1113
1166
  when a manifest applies, the architecture manifest digest. Repeating the
1114
1167
  same approval is a no-op. If an artifact changes after validation,
1115
1168
  DevFlow marks it stale and refuses approval until it is regenerated and
@@ -1120,7 +1173,7 @@ and names the pending questions and assumptions. Approval also rejects a
1120
1173
  specification whose section 7 still lists open questions. Legacy `0.2.0`
1121
1174
  changes without `discovery.yaml` remain approvable with a warning.
1122
1175
 
1123
- Only the `spec` stage is available in `0.3.28`, so `--stage` is optional
1176
+ Only the `spec` stage is available in `0.4.1`, so `--stage` is optional
1124
1177
  and defaults to `spec`. `--stage plan` and `--stage review` are
1125
1178
  rejected. There are no `plan`, `implement` or
1126
1179
  `review` commands in this release.
@@ -20,22 +20,23 @@ devflow/commands/init.py,sha256=Yb2zd0lchqyvrPuywY5ELL-Cfp4SnGFv_N_93rJeMKE,1799
20
20
  devflow/commands/recover.py,sha256=sV9x5-30E_3XRBe7JItDiSG-pqrowRzjqOkC_eyrhFQ,2165
21
21
  devflow/commands/reopen.py,sha256=bZiX-dyKgmtdKdV4FHwEwRCFvuuX5jezBCI7wIpkHYU,2971
22
22
  devflow/commands/security.py,sha256=lZlbMo34JHX46kBHRTSsZd4ANZ1mvxh6I-Nc6jNzuLI,2049
23
- devflow/commands/spec.py,sha256=7glxFHKuJd33mL6YayrxRJ6TViUmmQk5rijbNepsbig,16353
24
- devflow/commands/status.py,sha256=2rIPAZZnFvS3aAsHUNw8JaBrFq_l_8UGbURrKHIgXCo,7514
23
+ devflow/commands/spec.py,sha256=2d32ZpGzzBU7qGHZzu5V1UQ3-pcTcldHCZu3Qr2VlT8,16753
24
+ devflow/commands/status.py,sha256=7psMpY_vFFSOQUia39_0W1-tnCijg1tQLgAX5aMduNo,8406
25
25
  devflow/core/__init__.py,sha256=hN7i4-PDaZ7y4P8qRpZl_lJvIiPyQaN1TDGnw2BecYU,427
26
26
  devflow/core/architecture.py,sha256=qllllsUVqA76LiSU6z_s4U8dxMcs6ClKXU16HxI3yOI,13692
27
27
  devflow/core/clock.py,sha256=KZROv6o51Ln1EzK00ySCxfc7WPZqPlaQhFfjfdc_TMY,1651
28
- devflow/core/config.py,sha256=g_9ocRsrDLSsZZ5Sy1qlI7gi8WA2WlyiLUOZhcID2Ig,27065
28
+ devflow/core/config.py,sha256=zeMxMAUlvLo06pOUZ6mCh0cQBG21iNfbCom62uYQQzE,27502
29
29
  devflow/core/constitution.py,sha256=rPLc8Puv9nUMC_GZwzOqvr1B-4urdxAISr655od2IPM,5333
30
- devflow/core/discovery.py,sha256=YxCUvyfA0HLp2xEAI4frCks-5APNyTP0yBNCuVHDWZc,62649
30
+ devflow/core/discovery.py,sha256=rm2-7Eq8APFQ6hetQWXcsJ8KB1yEKVDVVHHwr-XJNLM,66507
31
31
  devflow/core/file_types.py,sha256=5S5YywOaTESDiln4kP7qyJFEjxHoiF6tSBbwuXNpDDc,566
32
32
  devflow/core/ports.py,sha256=6jlqeR40MNaz-IuZIAPimXpRKew-wMUab3KzelcTXsU,4541
33
33
  devflow/core/profile_manager.py,sha256=QnnJka2KIKD2tCSWJkGTOUEFMgmQT0Z9Qv173JKWKHw,8937
34
34
  devflow/core/project.py,sha256=4OnudghY5N5rCOmafWO5Hk68M7T3-mOV0j0k0dh2luE,16891
35
35
  devflow/core/recovery.py,sha256=W2If6Ymb3ISwMN8IVQYCwptDUzhxejlF-P2NvMYyZP0,8818
36
+ devflow/core/security_baseline.py,sha256=VvWIAlU2lhWtJP3ApRr5qXmh0zJ028OCIzaC6kOuQss,9682
36
37
  devflow/core/security_tools.py,sha256=F-JdGzycS-Vov_1SE5qciNVi31DqnnJXVqHqoDocSAA,8912
37
38
  devflow/core/spec_workflow.py,sha256=CTBDdKX8EkfHfrhUpjXY1r3QYwN-w5Du9cjSiViIhZg,44034
38
- devflow/core/specification.py,sha256=6b1-MRJjlPyzTwk5FzWCZJneAe0xy-xpnsmLZgMcA6Y,70036
39
+ devflow/core/specification.py,sha256=DL3t0ohs0gWCxWKCOOkviglXUchAfHjP1g0Dtz77nDo,72632
39
40
  devflow/core/artifacts/__init__.py,sha256=gt9xahPynoxv75FMq1ZJx91ILTIv4ExuvX1Ymrxwr2c,627
40
41
  devflow/core/artifacts/errors.py,sha256=hwZxnLFcUTtEjDWtN6rUCkM69EN19LGVlc6HD-pNZyk,493
41
42
  devflow/core/artifacts/models.py,sha256=xJjmY8jUAHxqYN9u1JEu8CbJB-IJg1xb9P-LDaP5_Hw,2049
@@ -63,12 +64,12 @@ devflow/profiles/django-backend/profile.yaml,sha256=SNj7a3yamdJx-P69GvIJmLkC2svO
63
64
  devflow/profiles/django-backend/constitution/django-standards.md,sha256=0M-XmxOpEmgIadcaVdf6OVmll8Oec0jEjcJ4C8MfwhQ,2052
64
65
  devflow/profiles/fastapi-backend/profile.yaml,sha256=5_b-zWSX0HV-tw_2ntRCSa4DyP3NUqYWmxOh55pXYmc,321
65
66
  devflow/profiles/fastapi-backend/constitution/fastapi-standards.md,sha256=iFKib4i_9z4wBQ9thl-uftg5g-CHwvmFWzMtLgA7CBk,1949
66
- devflow/prompts/__init__.py,sha256=DttfMavd0nfmhKkVE46VhpIHkGS-4amYfufABEM20xI,19120
67
+ devflow/prompts/__init__.py,sha256=kTm7xjlvHLgkH9zYV7e51iPlZqRKJqL0ufA67-chcPc,21949
67
68
  devflow/prompts/discovery-repair.md,sha256=hpw8pFaUC8OiHK_KTI2nMF45f77CqcFuDYzn9o6X5ao,1240
68
- devflow/prompts/discovery.md,sha256=QDwfcjmb76yJH4DKMyoZ4QRtrdkDwljrWr3gn2MYCn8,14920
69
- devflow/prompts/spec.md,sha256=Kze_ZvE5yn0tfncvr98Nw6GQLEZlJmcZFWDNUpLMnlc,7689
70
- devflow_toolkit-0.3.28.dist-info/METADATA,sha256=R78t2XrXxUh0-lKvALghxTcVr_SvX3iBPmxg-BUNego,55027
71
- devflow_toolkit-0.3.28.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
72
- devflow_toolkit-0.3.28.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
73
- devflow_toolkit-0.3.28.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
74
- devflow_toolkit-0.3.28.dist-info/RECORD,,
69
+ devflow/prompts/discovery.md,sha256=j6xP67cyie6rQ56_DZErdsbTJa-29vK72-Lg0rQdkY4,16595
70
+ devflow/prompts/spec.md,sha256=5N4tuB_StJYMENAO-WtxXDL1D7B3x0xhHXu9VWoBBEE,8049
71
+ devflow_toolkit-0.4.1.dist-info/METADATA,sha256=rNF8UUADaOXtPDYOYgB5ZTUMaA774jkQ7SyDlCRVV4w,57477
72
+ devflow_toolkit-0.4.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
73
+ devflow_toolkit-0.4.1.dist-info/entry_points.txt,sha256=wPmqE1081vi8s3xf-Wfzfvpl-44IKgwx7OGoLEK3u7o,44
74
+ devflow_toolkit-0.4.1.dist-info/licenses/LICENSE,sha256=Wa04lstC8Goe4b9IYfEYWB2k7nokYBejZl6NdyAl8rA,1077
75
+ devflow_toolkit-0.4.1.dist-info/RECORD,,