prodc 0.3.76__tar.gz → 0.3.77__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {prodc-0.3.76 → prodc-0.3.77}/PKG-INFO +1 -1
  2. {prodc-0.3.76 → prodc-0.3.77}/pyproject.toml +1 -1
  3. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/agent.md +1 -1
  4. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/board.py +10 -2
  5. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/app.py +7 -0
  6. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/commands.py +12 -1
  7. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/render.py +3 -1
  8. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/loader.py +13 -4
  9. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/model.py +18 -2
  10. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/writer.py +8 -3
  11. {prodc-0.3.76 → prodc-0.3.77}/tests/test_withdrawn.py +87 -1
  12. {prodc-0.3.76 → prodc-0.3.77}/.gitignore +0 -0
  13. {prodc-0.3.76 → prodc-0.3.77}/CHANGELOG.md +0 -0
  14. {prodc-0.3.76 → prodc-0.3.77}/LICENSE +0 -0
  15. {prodc-0.3.76 → prodc-0.3.77}/README.md +0 -0
  16. {prodc-0.3.76 → prodc-0.3.77}/examples/quickstart/features/orders.feature +0 -0
  17. {prodc-0.3.76 → prodc-0.3.77}/examples/quickstart/needs/jordan.yaml +0 -0
  18. {prodc-0.3.76 → prodc-0.3.77}/examples/quickstart/prodc.toml +0 -0
  19. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/__init__.py +0 -0
  20. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/adapters.py +0 -0
  21. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/callbacks.py +0 -0
  22. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/__init__.py +0 -0
  23. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/common.py +0 -0
  24. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/cli/serialize.py +0 -0
  25. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/config.py +0 -0
  26. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/dedup.py +0 -0
  27. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/py.typed +0 -0
  28. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/report.py +0 -0
  29. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/report_html.py +0 -0
  30. {prodc-0.3.76 → prodc-0.3.77}/src/prodc/status.py +0 -0
  31. {prodc-0.3.76 → prodc-0.3.77}/tests/test_adapters.py +0 -0
  32. {prodc-0.3.76 → prodc-0.3.77}/tests/test_answer.py +0 -0
  33. {prodc-0.3.76 → prodc-0.3.77}/tests/test_callbacks.py +0 -0
  34. {prodc-0.3.76 → prodc-0.3.77}/tests/test_citation.py +0 -0
  35. {prodc-0.3.76 → prodc-0.3.77}/tests/test_claim_gating.py +0 -0
  36. {prodc-0.3.76 → prodc-0.3.77}/tests/test_cli.py +0 -0
  37. {prodc-0.3.76 → prodc-0.3.77}/tests/test_command_hook.py +0 -0
  38. {prodc-0.3.76 → prodc-0.3.77}/tests/test_dedup.py +0 -0
  39. {prodc-0.3.76 → prodc-0.3.77}/tests/test_description.py +0 -0
  40. {prodc-0.3.76 → prodc-0.3.77}/tests/test_drafts.py +0 -0
  41. {prodc-0.3.76 → prodc-0.3.77}/tests/test_evalgate.py +0 -0
  42. {prodc-0.3.76 → prodc-0.3.77}/tests/test_external_adapter.py +0 -0
  43. {prodc-0.3.76 → prodc-0.3.77}/tests/test_gitlab_source.py +0 -0
  44. {prodc-0.3.76 → prodc-0.3.77}/tests/test_importance.py +0 -0
  45. {prodc-0.3.76 → prodc-0.3.77}/tests/test_loader.py +0 -0
  46. {prodc-0.3.76 → prodc-0.3.77}/tests/test_models.py +0 -0
  47. {prodc-0.3.76 → prodc-0.3.77}/tests/test_needref.py +0 -0
  48. {prodc-0.3.76 → prodc-0.3.77}/tests/test_relink.py +0 -0
  49. {prodc-0.3.76 → prodc-0.3.77}/tests/test_report.py +0 -0
  50. {prodc-0.3.76 → prodc-0.3.77}/tests/test_report_html.py +0 -0
  51. {prodc-0.3.76 → prodc-0.3.77}/tests/test_review.py +0 -0
  52. {prodc-0.3.76 → prodc-0.3.77}/tests/test_roles.py +0 -0
  53. {prodc-0.3.76 → prodc-0.3.77}/tests/test_source_role.py +0 -0
  54. {prodc-0.3.76 → prodc-0.3.77}/tests/test_sources.py +0 -0
  55. {prodc-0.3.76 → prodc-0.3.77}/tests/test_staleness.py +0 -0
  56. {prodc-0.3.76 → prodc-0.3.77}/tests/test_status.py +0 -0
  57. {prodc-0.3.76 → prodc-0.3.77}/tests/test_suggest.py +0 -0
  58. {prodc-0.3.76 → prodc-0.3.77}/tests/test_variants.py +0 -0
  59. {prodc-0.3.76 → prodc-0.3.77}/tests/test_who_variants.py +0 -0
  60. {prodc-0.3.76 → prodc-0.3.77}/tests/test_writer.py +0 -0
  61. {prodc-0.3.76 → prodc-0.3.77}/tests/test_writer_comments.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: prodc
3
- Version: 0.3.76
3
+ Version: 0.3.77
4
4
  Summary: Product management as code: roles, flows, and features traced to evidence.
5
5
  Project-URL: Homepage, https://gitlab.com/jorgeecardona/prodc
6
6
  Project-URL: Repository, https://gitlab.com/jorgeecardona/prodc
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "prodc"
3
- version = "0.3.76"
3
+ version = "0.3.77"
4
4
  description = "Product management as code: roles, flows, and features traced to evidence."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -79,7 +79,7 @@ Read first, then act, then check.
79
79
  | link a recurring want to a shared baseline | `prodc recurrence --suggest --apply --baseline-id <id> --file needs/<f>.yaml` |
80
80
  | record a human/AI review of the warrant | `prodc attest <id> --by <who> --date <ISO> [--ai]` |
81
81
  | record a human acceptance pass | `prodc accept <id> --who <person> --date <ISO>` |
82
- | decide against a need (won't-do) | `prodc withdraw <id> --reason "…"` — off the board + out of coverage; `prodc reinstate <id>` puts it back |
82
+ | decide against a need (won't-do) | `prodc withdraw <id> --reason "…" [--kind out_of_scope\|duplicate]` — off the board + out of coverage (use `out_of_scope` for a real need that isn't this product); `prodc reinstate <id>` puts it back |
83
83
  | hand a human a readable status file | `prodc report -o status.md` (markdown; `--format html` for an interactive viewer; `--client ID` to scope) |
84
84
  | act on a need going green (notify a tracker, etc.) | `prodc sync` — runs the `[callbacks]` commands for needs whose state changed since the last sync (`--dry-run` to preview) |
85
85
  | gate in CI | `prodc lint --strict` |
@@ -102,7 +102,11 @@ def need_payload(r: NeedResult, *, flavor: Literal["board", "html"] = "board") -
102
102
  "claim": need.claim,
103
103
  "answer": need.answer.value if need.answer else None,
104
104
  "withdrawn": (
105
- {"reason": need.withdrawn.reason, "date": need.withdrawn.date}
105
+ {
106
+ "reason": need.withdrawn.reason,
107
+ "date": need.withdrawn.date,
108
+ "kind": need.withdrawn.kind.value,
109
+ }
106
110
  if need.withdrawn
107
111
  else None
108
112
  ),
@@ -150,7 +154,11 @@ def need_payload(r: NeedResult, *, flavor: Literal["board", "html"] = "board") -
150
154
  "draft": need.draft,
151
155
  "answer": need.answer.value if need.answer else None,
152
156
  "withdrawn": (
153
- {"reason": need.withdrawn.reason, "date": need.withdrawn.date}
157
+ {
158
+ "reason": need.withdrawn.reason,
159
+ "date": need.withdrawn.date,
160
+ "kind": need.withdrawn.kind.value,
161
+ }
154
162
  if need.withdrawn
155
163
  else None
156
164
  ),
@@ -300,6 +300,13 @@ def main(argv: list[str] | None = None) -> int:
300
300
  wd.add_argument(
301
301
  "--reason", required=True, help="why it was decided against (kept on the record)"
302
302
  )
303
+ wd.add_argument(
304
+ "--kind",
305
+ choices=["wont_do", "out_of_scope", "duplicate"],
306
+ default="wont_do",
307
+ help="the decision's kind: wont_do (default), out_of_scope (real but not this product), "
308
+ "or duplicate (#74)",
309
+ )
303
310
  wd.add_argument("--date", default=None, help="when (ISO, e.g. 2026-10-10; default: today)")
304
311
  wd.add_argument("--config", default="prodc.toml", help="path to prodc.toml")
305
312
  wd.add_argument("--json", action="store_true", help="machine-readable output")
@@ -263,6 +263,14 @@ def cmd_status(args: argparse.Namespace) -> int:
263
263
  # orphans) until promoted with `set <id> draft=false`, unless --include-drafts is passed.
264
264
  draft_count = sum(1 for n in needs if n.draft and not n.is_withdrawn)
265
265
  withdrawn_count = sum(1 for n in needs if n.is_withdrawn)
266
+ # Break withdrawals down by kind (#74 follow-up), so "declined but valid" (out_of_scope) is
267
+ # legible on the board apart from plain won't-do; wont_do is the implicit default, not listed.
268
+ withdrawn_kinds: dict[str, int] = {}
269
+ for n in needs:
270
+ if n.withdrawn and n.withdrawn.kind.value != "wont_do":
271
+ withdrawn_kinds[n.withdrawn.kind.value] = (
272
+ withdrawn_kinds.get(n.withdrawn.kind.value, 0) + 1
273
+ )
266
274
  needs = board_needs(needs, include_drafts=args.include_drafts)
267
275
  # Scoped coverage (#49): restrict the board + coverage to a subset, so the number people
268
276
  # act on (this client, this goal) isn't diluted by the whole mixed board.
@@ -318,7 +326,9 @@ def cmd_status(args: argparse.Namespace) -> int:
318
326
  if draft_count and not args.include_drafts:
319
327
  print(f"drafts: {draft_count} staged (hidden — --include-drafts to show) (#60)")
320
328
  if withdrawn_count:
321
- print(f"withdrawn: {withdrawn_count} (decided against) (#74)")
329
+ extra = ", ".join(f"{c} {k}" for k, c in sorted(withdrawn_kinds.items()))
330
+ suffix = f" — {extra}" if extra else ""
331
+ print(f"withdrawn: {withdrawn_count} (decided against){suffix} (#74)")
322
332
  visible = [r for r in results if r.need.product]
323
333
  if args.only_must:
324
334
  visible = [r for r in visible if r.need.must]
@@ -549,6 +559,7 @@ def cmd_withdraw(args: argparse.Namespace) -> int:
549
559
  args.need_id,
550
560
  reason=args.reason,
551
561
  date=args.date or date.today().isoformat(),
562
+ kind=args.kind,
552
563
  expect_sha=args.expect_sha,
553
564
  dry_run=args.dry_run,
554
565
  )
@@ -276,7 +276,9 @@ def render_show(r: NeedResult, importance_label: str | None = None) -> str:
276
276
  if need.answer:
277
277
  lines.append(f" answer: {need.answer.value}")
278
278
  if need.withdrawn:
279
- lines.append(f" withdrawn: {need.withdrawn.reason} ({need.withdrawn.date})")
279
+ w = need.withdrawn
280
+ tag = "" if w.kind.value == "wont_do" else f" [{w.kind.value}]"
281
+ lines.append(f" withdrawn{tag}: {w.reason} ({w.date})")
280
282
  if need.description:
281
283
  lines.append(f" description: {need.description}")
282
284
  if need.importance is not None:
@@ -30,6 +30,7 @@ from .model import (
30
30
  Source,
31
31
  SourceKind,
32
32
  Withdrawal,
33
+ WithdrawalKind,
33
34
  )
34
35
 
35
36
 
@@ -130,10 +131,12 @@ def _answer(raw: object, where: str) -> Answer | None:
130
131
 
131
132
 
132
133
  def _withdrawal(raw: object, where: str) -> Withdrawal | None:
133
- """Parse ``withdrawn: {reason, date}`` into a :class:`Withdrawal` (#74).
134
+ """Parse ``withdrawn: {reason, date, kind?}`` into a :class:`Withdrawal` (#74).
134
135
 
135
- Both fields are required when the key is present — a decision against a need must say why
136
- and when, the same way an attestation needs who and when.
136
+ ``reason`` and ``date`` are required when the key is present — a decision against a need must
137
+ say why and when, the same way an attestation needs who and when. ``kind`` is optional and
138
+ defaults to ``wont_do``; it is validated with the same ``Enum(name) except ValueError`` pattern
139
+ as ``SourceKind``, so an unknown kind is a :class:`LoaderError` the author owns.
137
140
  """
138
141
  if raw is None:
139
142
  return None
@@ -142,7 +145,13 @@ def _withdrawal(raw: object, where: str) -> Withdrawal | None:
142
145
  date = _opt_str(tbl.get("date"), f"{where}.date")
143
146
  if not reason or not date:
144
147
  raise LoaderError(f"{where}: a withdrawal needs both 'reason' and 'date'")
145
- return Withdrawal(reason=reason, date=date)
148
+ kind_name = _opt_str(tbl.get("kind"), f"{where}.kind") or WithdrawalKind.WONT_DO.value
149
+ try:
150
+ kind = WithdrawalKind(kind_name)
151
+ except ValueError:
152
+ kinds = "|".join(k.value for k in WithdrawalKind)
153
+ raise LoaderError(f"{where}.kind: unknown withdrawal kind {kind_name!r} ({kinds})") from None
154
+ return Withdrawal(reason=reason, date=date, kind=kind)
146
155
 
147
156
 
148
157
  # Old source-kind names (pre-0.3.58) mapped to the primary/secondary/assumption ladder, so
@@ -161,17 +161,33 @@ class Attestation:
161
161
  comment: str | None = None # the review's feedback / rationale, kept on the record
162
162
 
163
163
 
164
+ class WithdrawalKind(StrEnum):
165
+ """Why a need is off the board — the decision's *kind*, as data, not only free-text reason.
166
+
167
+ All three take the need off the active board and out of coverage identically; the kind records
168
+ *why* so the board can tell a validated-but-off-strategy need apart from one killed as not
169
+ worth doing. ``OUT_OF_SCOPE`` is the case a real, client-evidenced need is declined because it
170
+ is not the product being built — distinct from ``WONT_DO`` (decided against on its merits) and
171
+ ``DUPLICATE`` (the same want is tracked under another need).
172
+ """
173
+
174
+ WONT_DO = "wont_do" # decided against on its merits — the default, #74's original meaning
175
+ OUT_OF_SCOPE = "out_of_scope" # real and valid, but not this product
176
+ DUPLICATE = "duplicate" # the same want is tracked elsewhere
177
+
178
+
164
179
  @dataclass(frozen=True)
165
180
  class Withdrawal:
166
181
  """A decision not to pursue a need — withdrawn / won't-do (#74).
167
182
 
168
183
  Unlike a draft (staged, not yet decided), a withdrawal is a decision *against*: the need is
169
- taken off the active board and out of coverage, with its ``reason`` and ``date`` kept on the
170
- record as the durable trace (``prodc show`` still renders it). Reinstate to put it back.
184
+ taken off the active board and out of coverage, with its ``reason``, ``date`` and ``kind`` kept
185
+ on the record as the durable trace (``prodc show`` still renders it). Reinstate to put it back.
171
186
  """
172
187
 
173
188
  reason: str
174
189
  date: str
190
+ kind: WithdrawalKind = WithdrawalKind.WONT_DO
175
191
 
176
192
 
177
193
  @dataclass(frozen=True)
@@ -474,16 +474,21 @@ def withdraw(
474
474
  *,
475
475
  reason: str,
476
476
  date: str,
477
+ kind: str = "wont_do",
477
478
  expect_sha: str | None,
478
479
  dry_run: bool,
479
480
  ) -> Edit:
480
481
  """Record a decision against a need — withdrawn / won't-do (#74).
481
482
 
482
- Writes a ``withdrawn: {reason, date}`` mapping onto the need, which takes it off the active
483
- board and out of coverage; the record stays as its durable trace. Replaces any existing
484
- withdrawal (re-withdrawing updates the reason/date). Reinstate with :func:`reinstate`.
483
+ Writes a ``withdrawn: {reason, date, kind?}`` mapping onto the need, which takes it off the
484
+ active board and out of coverage; the record stays as its durable trace. ``kind`` says *why*
485
+ (``wont_do`` default, ``out_of_scope``, ``duplicate``) and is written only when it is not the
486
+ default, to keep the common case clean. Replaces any existing withdrawal (re-withdrawing
487
+ updates it). Reinstate with :func:`reinstate`.
485
488
  """
486
489
  mark: dict[str, object] = {"reason": reason, "date": date}
490
+ if kind != "wont_do":
491
+ mark["kind"] = kind
487
492
  path, _ = _locate(config, need_id)
488
493
  doc, old_text = _read_doc(path)
489
494
  if expect_sha is not None and _sha256(old_text) != expect_sha:
@@ -242,7 +242,11 @@ def test_show_json_carries_withdrawn(tmp_path: Path, capsys: pytest.CaptureFixtu
242
242
 
243
243
  main(["show", "W-1", "--config", str(_project(tmp_path)), "--json"])
244
244
  payload = json.loads(capsys.readouterr().out)
245
- assert payload["withdrawn"] == {"reason": "superseded by N-1", "date": "2026-10-10"}
245
+ assert payload["withdrawn"] == {
246
+ "reason": "superseded by N-1",
247
+ "date": "2026-10-10",
248
+ "kind": "wont_do", # default when the YAML omits kind
249
+ }
246
250
 
247
251
 
248
252
  def test_status_json_live_need_has_null_withdrawn(
@@ -254,3 +258,85 @@ def test_status_json_live_need_has_null_withdrawn(
254
258
  payload = json.loads(capsys.readouterr().out)
255
259
  n1 = next(n for n in payload["needs"] if n["id"] == "N-1")
256
260
  assert n1["withdrawn"] is None
261
+
262
+
263
+ # --- withdrawal kind (#74 follow-up) ----------------------------------------
264
+
265
+ _KIND_NEEDS = """
266
+ needs:
267
+ - id: N-1
268
+ text: user can see a delivered thing
269
+ proofs: ["x:1"]
270
+ - id: OOS-1
271
+ text: a real but off-strategy need
272
+ withdrawn:
273
+ reason: not the product we build
274
+ date: 2026-10-10
275
+ kind: out_of_scope
276
+ """
277
+
278
+
279
+ def test_loader_parses_withdrawal_kind(tmp_path: Path) -> None:
280
+ from prodc.model import WithdrawalKind
281
+
282
+ cfg = Config.load(_project(tmp_path, needs=_KIND_NEEDS))
283
+ by_id = {n.id: n for n in load(cfg).needs}
284
+ assert by_id["OOS-1"].withdrawn is not None
285
+ assert by_id["OOS-1"].withdrawn.kind is WithdrawalKind.OUT_OF_SCOPE
286
+
287
+
288
+ def test_withdrawal_kind_defaults_wont_do(tmp_path: Path) -> None:
289
+ from prodc.model import WithdrawalKind
290
+
291
+ cfg = Config.load(_project(tmp_path)) # W-1 omits kind
292
+ by_id = {n.id: n for n in load(cfg).needs}
293
+ w = by_id["W-1"].withdrawn
294
+ assert w is not None and w.kind is WithdrawalKind.WONT_DO
295
+
296
+
297
+ def test_unknown_withdrawal_kind_rejected(tmp_path: Path) -> None:
298
+ needs = _KIND_NEEDS.replace("kind: out_of_scope", "kind: bogus")
299
+ with pytest.raises(LoaderError, match="unknown withdrawal kind 'bogus'"):
300
+ load(Config.load(_project(tmp_path, needs=needs)))
301
+
302
+
303
+ def test_withdraw_writes_non_default_kind(tmp_path: Path) -> None:
304
+ from prodc.cli import main
305
+ from prodc.model import WithdrawalKind
306
+
307
+ cfg = _project(tmp_path)
308
+ code = main(
309
+ ["withdraw", "N-1", "--reason", "off strategy", "--kind", "out_of_scope",
310
+ "--date", "2026-10-15", "--config", str(cfg)]
311
+ )
312
+ assert code == 0
313
+ by_id = {n.id: n for n in load(Config.load(cfg)).needs}
314
+ w = by_id["N-1"].withdrawn
315
+ assert w is not None and w.kind is WithdrawalKind.OUT_OF_SCOPE
316
+
317
+
318
+ def test_withdraw_omits_default_kind_in_yaml(tmp_path: Path) -> None:
319
+ from prodc.cli import main
320
+
321
+ cfg = _project(tmp_path)
322
+ main(["withdraw", "N-1", "--reason", "nope", "--date", "2026-10-15", "--config", str(cfg)])
323
+ text = (tmp_path / "needs" / "a.yaml").read_text(encoding="utf-8")
324
+ assert "kind:" not in text # wont_do is the default; not written, keeps files clean
325
+
326
+
327
+ def test_status_breaks_down_withdrawn_by_kind(
328
+ tmp_path: Path, capsys: pytest.CaptureFixture[str]
329
+ ) -> None:
330
+ from prodc.cli import main
331
+
332
+ main(["status", "--config", str(_project(tmp_path, needs=_KIND_NEEDS))])
333
+ out = capsys.readouterr().out
334
+ assert "withdrawn: 1 (decided against) — 1 out_of_scope" in out
335
+
336
+
337
+ def test_show_tags_non_default_kind(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
338
+ from prodc.cli import main
339
+
340
+ main(["show", "OOS-1", "--config", str(_project(tmp_path, needs=_KIND_NEEDS))])
341
+ out = capsys.readouterr().out
342
+ assert "withdrawn [out_of_scope]: not the product we build (2026-10-10)" in out
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes