@softure-ai/skills 0.23.0 → 0.24.0
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.
- package/README.md +7 -2
- package/WORKFLOW.md +66 -9
- package/package.json +1 -1
- package/rules/AGENTS.md +7 -2
- package/scripts/portfolio.py +25 -5
- package/skills/softure-doctor/SKILL.md +18 -6
- package/skills/softure-doctor/references/state.schema.json +2 -1
- package/skills/softure-doctor/scripts/context_state.py +96 -6
- package/skills/softure-doctor/scripts/doctor.py +110 -10
- package/skills/softure-doctor/scripts/doctor_fix.py +66 -0
- package/skills/softure-doctor/scripts/doctor_sweep.py +174 -8
- package/skills/softure-roadmap/SKILL.md +18 -4
- package/skills/softure-roadmap/references/example-roadmap.md +30 -0
- package/skills/softure-roadmap/references/slicing.md +12 -3
package/README.md
CHANGED
|
@@ -32,7 +32,9 @@ It never overwrites a skill folder it did not install. Flags: `--dry-run`, `--ta
|
|
|
32
32
|
**CI job.** Run the doctor in a CI job named `context-doctor`, with no paths filter and no condition, so
|
|
33
33
|
documentation-only changes are checked too (in a project that already has history, once the rollout below
|
|
34
34
|
brings the doctor to zero). Keep that name: outside readers (`portfolio --source api`, an aggregator) look for
|
|
35
|
-
the `context-doctor` check run on the main branch's head.
|
|
35
|
+
the `context-doctor` check run on the main branch's head. In GitHub Actions the doctor writes its failure codes on
|
|
36
|
+
that check run (the annotation `context-doctor failure codes`, then one per failure) and in the job summary, so a
|
|
37
|
+
reader gets the codes through the forge API without a checkout.
|
|
36
38
|
|
|
37
39
|
```yaml
|
|
38
40
|
context-doctor:
|
|
@@ -57,7 +59,10 @@ usually fails on history. Put it right, in this order, one pass per repository:
|
|
|
57
59
|
2. `npx softure-skills doctor --sweep --json`, worked by an agent with the `softure-doctor` skill
|
|
58
60
|
("Sweep history to zero"): every entry settled with its evidence (commit, release, file), never
|
|
59
61
|
without, in one change, until the doctor exits 0. Entries classed `superseded` (later roadmaps,
|
|
60
|
-
releases or changes made them obsolete) are closed by the agent as obsolete, never forwarded
|
|
62
|
+
releases or changes made them obsolete) are closed by the agent as obsolete, never forwarded; post-merge
|
|
63
|
+
steps (a release after the merge, `close #N`) are checked with the forge through `gh`, by the sweep itself
|
|
64
|
+
when it can reach it, else by the agent (class `forge`). A check carried to another roadmap (`→ roadmap-x`)
|
|
65
|
+
is ticked by `--fix`.
|
|
61
66
|
3. The owner's short list: only real owner items (a decision about future work, a secret, account or
|
|
62
67
|
connector, a step outside the repository), carried to the live roadmap or an `owner-word` issue.
|
|
63
68
|
4. The `context-doctor` job above, once the doctor is at zero.
|
package/WORKFLOW.md
CHANGED
|
@@ -80,6 +80,8 @@ or languages.
|
|
|
80
80
|
// at once (default; branches never edit roadmap.md, so merging <main> in never conflicts
|
|
81
81
|
// on it); "branch" commits them on the session branch only, <main> changes only by the merge
|
|
82
82
|
},
|
|
83
|
+
"roadmap": { "sizes": false }, // optional: true lets softure-roadmap write a relative size (S / M / L) per item and
|
|
84
|
+
// a `### Slices` block (§5); default: only when the owner asks for sizes
|
|
83
85
|
"release": { "owner": true }, // releases and deploys are never done by skills when true; false lets an autonomous
|
|
84
86
|
// project release through its own pipeline (never a production deploy, §8.4)
|
|
85
87
|
"autonomy": { // optional, read only when mode is "autonomous" (§8.4)
|
|
@@ -284,6 +286,14 @@ updated: 2026-10-01
|
|
|
284
286
|
## Order
|
|
285
287
|
Why this order; which items may run in parallel and which files each one owns.
|
|
286
288
|
|
|
289
|
+
**Sizes:** relative to each other, never hours or dates. S: … M: … L: … (optional, see below)
|
|
290
|
+
|
|
291
|
+
### Slices (optional, see below)
|
|
292
|
+
| Slice | Items | Size |
|
|
293
|
+
| --- | --- | --- |
|
|
294
|
+
| **1. First usable** | FC-1, FC-2 | 1 S, 1 M |
|
|
295
|
+
| 2. … | FC-3 | 1 L |
|
|
296
|
+
|
|
287
297
|
## Items
|
|
288
298
|
|
|
289
299
|
### FC-1: Hero in balance
|
|
@@ -291,6 +301,8 @@ Why this order; which items may run in parallel and which files each one owns.
|
|
|
291
301
|
- **Status:** ready
|
|
292
302
|
- **Outcome:** …
|
|
293
303
|
- **Prerequisites:** …
|
|
304
|
+
- **Touches (estimate):** files and areas, from a quick search
|
|
305
|
+
- **Size:** S (optional, see below)
|
|
294
306
|
- **Unknowns:** questions research must answer
|
|
295
307
|
- **Risk:** …
|
|
296
308
|
- **Baseline:** how we measure before/after
|
|
@@ -317,6 +329,16 @@ item block and appends to `## Done` itself. On a change branch (`softure-worktre
|
|
|
317
329
|
branch never conflicts on the roadmap. Orchestrators fall back to `wt-roadmap.py done` themselves when a thread did not
|
|
318
330
|
run it.
|
|
319
331
|
Each item block may carry `- **Input:** <path>` (e.g. the change folder), which tells research where its brief lives.
|
|
332
|
+
|
|
333
|
+
**Sizes and slices (optional).** An owner who funds a roadmap in slices ("the first usable slice now, the rest after
|
|
334
|
+
it") needs a rough relative size to make that call. `softure-roadmap` writes sizes only when the owner asks for them or
|
|
335
|
+
`workflow.json` sets `roadmap.sizes: true`; otherwise a roadmap has none:
|
|
336
|
+
- `- **Size:** S | M | L` in an item block, after `Touches (estimate)`. Sizes are relative to each other, never hours,
|
|
337
|
+
days, points or dates; their meaning is defined once, in a `**Sizes:**` line under `## Order`.
|
|
338
|
+
- `### Slices` under `## Order`: named groups of items in order, the first usable slice marked (bold), each with its size
|
|
339
|
+
sum as counts (`2 S, 1 M`), so the owner can fund slice by slice. Every sized item sits in exactly one slice.
|
|
340
|
+
- The `## At a glance` table, the row status and the item block's first two fields stay as they are: the parsers
|
|
341
|
+
never read a size.
|
|
320
342
|
`change.md` is defined **only** in §4. softure-roadmap (step 14, for every item it records) and softure-new write the same
|
|
321
343
|
format; softure-new takes over a `change.md` the roadmap opened.
|
|
322
344
|
|
|
@@ -623,8 +645,26 @@ after the last item", "drop SA-12"). It is the owner's word in writing, equal to
|
|
|
623
645
|
`change.md` or a standing order) gets a comment with the question and stays open.
|
|
624
646
|
- **Manual mode.** The coordinator shows open `owner-word` issues to the owner at the start of a session and acts
|
|
625
647
|
only on the owner's word in the conversation; it then comments and closes them the same way.
|
|
648
|
+
- **Answering a queue entry.** An issue that answers one `owner_queue` entry (§12.1) may carry, next to the prose, one
|
|
649
|
+
machine-readable line that names the entry by its `id` and the answer:
|
|
650
|
+
|
|
651
|
+
```markdown
|
|
652
|
+
Start the payments roadmap once the provider account is open.
|
|
653
|
+
|
|
654
|
+
<!-- owner-word: {"entry": "oq-bfe20288d8", "answer": "yes"} -->
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
`answer` is `yes`, `no` or `later`; the prose still says the decision and wins where the two differ (the coordinator
|
|
658
|
+
asks in a comment). The coordinator settles the entry it names in the file `source` points to, citing the issue:
|
|
659
|
+
`yes`: it carries the decision out and ticks the entry `— done: #N` (with the thread, PR or merge SHA when there is
|
|
660
|
+
one); `no`: it ticks the entry `— declined: #N` and records what follows in the roadmap (an item `dropped`, a queued
|
|
661
|
+
roadmap left waiting); `later`: it leaves the entry open and appends `(later: #N)`, so the entry keeps its `id` and
|
|
662
|
+
stays in the queue. An `entry` that is not in the current `state.json` (already settled, or an unknown id) gets a
|
|
663
|
+
comment saying so, and the issue is closed when the entry was settled. An issue without the line is read as prose,
|
|
664
|
+
as before.
|
|
626
665
|
- **Not in `state.json`.** Open owner-word issues live on the forge; an aggregator reads both (`state.json` for what
|
|
627
|
-
waits for the owner, the forge for the words already given).
|
|
666
|
+
waits for the owner, the forge for the words already given). With the line, it tells which entries an open issue
|
|
667
|
+
already answers (its `entry`) and shows them as answered until the entry leaves the queue.
|
|
628
668
|
|
|
629
669
|
## 9. Commits
|
|
630
670
|
|
|
@@ -722,7 +762,7 @@ A project without the file gets it from the first of these runs; nothing has to
|
|
|
722
762
|
|
|
723
763
|
```jsonc
|
|
724
764
|
{
|
|
725
|
-
"schema_version": 1
|
|
765
|
+
"schema_version": 2, // 2 adds owner_queue[].id; read a version 1 file as one without ids
|
|
726
766
|
"project": "Example clinic", // workflow.json `project`, else the roadmap's, else the repository name; never null
|
|
727
767
|
"mode": "autonomous", "main_branch": "main",
|
|
728
768
|
"updated_at": "2026-11-20T09:00:00Z", // changes only when the content does
|
|
@@ -740,8 +780,8 @@ A project without the file gets it from the first of these runs; nothing has to
|
|
|
740
780
|
"open_changes": [ { "change_id": "search-titles", "title": "…", "status": "implementing", "roadmap_item": "SR-2",
|
|
741
781
|
"updated": "2026-11-10", "stage": "implement 2/3" } ],
|
|
742
782
|
"owner_queue": [ // everything that waits for the owner, oldest first
|
|
743
|
-
{ "kind": "decision", "source": "context/foundation/roadmap.md#Owner decisions and checks",
|
|
744
|
-
"since": "2026-11-10", "text": "**SR-5**: choose the ranking provider …" }
|
|
783
|
+
{ "id": "oq-06e40f59e9", "kind": "decision", "source": "context/foundation/roadmap.md#Owner decisions and checks",
|
|
784
|
+
"item": "SR-5", "since": "2026-11-10", "text": "**SR-5**: choose the ranking provider …" }
|
|
745
785
|
],
|
|
746
786
|
"last_release": { "version": "v1.4.0", "date": "2026-10-02", // as a closed roadmap recorded it (§5.2); the
|
|
747
787
|
"source": "context/foundation/archive/2026-09-30-roadmap.md" } // portfolio asks the forge first
|
|
@@ -767,7 +807,11 @@ An unticked entry in any other archived roadmap, and any unticked `## Owner deci
|
|
|
767
807
|
roadmap, is history to settle (the doctor's `archived-roadmap-open-checks`), not something that waits for the owner.
|
|
768
808
|
Entries from open changes are refreshed on every write and never make the file stale, like `open_changes`. `source` is the file, `#`, and the heading; `item` the roadmap ID the entry names;
|
|
769
809
|
`since` the date in the entry, else the file's `updated`, and once written it is kept for that entry on every
|
|
770
|
-
rewrite.
|
|
810
|
+
rewrite. `id` is a short stable id (`oq-` and a hash of `source`, `item` and the entry's text when it first appeared):
|
|
811
|
+
it is kept, like `since`, on every rewrite, also when only the entry's wording changed or it moved to another heading
|
|
812
|
+
of the same file (the same item and kind, or text that is still close), so a reader follows one entry across scans
|
|
813
|
+
without fingerprinting it and an owner-word issue can name the entry it answers (§8.6). Owner-word issues live on the
|
|
814
|
+
forge, not here.
|
|
771
815
|
|
|
772
816
|
`open_changes` and `updated_at` are refreshed on every write but never make the file stale: a change branch edits
|
|
773
817
|
its own `change.md` without touching `state.json`, and stays green.
|
|
@@ -800,7 +844,11 @@ left after them; `--fix --write` applies them, only under `context/`, and a seco
|
|
|
800
844
|
the file's current path when git history shows where it moved (rename detection, followed across moves); a file
|
|
801
845
|
deleted on purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
802
846
|
- an unticked Progress item of an archived plan that is struck through or carries a dropped/cancelled/not-applicable
|
|
803
|
-
note is normalised to `- [x] ~~<item>~~ — dropped: <note
|
|
847
|
+
note is normalised to `- [x] ~~<item>~~ — dropped: <note>`;
|
|
848
|
+
- an unticked owner check or pre-release step of an archived roadmap, or an open row, whose text carries a carry
|
|
849
|
+
marker (`→ roadmap-<slug>`, `carried to <roadmap>`) naming a roadmap that exists (queued, archived or the live one)
|
|
850
|
+
is ticked `- [x] <text> — carried to <path>` (a row becomes `carried (to <path>)`); the sweep shows such an entry
|
|
851
|
+
with that roadmap as its evidence. A marker whose roadmap does not exist stays a failure.
|
|
804
852
|
|
|
805
853
|
A row whose move or deletion the history does not show, and a live index, are left alone and named. A shallow clone
|
|
806
854
|
works on the commits it holds and names what lies past its edge. Everything else is a judgement case.
|
|
@@ -815,7 +863,12 @@ and later roadmaps that mention the item. Each entry has a class. `evidence`: th
|
|
|
815
863
|
no direct evidence, but later work made it obsolete (for an owner check or open row of an archived roadmap, a later
|
|
816
864
|
roadmap was closed and a release shipped after it, or the same item ID or file area appears in a later archived change;
|
|
817
865
|
for a Progress item, a later phase of the same plan is ticked); its evidence names that roadmap, release or change, and
|
|
818
|
-
the agent closes it as `obsolete: superseded by <ref>` itself, never forwards it.
|
|
866
|
+
the agent closes it as `obsolete: superseded by <ref>` itself, never forwards it. Post-merge steps that git history
|
|
867
|
+
cannot prove (a release after the merge, `close #N`, the Dependabot pull requests) are asked of the forge through `gh`
|
|
868
|
+
when it is reachable (a GitHub remote and credentials): a release published on or after the merge date, the state of
|
|
869
|
+
each `#N`, the open Dependabot pull requests; when every check holds the entry is `evidence` with those pointers.
|
|
870
|
+
`forge`: the same steps when the forge cannot be reached from where the sweep runs (or with `--no-forge`); an agent
|
|
871
|
+
checks them with `gh` before anything goes to the owner. `owner`: only for what is still
|
|
819
872
|
meaningful today, a decision about future work, a secret, account or connector, or a step outside the repository whose
|
|
820
873
|
effect the agent cannot see; the entry says which (`owner_reason`) and what the sweep looked for (`tried`). The
|
|
821
874
|
`softure-doctor` skill ("Sweep history to zero") tells an agent how to work it: every entry is settled with its evidence
|
|
@@ -833,7 +886,10 @@ is the sweep to zero.
|
|
|
833
886
|
A project that has never written `state.json` gets a note, not a failure. **Adopting projects run the doctor in a CI
|
|
834
887
|
job named `context-doctor`**, with no paths filter and no condition, so documentation-only changes are checked too and
|
|
835
888
|
an outside reader finds the result by that name: the check run `context-doctor` on the main branch's head says whether
|
|
836
|
-
the project's context contract is green (`portfolio --source api` reads it).
|
|
889
|
+
the project's context contract is green (`portfolio --source api` reads it). In GitHub Actions the doctor also leaves
|
|
890
|
+
its failure codes on that check run: the first annotation, titled `context-doctor failure codes`, lists every code with
|
|
891
|
+
its count (`archived-change-progress (3), state-stale (1)`), one annotation per failure follows (as many as GitHub
|
|
892
|
+
keeps), and the job summary holds the same table. Keep the job name, whatever the rest of
|
|
837
893
|
the workflow looks like. The installer prints the job until a workflow under `.github/workflows/` runs the doctor, and
|
|
838
894
|
asks to rename it while the job that runs it has another name:
|
|
839
895
|
|
|
@@ -865,7 +921,8 @@ where `repo` is `owner/name`, a git URL or a local path. One row per project:
|
|
|
865
921
|
`project | active roadmap X/N | queued | open changes | owner queue | last release | doctor`. The doctor runs on the
|
|
866
922
|
same tree; a project without `state.json` yet gets one built in memory (marked `*`). `--source api` reads only
|
|
867
923
|
`state.json` through `gh api` and runs no doctor; its doctor column is the `context-doctor` check run on the main
|
|
868
|
-
branch's head (`ok`, `failing
|
|
924
|
+
branch's head (`ok`, `failing` with the doctor's failure codes from that run's annotations, `pending`, or `missing` when
|
|
925
|
+
the project has no job by that name). **Last release comes from the forge** when it can: the latest GitHub
|
|
869
926
|
release through `gh api` (both modes, for a GitHub repository; a local checkout counts when its `origin` is on GitHub),
|
|
870
927
|
else the highest `v*` tag (git mode), else `state.json` → `last_release`, which only records what a closed roadmap
|
|
871
928
|
wrote and is shown labelled: `v1.4.0 (roadmap, 2026-10-02)`. `--json` gives `last_release`, `last_release_date` and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/skills",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "SOFTURE agent skills: a spec-driven delivery workflow (shape → prd → roadmap → plan → implement → review) plus parallel worktree orchestration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/rules/AGENTS.md
CHANGED
|
@@ -86,7 +86,8 @@ step the owner has to undo.
|
|
|
86
86
|
trade-off), ask with a recommendation instead of deciding silently.
|
|
87
87
|
- **Owner-word issues** (label `owner-word`, WORKFLOW §8.6): at the start of a session, list the open
|
|
88
88
|
ones in this project's repository and show them to the owner first, with what each would start. Act
|
|
89
|
-
on one only after the owner's word in this conversation; then comment what was done and close it.
|
|
89
|
+
on one only after the owner's word in this conversation; then comment what was done and close it. One that names
|
|
90
|
+
an `owner_queue` entry (`<!-- owner-word: {"entry": …} -->`) is settled on that entry, citing the issue (§8.6).
|
|
90
91
|
- Rules of autonomous projects (standing merge consent, coordinators, report cadences) do not apply
|
|
91
92
|
here, even when a memory or another session suggests them.
|
|
92
93
|
|
|
@@ -346,7 +347,11 @@ word in writing, equal to the same sentence in the main chat: one decision, its
|
|
|
346
347
|
on it like an order in the chat: a roadmap to start goes to a roadmap thread (`--promote`), a release
|
|
347
348
|
word is recorded where the release rules look for it (the roadmap header's `Release:` order, quoted with
|
|
348
349
|
the issue link), a "no" or "later" is recorded in the roadmap (`## Owner decisions and checks` or the
|
|
349
|
-
item's status).
|
|
350
|
+
item's status). An issue whose body carries `<!-- owner-word: {"entry": "<id>", "answer": "yes|no|later"} -->`
|
|
351
|
+
answers the `owner_queue` entry with that `id` in `context/state.json`: settle that entry in its `source` file and cite
|
|
352
|
+
the issue (`yes`: carry it out and tick it `— done: #N`; `no`: tick it `— declined: #N` and record what follows;
|
|
353
|
+
`later`: leave it open with `(later: #N)`); an `entry` no longer in the queue gets a comment saying so (WORKFLOW §8.6).
|
|
354
|
+
Then it comments what it did (thread, PR, merge SHA, roadmap line), closes the issue as
|
|
350
355
|
completed, and names it in the next report. An issue it cannot act on (unclear, contradicts `change.md`
|
|
351
356
|
or a standing order) gets one comment with the question and stays open; the question also goes to the
|
|
352
357
|
owner in the main chat. Owner-word issues are not work items: they never get a thread of their own
|
package/scripts/portfolio.py
CHANGED
|
@@ -30,9 +30,11 @@ repository, in both modes; a local checkout counts when its `origin` is on GitHu
|
|
|
30
30
|
`v*` tag (git mode), else the value a closed roadmap recorded in `state.json`, labelled `(roadmap)`.
|
|
31
31
|
`SOFTURE_GH` names another `gh` binary.
|
|
32
32
|
|
|
33
|
-
`--owner` prints only the owner queue across all projects, oldest first
|
|
33
|
+
`--owner` prints only the owner queue across all projects, oldest first, with each entry's `id` (an owner-word issue
|
|
34
|
+
names the entry it answers by that id, WORKFLOW §8.6). `--json` prints the same data
|
|
34
35
|
for another tool (`last_release` is the version; `last_release_source` is `release`, `tag` or `roadmap`;
|
|
35
|
-
with `--source api`, `doctor_check` is the check run's status
|
|
36
|
+
with `--source api`, `doctor_check` is the check run's status, `doctor_check_url` its page and `doctor_check_codes`
|
|
37
|
+
the doctor's failure codes from the run's annotations; the table shows them after `failing`). Exit 1 when a project could not be read (its row says why); nothing is ever written
|
|
36
38
|
outside a temporary folder.
|
|
37
39
|
"""
|
|
38
40
|
from __future__ import annotations
|
|
@@ -57,6 +59,7 @@ GITHUB_RE = re.compile(r"github\.com[:/]([\w.-]+/[\w.-]+?)(?:\.git)?/?$")
|
|
|
57
59
|
SEMVER_RE = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)$")
|
|
58
60
|
# The CI job every adopting project runs the doctor in (WORKFLOW.md §12.2); its check run carries this name.
|
|
59
61
|
DOCTOR_CHECK = "context-doctor"
|
|
62
|
+
CODES_TITLE = "context-doctor failure codes" # the doctor's annotation that lists its failure codes
|
|
60
63
|
PASSING = ("success", "neutral", "skipped")
|
|
61
64
|
|
|
62
65
|
|
|
@@ -168,7 +171,20 @@ def doctor_check(slug: str, branch: str | None) -> dict:
|
|
|
168
171
|
status = "pending"
|
|
169
172
|
else:
|
|
170
173
|
status = "ok" if run.get("conclusion") in PASSING else "failing"
|
|
171
|
-
|
|
174
|
+
codes = failure_codes(slug, run) if status == "failing" else []
|
|
175
|
+
return {"status": status, "url": run.get("html_url"), "codes": codes}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def failure_codes(slug: str, run: dict) -> list[str]:
|
|
179
|
+
"""The doctor's failure codes of a failing check run, from its `context-doctor failure codes` annotation."""
|
|
180
|
+
if not run.get("id") or not (run.get("output") or {}).get("annotations_count", 1):
|
|
181
|
+
return []
|
|
182
|
+
annotations = gh_json(f"repos/{slug}/check-runs/{run['id']}/annotations")
|
|
183
|
+
for annotation in annotations if isinstance(annotations, list) else []:
|
|
184
|
+
if annotation.get("title") == CODES_TITLE:
|
|
185
|
+
return [part.strip().split(" (")[0] for part in (annotation.get("message") or "").split(",")
|
|
186
|
+
if part.strip()]
|
|
187
|
+
return []
|
|
172
188
|
|
|
173
189
|
|
|
174
190
|
def pick_release(forge: dict | None, tag: dict | None, state: dict | None) -> dict:
|
|
@@ -262,6 +278,7 @@ def read_api(project: dict) -> dict:
|
|
|
262
278
|
check = doctor_check(slug, project.get("branch"))
|
|
263
279
|
return {"branch": project.get("branch") or "default", "state": state, "state_source": source,
|
|
264
280
|
"doctor": None, "doctor_check": check["status"], "doctor_check_url": check["url"],
|
|
281
|
+
"doctor_check_codes": check.get("codes") or [],
|
|
265
282
|
**release_fields(release)}
|
|
266
283
|
|
|
267
284
|
|
|
@@ -296,6 +313,8 @@ def collect(projects: list[dict], source: str) -> list[dict]:
|
|
|
296
313
|
def check_cell(row: dict) -> str:
|
|
297
314
|
"""The doctor column of a row read through the API: the `context-doctor` check run, else `n/a`."""
|
|
298
315
|
check = row.get("doctor_check")
|
|
316
|
+
if check == "failing" and row.get("doctor_check_codes"):
|
|
317
|
+
return f"failing: {', '.join(row['doctor_check_codes'])}"
|
|
299
318
|
return check if check and check != "unknown" else "n/a"
|
|
300
319
|
|
|
301
320
|
|
|
@@ -363,9 +382,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
363
382
|
print(json.dumps({"generated_at": generated, "projects": rows}, indent=2, ensure_ascii=False))
|
|
364
383
|
elif flags["--owner"]:
|
|
365
384
|
entries = owner_entries(rows)
|
|
366
|
-
print(table(["since", "project", "kind", "what", "source"],
|
|
385
|
+
print(table(["since", "project", "kind", "what", "source", "id"],
|
|
367
386
|
[[e.get("since") or "—", e["project"], e["kind"], e["text"],
|
|
368
|
-
e["source"].replace("context/", "")] for e in entries])
|
|
387
|
+
e["source"].replace("context/", ""), e.get("id") or "—"] for e in entries])
|
|
388
|
+
if entries else "Nothing waits for the owner.")
|
|
369
389
|
else:
|
|
370
390
|
print(table(["project", "active roadmap X/N", "queued", "open changes", "owner queue", "last release", "doctor"],
|
|
371
391
|
[summary_cells(row) for row in rows]))
|
|
@@ -38,7 +38,9 @@ backlog), §5.2 (closing a roadmap), §6 (Progress). Two scripts next to this fi
|
|
|
38
38
|
|
|
39
39
|
- **CI of every adopting project**, documentation-only changes included: `npx softure-skills doctor` in a job
|
|
40
40
|
named `context-doctor`, with no paths filter and no condition (the installer prints the job; WORKFLOW §12.2).
|
|
41
|
-
Keep the name: outside readers look for that check run on the main branch's head
|
|
41
|
+
Keep the name: outside readers look for that check run on the main branch's head; in GitHub Actions the doctor
|
|
42
|
+
writes its failure codes there as annotations (the first, `context-doctor failure codes`, lists them all) and as
|
|
43
|
+
the job summary. A project with history adds it after the rollout (WORKFLOW §12.4):
|
|
42
44
|
`--fix --write`, the sweep to zero, the owner's short list, then the CI job. Drift happens in the documents, so a CI that skips doc-only
|
|
43
45
|
changes misses it.
|
|
44
46
|
- **`softure-archive`** (on the main branch) and **`softure-roadmap`** (record, `--queue`, `--promote`,
|
|
@@ -68,7 +70,7 @@ Each problem is one line `FAIL <code> <path>: <what>`. Fix the file it names, ne
|
|
|
68
70
|
## Mechanical repairs: `--fix`
|
|
69
71
|
|
|
70
72
|
`doctor.py --fix` prints every edit it would make and the failures left after them; `--fix --write`
|
|
71
|
-
applies them. It writes only under `context/`, and a second run changes nothing.
|
|
73
|
+
applies them. It writes only under `context/`, and a second run changes nothing. Four shapes are
|
|
72
74
|
mechanical:
|
|
73
75
|
|
|
74
76
|
- `archived-change-status`: the archived `change.md` gets `status: archived`, and the old value is kept
|
|
@@ -77,7 +79,11 @@ mechanical:
|
|
|
77
79
|
path when git history shows where it moved (renames followed across several moves); a file deleted on
|
|
78
80
|
purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
79
81
|
- a dropped Progress item of an archived plan (unticked, but struck through or carrying an explicit
|
|
80
|
-
dropped/cancelled/not-applicable note) is normalised to `- [x] ~~<item>~~ — dropped: <note
|
|
82
|
+
dropped/cancelled/not-applicable note) is normalised to `- [x] ~~<item>~~ — dropped: <note>`;
|
|
83
|
+
- a carried entry of an archived roadmap: an unticked owner check or pre-release step, or an open row, whose
|
|
84
|
+
text carries a carry marker (`→ roadmap-<slug>`, `carried to <roadmap>`) naming a roadmap that exists
|
|
85
|
+
(queued, archived or the live one) is ticked `- [x] <text> — carried to <path>` (a row becomes
|
|
86
|
+
`carried (to <path>)`). A marker whose roadmap does not exist is left alone and named: it stays a failure.
|
|
81
87
|
|
|
82
88
|
It skips, and names, every row it cannot settle from history (a live index, a target whose move or
|
|
83
89
|
deletion the history does not show). A shallow clone works on the commits it holds and names what lies
|
|
@@ -103,6 +109,8 @@ The evidence it looks for:
|
|
|
103
109
|
| `archived-roadmap-summary` | the merge (or squash) commit of the item's change on the main line; the last SHA of its archived plan |
|
|
104
110
|
| `archived-roadmap-open-items` | the item's archived change folder, its merge commit, the release that contains it, later roadmaps that mention it |
|
|
105
111
|
| `archived-roadmap-open-checks` | the same for the item the check names, plus the first release after the close (for pre-release steps) |
|
|
112
|
+
| carried entries | a check or row with a carry marker whose roadmap exists: that roadmap (`--fix --write` ticks it) |
|
|
113
|
+
| post-merge steps | a release after the merge, `close #N`, the Dependabot pull requests: asked of the forge through `gh` (the first release published on or after the merge date, the state of `#N`, open Dependabot pull requests); class `forge` when the forge cannot be reached (`--no-forge` skips it) |
|
|
106
114
|
| anything else | the file to fix (`index-missing-file`: where git history says the file went, or that it never existed) |
|
|
107
115
|
|
|
108
116
|
Work the list in one change per repository (`docs(context): settle history to zero`):
|
|
@@ -121,7 +129,11 @@ Work the list in one change per repository (`docs(context): settle history to ze
|
|
|
121
129
|
superseded by <release / roadmap / change>` (a row: `dropped (obsolete: superseded by <ref>)`).
|
|
122
130
|
Never forward it to the owner: a screenshot review of a page rebuilt since, or "after the release,
|
|
123
131
|
re-run X" for a release long gone, has no answer the owner could give.
|
|
124
|
-
3.
|
|
132
|
+
3. **`forge` entries are yours, not the owner's.** Check each with `gh` before anything goes to the owner:
|
|
133
|
+
`gh release list` (a release published after the merge), `gh issue view <N>` / `gh pr view <N>`,
|
|
134
|
+
`gh pr list --author app/dependabot`. Tick it with what the forge shows (`— done: v1.5.0`,
|
|
135
|
+
`— done: #12 closed`); only a step the forge shows not done, and only the owner can do, goes on.
|
|
136
|
+
4. **Only true owner items stay open, in one place.** An entry is the owner's when the evidence does
|
|
125
137
|
not settle it, nothing later superseded it, and only the owner can: a decision about future work
|
|
126
138
|
that is still open, a secret, account or connector, or a step outside the repository (a production
|
|
127
139
|
setting, a real device) whose effect the agent cannot see. Before forwarding an `unsettled` entry,
|
|
@@ -129,8 +141,8 @@ Work the list in one change per repository (`docs(context): settle history to ze
|
|
|
129
141
|
live roadmap's `## Owner decisions and checks` (or an `owner-word` issue, WORKFLOW §8.6) and tick
|
|
130
142
|
the archived line `— carried to <path | #N>`. Never carry a check whose work the evidence shows done,
|
|
131
143
|
and never tick a decision on the owner's behalf.
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
5. Regenerate the state (`context_state.py write`) and re-run `doctor.py` until it exits 0. Commit.
|
|
145
|
+
6. Report: failures per code before and after, and **one short list for the owner**: `ID | what the
|
|
134
146
|
owner decides or does | where it lives now`. Nothing else is left open.
|
|
135
147
|
|
|
136
148
|
An entry the agent cannot settle and that is not the owner's (the evidence is ambiguous) is named in
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"open_changes", "owner_queue", "last_release"],
|
|
9
9
|
"additionalProperties": false,
|
|
10
10
|
"properties": {
|
|
11
|
-
"schema_version": { "type": "integer", "enum": [1] },
|
|
11
|
+
"schema_version": { "type": "integer", "enum": [1, 2], "description": "2 adds owner_queue[].id; a reader of version 1 files treats id as absent" },
|
|
12
12
|
"project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder); never null" },
|
|
13
13
|
"mode": { "type": "string", "enum": ["manual", "autonomous"] },
|
|
14
14
|
"main_branch": { "type": ["string", "null"] },
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"required": ["kind", "source", "item", "since", "text"],
|
|
105
105
|
"additionalProperties": false,
|
|
106
106
|
"properties": {
|
|
107
|
+
"id": { "type": "string", "description": "stable id of the entry (schema_version 2): set when the entry first appears, kept on every rewrite, also when only its wording changed or its heading moved within the file; absent in version 1 files" },
|
|
107
108
|
"kind": { "type": "string", "enum": ["word", "decision", "step", "secret"] },
|
|
108
109
|
"source": { "type": "string", "description": "file, then `#` and the heading" },
|
|
109
110
|
"item": { "type": ["string", "null"], "description": "roadmap item ID, when the entry names one" },
|
|
@@ -19,14 +19,19 @@ release is recorded. An unticked entry left in any other archived roadmap is his
|
|
|
19
19
|
(`../references/state.schema.json`). A reader needs this one file per repository instead of parsing
|
|
20
20
|
the markdown.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Every owner-queue entry has an `id`: a short hash of its `source`, `item` and text, taken when the entry first
|
|
23
|
+
appears. `id` and `since` are kept from the previous file for an entry that is still there, also when only its
|
|
24
|
+
wording changed or its heading moved within the same file (the same item, or text that is still close enough),
|
|
25
|
+
so a reader can follow one entry across rewrites and "oldest first" stays true. `updated_at` changes only when the
|
|
26
|
+
content does.
|
|
24
27
|
|
|
25
28
|
Importable: `from context_state import build_state, render_state, FsReader, GitReader, IndexReader`.
|
|
26
29
|
"""
|
|
27
30
|
from __future__ import annotations
|
|
28
31
|
|
|
29
32
|
import datetime as dt
|
|
33
|
+
import difflib
|
|
34
|
+
import hashlib
|
|
30
35
|
import json
|
|
31
36
|
import os
|
|
32
37
|
import re
|
|
@@ -35,7 +40,7 @@ import sys
|
|
|
35
40
|
|
|
36
41
|
sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/skills
|
|
37
42
|
|
|
38
|
-
SCHEMA_VERSION =
|
|
43
|
+
SCHEMA_VERSION = 2
|
|
39
44
|
STATE_PATH = "context/state.json"
|
|
40
45
|
WORKFLOW_PATH = "context/workflow.json"
|
|
41
46
|
ROADMAP_PATH = "context/foundation/roadmap.md"
|
|
@@ -487,9 +492,7 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
487
492
|
owner_queue += _handoff_entries(f"{CHANGES_DIR}/{name}/change.md", text, meta.get("roadmap_item"),
|
|
488
493
|
meta.get("updated") or today)
|
|
489
494
|
|
|
490
|
-
|
|
491
|
-
for entry in owner_queue:
|
|
492
|
-
entry["since"] = previous.get(_entry_key(entry)) or entry["since"]
|
|
495
|
+
owner_queue = carry_identity(owner_queue, (prior or {}).get("owner_queue") or [])
|
|
493
496
|
owner_queue.sort(key=lambda entry: (entry["since"] or "", entry["source"], entry["text"]))
|
|
494
497
|
|
|
495
498
|
state = {
|
|
@@ -541,6 +544,93 @@ def _entry_key(entry: dict) -> tuple:
|
|
|
541
544
|
return (entry.get("kind"), entry.get("source"), entry.get("text"))
|
|
542
545
|
|
|
543
546
|
|
|
547
|
+
# Text of an unmatched entry this close to a prior entry's text (difflib ratio) is the same entry reworded.
|
|
548
|
+
REWORD_RATIO = 0.6
|
|
549
|
+
# The same, across headings of one file (a moved entry): stricter, because the section changed too.
|
|
550
|
+
MOVED_RATIO = 0.8
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def entry_id(entry: dict) -> str:
|
|
554
|
+
"""A short id for a new owner-queue entry: a hash of its source, item and first line."""
|
|
555
|
+
first_line = (entry.get("text") or "").strip().splitlines()[0] if (entry.get("text") or "").strip() else ""
|
|
556
|
+
seed = "\n".join((entry.get("source") or "", entry.get("item") or "", first_line))
|
|
557
|
+
return "oq-" + hashlib.sha1(seed.encode("utf-8")).hexdigest()[:10]
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def _file_of(source: str | None) -> str:
|
|
561
|
+
return (source or "").split("#", 1)[0]
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def _same_entry_score(new: dict, old: dict) -> float | None:
|
|
565
|
+
"""How surely `old` (prior file) is `new` reworded or moved; None when it is not."""
|
|
566
|
+
if _file_of(new.get("source")) != _file_of(old.get("source")):
|
|
567
|
+
return None
|
|
568
|
+
same_section = new.get("source") == old.get("source")
|
|
569
|
+
ratio = difflib.SequenceMatcher(None, new.get("text") or "", old.get("text") or "").ratio()
|
|
570
|
+
if new.get("item") and new.get("item") == old.get("item") and new.get("kind") == old.get("kind"):
|
|
571
|
+
return 1.0 + ratio + (1.0 if same_section else 0.0)
|
|
572
|
+
if new.get("item") != old.get("item"):
|
|
573
|
+
return None
|
|
574
|
+
if ratio >= (REWORD_RATIO if same_section else MOVED_RATIO):
|
|
575
|
+
return ratio + (1.0 if same_section else 0.0)
|
|
576
|
+
return None
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def carry_identity(entries: list[dict], prior: list[dict]) -> list[dict]:
|
|
580
|
+
"""Give every entry an `id` and keep `id` and `since` of the prior entry it continues.
|
|
581
|
+
|
|
582
|
+
An entry with the same kind, source and text as a prior one continues it. Each remaining entry continues the
|
|
583
|
+
prior one it matches best: the same file, and the same item and kind, or (without an item) text that is still
|
|
584
|
+
close enough (`REWORD_RATIO` under the same heading, `MOVED_RATIO` under another). A prior entry is continued
|
|
585
|
+
at most once. Anything else is new and gets a fresh id; ids stay unique within the queue.
|
|
586
|
+
"""
|
|
587
|
+
unmatched = list(prior)
|
|
588
|
+
exact: dict[tuple, list[dict]] = {}
|
|
589
|
+
for old in unmatched:
|
|
590
|
+
exact.setdefault(_entry_key(old), []).append(old)
|
|
591
|
+
pending = []
|
|
592
|
+
for entry in entries:
|
|
593
|
+
candidates = exact.get(_entry_key(entry))
|
|
594
|
+
if candidates:
|
|
595
|
+
old = candidates.pop(0)
|
|
596
|
+
unmatched.remove(old)
|
|
597
|
+
_continue(entry, old)
|
|
598
|
+
else:
|
|
599
|
+
pending.append(entry)
|
|
600
|
+
pairs = []
|
|
601
|
+
for new_index, entry in enumerate(pending):
|
|
602
|
+
for old_index, old in enumerate(unmatched):
|
|
603
|
+
score = _same_entry_score(entry, old)
|
|
604
|
+
if score is not None:
|
|
605
|
+
pairs.append((score, new_index, old_index))
|
|
606
|
+
taken_new: set[int] = set()
|
|
607
|
+
taken_old: set[int] = set()
|
|
608
|
+
for _score, new_index, old_index in sorted(pairs, key=lambda pair: (-pair[0], pair[1], pair[2])):
|
|
609
|
+
if new_index in taken_new or old_index in taken_old:
|
|
610
|
+
continue
|
|
611
|
+
taken_new.add(new_index)
|
|
612
|
+
taken_old.add(old_index)
|
|
613
|
+
_continue(pending[new_index], unmatched[old_index])
|
|
614
|
+
used: set[str] = set()
|
|
615
|
+
result = []
|
|
616
|
+
for entry in entries:
|
|
617
|
+
ident = entry.get("id") if entry.get("id") not in used else None
|
|
618
|
+
if not ident:
|
|
619
|
+
base = entry_id(entry)
|
|
620
|
+
ident, suffix = base, 2
|
|
621
|
+
while ident in used:
|
|
622
|
+
ident, suffix = f"{base}-{suffix}", suffix + 1
|
|
623
|
+
used.add(ident)
|
|
624
|
+
result.append({"id": ident, **{key: value for key, value in entry.items() if key != "id"}})
|
|
625
|
+
return result
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
def _continue(entry: dict, old: dict) -> None:
|
|
629
|
+
if old.get("id"):
|
|
630
|
+
entry["id"] = old["id"]
|
|
631
|
+
entry["since"] = old.get("since") or entry["since"]
|
|
632
|
+
|
|
633
|
+
|
|
544
634
|
def comparable(state: dict | None) -> dict | None:
|
|
545
635
|
"""The state without what a rewrite may change on its own (VOLATILE_FIELDS, VOLATILE_SOURCES)."""
|
|
546
636
|
if state is None:
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
doctor.py [--root <dir>] [--json]
|
|
5
5
|
doctor.py --fix [--write] [--json] mechanical repairs of history (dry run unless --write)
|
|
6
|
-
doctor.py --sweep [--json]
|
|
6
|
+
doctor.py --sweep [--json] [--no-forge] every remaining failure as a worklist with evidence (read-only;
|
|
7
|
+
asks the forge through `gh` about post-merge steps unless --no-forge)
|
|
7
8
|
doctor.py --baseline last resort: accept today's failures in context/doctor-baseline.json
|
|
8
9
|
npx softure-skills doctor [...] (the same, from the installed package)
|
|
9
10
|
|
|
10
11
|
Adopting projects run it in a CI job named `context-doctor`, documentation-only changes included (that is where the
|
|
11
|
-
drift happens).
|
|
12
|
-
|
|
12
|
+
drift happens). In GitHub Actions it also writes the failure codes as annotations of that check run (the first one,
|
|
13
|
+
titled `context-doctor failure codes`, lists every code with its count) and as the job summary, so a reader of the
|
|
14
|
+
forge API sees the codes on the main branch's head without a checkout. `softure-archive` and `softure-roadmap
|
|
15
|
+
--close` run it before their commit and fix what they own. Each problem is one line `FAIL <code> <path>: <what>`; the codes:
|
|
13
16
|
|
|
14
17
|
roadmap-archived-not-removed roadmap.md is still there although the same roadmap is in foundation/archive/
|
|
15
18
|
roadmap-status-mismatch roadmap.md `status` contradicts its rows (done with open rows; waiting)
|
|
@@ -221,6 +224,40 @@ def open_checks(text: str, include_release: bool = True) -> list[str]:
|
|
|
221
224
|
return found
|
|
222
225
|
|
|
223
226
|
|
|
227
|
+
# A carry marker: the line says which roadmap took the entry over (`→ roadmap-later`, `carried to
|
|
228
|
+
# roadmaps/roadmap-later.md`, `carried over to roadmap.md`).
|
|
229
|
+
CARRY_RE = re.compile(r"(?:→|->|\bcarried(?:\s+over)?\s+to)\s*\**\s*`?(?P<target>(?:[\w.-]+/)*roadmap"
|
|
230
|
+
r"(?:-[A-Za-z0-9][\w-]*?(?:\.md)?|\.md))(?![\w-])`?", re.IGNORECASE)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def carry_target(text: str) -> str | None:
|
|
234
|
+
"""The roadmap a carry marker in `text` names (as written), or None."""
|
|
235
|
+
match = CARRY_RE.search(text or "")
|
|
236
|
+
return match.group("target") if match else None
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def resolve_carry(reader, target: str | None) -> str | None:
|
|
240
|
+
"""The file of the roadmap a carry marker names, when it exists (queued, archived, or the live one)."""
|
|
241
|
+
if not target:
|
|
242
|
+
return None
|
|
243
|
+
name = target.rsplit("/", 1)[-1]
|
|
244
|
+
if name == "roadmap.md":
|
|
245
|
+
text = reader.read(ROADMAP_PATH)
|
|
246
|
+
return ROADMAP_PATH if text is not None else None
|
|
247
|
+
slug = name[len("roadmap-"):]
|
|
248
|
+
slug = slug[:-3] if slug.endswith(".md") else slug
|
|
249
|
+
queued = f"{QUEUED_DIR}/roadmap-{slug}.md"
|
|
250
|
+
if reader.read(queued) is not None:
|
|
251
|
+
return queued
|
|
252
|
+
live = reader.read(ROADMAP_PATH)
|
|
253
|
+
if live is not None and frontmatter(live).get("roadmap") == slug:
|
|
254
|
+
return ROADMAP_PATH
|
|
255
|
+
for path in _files(reader, ARCHIVE_ROADMAPS_DIR, r"^\d{4}-\d{2}-\d{2}-roadmap.*\.md$"):
|
|
256
|
+
if frontmatter(reader.read(path) or "").get("roadmap") == slug or path.endswith(f"roadmap-{slug}.md"):
|
|
257
|
+
return path
|
|
258
|
+
return None
|
|
259
|
+
|
|
260
|
+
|
|
224
261
|
def check_archived_roadmaps(reader) -> list[Finding]:
|
|
225
262
|
findings: list[Finding] = []
|
|
226
263
|
pending = pending_release_roadmap(reader)
|
|
@@ -583,18 +620,19 @@ def run_baseline(reader, root: str, git_root: str | None) -> int:
|
|
|
583
620
|
return 1 if change["refused"] else 0
|
|
584
621
|
|
|
585
622
|
|
|
586
|
-
def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
623
|
+
def run_sweep(reader, root: str, git_root: str | None, as_json: bool, use_forge: bool = True) -> int:
|
|
587
624
|
"""`--sweep`: the worklist of every failure with its evidence; exit 1 while anything is left."""
|
|
588
625
|
import doctor_sweep
|
|
589
626
|
|
|
590
|
-
entries = doctor_sweep.sweep(reader, git_root)
|
|
627
|
+
entries = doctor_sweep.sweep(reader, git_root, doctor_sweep.Forge(git_root, enabled=use_forge))
|
|
591
628
|
owner = [entry for entry in entries if entry["class"] == "owner"]
|
|
592
629
|
superseded = [entry for entry in entries if entry["class"] == "superseded"]
|
|
593
|
-
|
|
630
|
+
forge = [entry for entry in entries if entry["class"] == "forge"]
|
|
631
|
+
with_evidence = len(entries) - len(owner) - len(superseded) - len(forge)
|
|
594
632
|
if as_json:
|
|
595
633
|
print(json.dumps({"root": root, "entries": entries,
|
|
596
634
|
"summary": {"total": len(entries), "with_evidence": with_evidence,
|
|
597
|
-
"superseded": len(superseded), "owner": len(owner)}},
|
|
635
|
+
"superseded": len(superseded), "forge": len(forge), "owner": len(owner)}},
|
|
598
636
|
indent=2, ensure_ascii=False))
|
|
599
637
|
return 1 if entries else 0
|
|
600
638
|
if not entries:
|
|
@@ -607,16 +645,76 @@ def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
|
607
645
|
print(f" evidence {evidence['kind']} {evidence['ref']}: {evidence['note']}")
|
|
608
646
|
if entry["class"] == "superseded":
|
|
609
647
|
print(" superseded: later work made it obsolete; close it yourself, never forward it")
|
|
648
|
+
if entry["class"] == "forge":
|
|
649
|
+
print(" forge: check it with `gh` before anything goes to the owner")
|
|
650
|
+
for tried in entry["tried"]:
|
|
651
|
+
print(f" tried: {tried}")
|
|
610
652
|
if entry["owner"]:
|
|
611
653
|
print(f" owner ({entry['owner_reason']}): only the owner can settle it")
|
|
612
654
|
for tried in entry["tried"]:
|
|
613
655
|
print(f" tried: {tried}")
|
|
614
656
|
print(f" settle: {entry['settle']}")
|
|
615
657
|
print(f"softure-doctor --sweep: {len(entries)} entr{'y' if len(entries) == 1 else 'ies'} to settle, "
|
|
616
|
-
f"{with_evidence} with evidence, {len(superseded)} superseded, {len(
|
|
658
|
+
f"{with_evidence} with evidence, {len(superseded)} superseded, {len(forge)} to check with the forge, "
|
|
659
|
+
f"{len(owner)} for the owner")
|
|
617
660
|
return 1
|
|
618
661
|
|
|
619
662
|
|
|
663
|
+
# The annotation that lists every failure code of a run; readers of the check run (portfolio --source api) find it
|
|
664
|
+
# by this title. GitHub keeps only the first few annotations of a step, so the codes come first, in one annotation.
|
|
665
|
+
CI_CODES_TITLE = "context-doctor failure codes"
|
|
666
|
+
CI_ANNOTATION_LIMIT = 9
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def failure_codes(failures: list[Finding]) -> list[tuple[str, int]]:
|
|
670
|
+
counts: dict[str, int] = {}
|
|
671
|
+
for failure in failures:
|
|
672
|
+
counts[failure.code] = counts.get(failure.code, 0) + 1
|
|
673
|
+
return sorted(counts.items())
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def _escape(value: str, property_value: bool = False) -> str:
|
|
677
|
+
value = value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
|
|
678
|
+
return value.replace(":", "%3A").replace(",", "%2C") if property_value else value
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def report_to_ci(failures: list[Finding], env: dict | None = None, out=None) -> None:
|
|
682
|
+
"""In GitHub Actions: the failure codes as annotations of the check run, and a job summary.
|
|
683
|
+
|
|
684
|
+
The first annotation (title `CI_CODES_TITLE`) lists every code with its count, so a reader of the check run
|
|
685
|
+
through the forge API gets the codes without a checkout; one annotation per failure follows, up to the limit.
|
|
686
|
+
The job summary (`$GITHUB_STEP_SUMMARY`) holds the same table. Outside Actions nothing changes.
|
|
687
|
+
"""
|
|
688
|
+
env = os.environ if env is None else env
|
|
689
|
+
out = out or sys.stdout
|
|
690
|
+
if env.get("GITHUB_ACTIONS") != "true":
|
|
691
|
+
return
|
|
692
|
+
codes = failure_codes(failures)
|
|
693
|
+
if codes:
|
|
694
|
+
listed = ", ".join(f"{code} ({count})" for code, count in codes)
|
|
695
|
+
print(f"::error title={_escape(CI_CODES_TITLE, True)}::{_escape(listed)}", file=out)
|
|
696
|
+
for failure in failures[:CI_ANNOTATION_LIMIT]:
|
|
697
|
+
print(f"::error file={_escape(failure.path, True)},title={_escape(failure.code, True)}::"
|
|
698
|
+
f"{_escape(failure.message)}", file=out)
|
|
699
|
+
target = env.get("GITHUB_STEP_SUMMARY")
|
|
700
|
+
if not target:
|
|
701
|
+
return
|
|
702
|
+
lines = ["### context-doctor", ""]
|
|
703
|
+
if codes:
|
|
704
|
+
lines += [f"{len(failures)} problem(s) in the context/ contract (WORKFLOW.md §12).", "",
|
|
705
|
+
"| Code | Count | First path |", "| --- | --- | --- |"]
|
|
706
|
+
for code, count in codes:
|
|
707
|
+
first = next(failure.path for failure in failures if failure.code == code)
|
|
708
|
+
lines.append(f"| `{code}` | {count} | `{first}` |")
|
|
709
|
+
else:
|
|
710
|
+
lines.append("context/ contract OK")
|
|
711
|
+
try:
|
|
712
|
+
with open(target, "a", encoding="utf-8") as fh:
|
|
713
|
+
fh.write("\n".join(lines) + "\n")
|
|
714
|
+
except OSError:
|
|
715
|
+
pass
|
|
716
|
+
|
|
717
|
+
|
|
620
718
|
def main(argv: list[str] | None = None) -> int:
|
|
621
719
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
622
720
|
if "-h" in args or "--help" in args:
|
|
@@ -626,13 +724,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
626
724
|
fix = _take(args, "--fix")
|
|
627
725
|
write = _take(args, "--write")
|
|
628
726
|
do_sweep = _take(args, "--sweep")
|
|
727
|
+
no_forge = _take(args, "--no-forge")
|
|
629
728
|
do_baseline = _take(args, "--baseline")
|
|
630
729
|
root = None
|
|
631
730
|
if "--root" in args:
|
|
632
731
|
k = args.index("--root")
|
|
633
732
|
root = os.path.abspath(args[k + 1])
|
|
634
733
|
del args[k:k + 2]
|
|
635
|
-
if args or (write and not fix) or sum((fix, do_sweep, do_baseline)) > 1:
|
|
734
|
+
if args or (write and not fix) or sum((fix, do_sweep, do_baseline)) > 1 or (no_forge and not do_sweep):
|
|
636
735
|
print(__doc__, file=sys.stderr)
|
|
637
736
|
return 2
|
|
638
737
|
top = subprocess.run(["git", "-C", root or os.getcwd(), "rev-parse", "--show-toplevel"],
|
|
@@ -650,7 +749,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
650
749
|
if fix:
|
|
651
750
|
return run_fix(reader, root, git_root, write, as_json)
|
|
652
751
|
if do_sweep:
|
|
653
|
-
return run_sweep(reader, root, git_root, as_json)
|
|
752
|
+
return run_sweep(reader, root, git_root, as_json, use_forge=not no_forge)
|
|
654
753
|
if do_baseline:
|
|
655
754
|
return run_baseline(reader, root, git_root)
|
|
656
755
|
findings = run_checks(reader, git_root)
|
|
@@ -661,6 +760,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
661
760
|
return 1 if failures else 0
|
|
662
761
|
for finding in findings:
|
|
663
762
|
print(finding)
|
|
763
|
+
report_to_ci(failures)
|
|
664
764
|
baselined = sum(1 for f in findings if f.severity == "baselined")
|
|
665
765
|
if baselined:
|
|
666
766
|
print(f"softure-doctor: {baselined} failure(s) accepted by {BASELINE_PATH} (last resort; sweep them to zero)")
|
|
@@ -17,6 +17,11 @@ Three shapes are mechanical, and only files under `context/` are edited:
|
|
|
17
17
|
dropped Progress item an unticked item of an archived plan's `## Progress` that is struck through or
|
|
18
18
|
carries a dropped/cancelled/not-applicable note is normalised to
|
|
19
19
|
`- [x] ~~<item>~~ — dropped: <note>` (the doctor already reads it as dropped)
|
|
20
|
+
carried entry an unticked owner check or pre-release step of an archived roadmap, or an open row,
|
|
21
|
+
whose text carries a carry marker (`→ roadmap-<slug>`, `carried to <roadmap>`) naming a
|
|
22
|
+
roadmap that exists (queued, archived or the live one): the check is ticked
|
|
23
|
+
`- [x] <text> — carried to <path>`, the row (and its item block) becomes
|
|
24
|
+
`carried (to <path>)`; a marker whose roadmap does not exist is left alone and named
|
|
20
25
|
|
|
21
26
|
Everything else (an index row whose target is not in the history this checkout holds, a live index)
|
|
22
27
|
is a judgement case: `doctor.py --sweep` lists it with evidence. A shallow clone works: what it cannot
|
|
@@ -221,6 +226,8 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
221
226
|
if lines != text.split("\n"):
|
|
222
227
|
files[rel] = "\n".join(lines)
|
|
223
228
|
|
|
229
|
+
_plan_carried(reader, files, edits, skipped)
|
|
230
|
+
|
|
224
231
|
history = History(root)
|
|
225
232
|
for missing in doctor.missing_index_targets(reader):
|
|
226
233
|
if not missing["path"].startswith(ARCHIVE_PREFIXES):
|
|
@@ -263,6 +270,65 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
263
270
|
return {"edits": edits, "skipped": skipped, "files": files}
|
|
264
271
|
|
|
265
272
|
|
|
273
|
+
def _foundation_relative(path: str) -> str:
|
|
274
|
+
prefix = "context/foundation/"
|
|
275
|
+
return path[len(prefix):] if path.startswith(prefix) else path
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _plan_carried(reader, files: dict[str, str], edits: list[dict], skipped: list[dict]) -> None:
|
|
279
|
+
"""Tick carry-marked checks and close carry-marked rows of archived roadmaps whose target roadmap exists."""
|
|
280
|
+
import doctor # noqa: E402
|
|
281
|
+
|
|
282
|
+
from context_state import CHECKBOX_RE, OWNER_SECTION, RELEASE_SECTION, pending_release_roadmap, roadmap_rows
|
|
283
|
+
|
|
284
|
+
pending = pending_release_roadmap(reader)
|
|
285
|
+
for path in doctor._archived_roadmaps(reader):
|
|
286
|
+
text = files.get(path, reader.read(path) or "")
|
|
287
|
+
lines = text.split("\n")
|
|
288
|
+
wanted = {OWNER_SECTION} | ({RELEASE_SECTION} if path != pending else set())
|
|
289
|
+
open_rows = {row["id"]: row for row in roadmap_rows(text) if row["status"] not in doctor.CLOSED_STATUSES}
|
|
290
|
+
section = None
|
|
291
|
+
for index, line in enumerate(lines):
|
|
292
|
+
if line.startswith("## "):
|
|
293
|
+
section = line[3:].strip()
|
|
294
|
+
continue
|
|
295
|
+
box = CHECKBOX_RE.match(line)
|
|
296
|
+
row = re.match(r"^\|\s*\*\*([A-Z]+-\d+)\*\*\s*\|", line)
|
|
297
|
+
if box and box.group("mark") == " " and section in wanted:
|
|
298
|
+
subject = box.group("text")
|
|
299
|
+
elif row and row.group(1) in open_rows:
|
|
300
|
+
subject = [cell.strip() for cell in line.strip().strip("|").split("|")][-1]
|
|
301
|
+
else:
|
|
302
|
+
continue
|
|
303
|
+
target = doctor.carry_target(subject)
|
|
304
|
+
if not target:
|
|
305
|
+
continue
|
|
306
|
+
found = doctor.resolve_carry(reader, target)
|
|
307
|
+
if not found:
|
|
308
|
+
skipped.append({"code": "archived-roadmap-open-checks" if box else "archived-roadmap-open-items",
|
|
309
|
+
"path": path, "line": index + 1,
|
|
310
|
+
"why": f"carry marker names `{target}`, which is no queued, archived or live roadmap"})
|
|
311
|
+
continue
|
|
312
|
+
where = _foundation_relative(found)
|
|
313
|
+
if box:
|
|
314
|
+
lines[index] = line.replace("- [ ] ", "- [x] ", 1).rstrip() + f" — carried to {where}"
|
|
315
|
+
edits.append({"code": "archived-roadmap-open-checks", "path": path, "line": index + 1,
|
|
316
|
+
"what": f"carried check ticked: carried to {where}"})
|
|
317
|
+
else:
|
|
318
|
+
old_status = subject
|
|
319
|
+
new_status = f"carried (to {where})"
|
|
320
|
+
head = line.rstrip()
|
|
321
|
+
cut = head.rstrip("|").rstrip().rfind(old_status)
|
|
322
|
+
lines[index] = head[:cut] + new_status + head[cut + len(old_status):]
|
|
323
|
+
for block_index, block_line in enumerate(lines):
|
|
324
|
+
if block_line.strip() == f"- **Status:** {old_status}":
|
|
325
|
+
lines[block_index] = block_line.replace(old_status, new_status, 1)
|
|
326
|
+
edits.append({"code": "archived-roadmap-open-items", "path": path, "line": index + 1,
|
|
327
|
+
"what": f"{row.group(1)} {old_status} -> {new_status}"})
|
|
328
|
+
if lines != text.split("\n"):
|
|
329
|
+
files[path] = "\n".join(lines)
|
|
330
|
+
|
|
331
|
+
|
|
266
332
|
def apply_fixes(root: str, files: dict[str, str]) -> None:
|
|
267
333
|
for rel, text in files.items():
|
|
268
334
|
if not rel.startswith("context/"):
|
|
@@ -15,6 +15,9 @@ evidence found in the repository, and how to settle it:
|
|
|
15
15
|
contains it, and later roadmaps that mention the item
|
|
16
16
|
archived-roadmap-open-checks the same for the item the check names, plus the first release after
|
|
17
17
|
the roadmap was closed
|
|
18
|
+
carried entries an open check or row whose text carries a carry marker (`→ roadmap-<slug>`,
|
|
19
|
+
`carried to <roadmap>`) naming a roadmap that exists: that roadmap is the
|
|
20
|
+
evidence, and `--fix` ticks it (a marker whose roadmap is gone stays as it was)
|
|
18
21
|
anything else the file to fix (and `--fix` for the mechanical shapes)
|
|
19
22
|
|
|
20
23
|
Every entry has a `class`:
|
|
@@ -25,6 +28,12 @@ Every entry has a `class`:
|
|
|
25
28
|
item ID or file area appears in a later archived change; for a Progress item, a later
|
|
26
29
|
phase of the same plan is ticked (or a later archived change has the item's area). The
|
|
27
30
|
agent closes it as `obsolete: superseded by <ref>` itself, never forwards it
|
|
31
|
+
forge a post-merge step the history cannot prove (a release after the merge, `close #N`, the
|
|
32
|
+
Dependabot pull requests) while the forge cannot be reached from here: an agent with `gh`
|
|
33
|
+
checks it before anything goes to the owner. With the forge reachable (`gh` and a GitHub
|
|
34
|
+
remote), the sweep asks it itself: a release published on or after the merge date, the
|
|
35
|
+
state of each `#N`, open Dependabot pull requests; when every check holds the entry is
|
|
36
|
+
`evidence` with those pointers (`--no-forge` skips the forge)
|
|
28
37
|
owner only the owner can settle it: a decision about future work, a secret, account or connector,
|
|
29
38
|
or a step outside the repository whose effect the agent cannot see (`owner_reason` says
|
|
30
39
|
which; `unsettled` when nothing at all was found), with `tried`: what the sweep looked for
|
|
@@ -215,6 +224,19 @@ def _item_evidence(reader, git: Git, path: str, item: str | None, change_id: str
|
|
|
215
224
|
return evidence
|
|
216
225
|
|
|
217
226
|
|
|
227
|
+
CARRIED_SETTLE = "mechanical: `doctor --fix --write` ticks it `— carried to <path>` (the row: `carried (to <path>)`)"
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _carried(reader, text: str) -> list[dict]:
|
|
231
|
+
"""Evidence when `text` carries a carry marker whose roadmap exists; [] otherwise (a missing target stays open)."""
|
|
232
|
+
import doctor
|
|
233
|
+
|
|
234
|
+
target = doctor.carry_target(text)
|
|
235
|
+
found = doctor.resolve_carry(reader, target)
|
|
236
|
+
return [_evidence("file", found, f"the carry marker `{target}` names this roadmap, which took the entry over")] \
|
|
237
|
+
if found else []
|
|
238
|
+
|
|
239
|
+
|
|
218
240
|
def owner_kind(text: str) -> str | None:
|
|
219
241
|
"""`decision`, `secret` or `outside` when the line is something only the owner can settle; None otherwise."""
|
|
220
242
|
for kind, pattern in OWNER_KINDS:
|
|
@@ -242,6 +264,9 @@ def _entry(code: str, path: str, line: int | None, text: str, subject: str, evid
|
|
|
242
264
|
evidence = superseded
|
|
243
265
|
else:
|
|
244
266
|
klass, reason, settle = "owner", "unsettled", SETTLE.get(code, "fix the file it names")
|
|
267
|
+
override = extra.pop("settle_override", None)
|
|
268
|
+
if override and klass == "evidence":
|
|
269
|
+
settle = override
|
|
245
270
|
return {"code": code, "path": path, "line": line, "text": text, "subject": subject, "evidence": evidence,
|
|
246
271
|
"class": klass, "owner": klass == "owner", "owner_reason": reason,
|
|
247
272
|
"tried": [] if klass == "evidence" else (tried or []), "settle": settle, **extra}
|
|
@@ -390,7 +415,9 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
390
415
|
if git.shallow:
|
|
391
416
|
tried.append("the history is a shallow clone; `git fetch --deepen <n>` may find more")
|
|
392
417
|
entries.append(_entry("archived-change-progress", path, number, line, subject, evidence,
|
|
393
|
-
superseded=superseded, tried=tried, owner_text=subject
|
|
418
|
+
superseded=superseded, tried=tried, owner_text=subject,
|
|
419
|
+
merged_on=merges[0]["date"] if merges else (change.get("archived_at") or change.get("updated")
|
|
420
|
+
or since)))
|
|
394
421
|
return entries
|
|
395
422
|
|
|
396
423
|
|
|
@@ -432,12 +459,14 @@ def _open_item_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
432
459
|
continue
|
|
433
460
|
row = rows.pop(match.group(1))
|
|
434
461
|
status = [cell.strip() for cell in line.strip().strip("|").split("|")][-1]
|
|
435
|
-
|
|
462
|
+
carried = _carried(reader, status)
|
|
463
|
+
evidence = carried or _item_evidence(reader, git, path, row["id"], row["change_id"])
|
|
436
464
|
superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
|
|
437
465
|
reader, git, path, line, [row["id"], row["change_id"]])
|
|
438
466
|
entries.append(_entry("archived-roadmap-open-items", path, number, line, f"{row['id']} ({row['status']})",
|
|
439
467
|
evidence, superseded=superseded, tried=tried, item=row["id"],
|
|
440
|
-
change_id=row["change_id"], status=status
|
|
468
|
+
change_id=row["change_id"], status=status, settle_override=CARRIED_SETTLE
|
|
469
|
+
if carried else None))
|
|
441
470
|
return entries
|
|
442
471
|
|
|
443
472
|
|
|
@@ -460,14 +489,17 @@ def _open_check_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
460
489
|
ref = ITEM_REF_RE.search(line)
|
|
461
490
|
item = ref.group("id") if ref else None
|
|
462
491
|
change_id = (rows.get(item) or {}).get("change_id") if item else None
|
|
463
|
-
|
|
492
|
+
carried = _carried(reader, line)
|
|
493
|
+
evidence = carried or (_item_evidence(reader, git, path, item, change_id) if item else [])
|
|
464
494
|
if release and section == RELEASE_SECTION:
|
|
465
495
|
evidence.append(_evidence("release", release["tag"], f"released {release['date']}, after the close"))
|
|
466
496
|
superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
|
|
467
497
|
reader, git, path, line, [item, change_id] if item else [])
|
|
468
498
|
entries.append(_entry("archived-roadmap-open-checks", path, number, line, box.group("text").strip(),
|
|
469
|
-
evidence, superseded=superseded, tried=tried,
|
|
470
|
-
item=item, change_id=change_id,
|
|
499
|
+
evidence, superseded=superseded, tried=tried,
|
|
500
|
+
owner_text=None if carried else box.group("text"), item=item, change_id=change_id,
|
|
501
|
+
section=section, settle_override=CARRIED_SETTLE if carried else None,
|
|
502
|
+
merged_on=closed_on))
|
|
471
503
|
return entries
|
|
472
504
|
|
|
473
505
|
|
|
@@ -503,11 +535,15 @@ def _file_entry(failure, reader) -> dict:
|
|
|
503
535
|
return _entry(failure.code, failure.path, None, "", failure.message, evidence)
|
|
504
536
|
|
|
505
537
|
|
|
506
|
-
def sweep(reader, root: str | None) -> list[dict]:
|
|
507
|
-
"""Every failure the doctor reports on `reader`, as worklist entries with evidence.
|
|
538
|
+
def sweep(reader, root: str | None, forge: "Forge | None" = None) -> list[dict]:
|
|
539
|
+
"""Every failure the doctor reports on `reader`, as worklist entries with evidence.
|
|
540
|
+
|
|
541
|
+
`forge` (default: `Forge(root)`, through `gh`) is asked about post-merge steps that the history cannot prove.
|
|
542
|
+
"""
|
|
508
543
|
import doctor
|
|
509
544
|
|
|
510
545
|
git = Git(root)
|
|
546
|
+
forge = forge if forge is not None else Forge(root)
|
|
511
547
|
entries: list[dict] = []
|
|
512
548
|
indexes_done = False
|
|
513
549
|
for failure in doctor.run_checks(reader, root, baseline=False):
|
|
@@ -527,4 +563,134 @@ def sweep(reader, root: str | None) -> list[dict]:
|
|
|
527
563
|
entries += _open_check_entries(reader, git, failure.path)
|
|
528
564
|
else:
|
|
529
565
|
entries.append(_file_entry(failure, reader))
|
|
566
|
+
for entry in entries:
|
|
567
|
+
_forge_step(entry, forge)
|
|
530
568
|
return entries
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
# ---------------------------------------------------------------- forge
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
class Forge:
|
|
575
|
+
"""Read-only questions to the repository's forge through `gh` (`$SOFTURE_GH` names another binary).
|
|
576
|
+
|
|
577
|
+
`{owner}/{repo}` is resolved by `gh` from the checkout's remote. `reachable` is False without `gh`, without a
|
|
578
|
+
GitHub remote, without credentials, or when `enabled` is False (`--no-forge`); every answer is then None.
|
|
579
|
+
"""
|
|
580
|
+
|
|
581
|
+
def __init__(self, root: str | None, enabled: bool = True) -> None:
|
|
582
|
+
self.root = root
|
|
583
|
+
self.enabled = enabled and bool(root)
|
|
584
|
+
self._reachable: bool | None = None
|
|
585
|
+
self._releases: list[dict] | None = None
|
|
586
|
+
|
|
587
|
+
def _api(self, path: str):
|
|
588
|
+
import json
|
|
589
|
+
|
|
590
|
+
try:
|
|
591
|
+
out = subprocess.run([os.environ.get("SOFTURE_GH", "gh"), "api", path], cwd=self.root,
|
|
592
|
+
capture_output=True, text=True, timeout=60)
|
|
593
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
594
|
+
return None
|
|
595
|
+
if out.returncode != 0:
|
|
596
|
+
return None
|
|
597
|
+
try:
|
|
598
|
+
return json.loads(out.stdout)
|
|
599
|
+
except ValueError:
|
|
600
|
+
return None
|
|
601
|
+
|
|
602
|
+
@property
|
|
603
|
+
def reachable(self) -> bool:
|
|
604
|
+
if self._reachable is None:
|
|
605
|
+
self._reachable = self.enabled and isinstance(self._api("repos/{owner}/{repo}"), dict)
|
|
606
|
+
return self._reachable
|
|
607
|
+
|
|
608
|
+
def releases(self) -> list[dict]:
|
|
609
|
+
if self._releases is None:
|
|
610
|
+
data = self._api("repos/{owner}/{repo}/releases?per_page=100") if self.reachable else None
|
|
611
|
+
self._releases = sorted((release for release in data or [] if isinstance(release, dict)
|
|
612
|
+
and not release.get("draft") and release.get("published_at")),
|
|
613
|
+
key=lambda release: release["published_at"])
|
|
614
|
+
return self._releases
|
|
615
|
+
|
|
616
|
+
def release_after(self, day: str | None) -> dict | None:
|
|
617
|
+
"""The first published release on or after `day`."""
|
|
618
|
+
return next((release for release in self.releases() if release["published_at"][:10] >= (day or "")), None)
|
|
619
|
+
|
|
620
|
+
def issue(self, number: str) -> dict | None:
|
|
621
|
+
data = self._api(f"repos/{{owner}}/{{repo}}/issues/{number}") if self.reachable else None
|
|
622
|
+
return data if isinstance(data, dict) else None
|
|
623
|
+
|
|
624
|
+
def open_dependabot_before(self, day: str | None) -> list[dict] | None:
|
|
625
|
+
data = self._api("repos/{owner}/{repo}/pulls?state=open&per_page=100") if self.reachable else None
|
|
626
|
+
if not isinstance(data, list):
|
|
627
|
+
return None
|
|
628
|
+
return [pull for pull in data if "dependabot" in ((pull.get("user") or {}).get("login") or "")
|
|
629
|
+
and (pull.get("created_at") or "")[:10] <= (day or "9999")]
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
RELEASE_STEP_RE = re.compile(r"\b(?:release|released|publish|published)\b", re.IGNORECASE)
|
|
633
|
+
ISSUE_REF_RE = re.compile(r"(?<![\w/&])#(\d+)\b")
|
|
634
|
+
DEPENDABOT_RE = re.compile(r"\bdependabot\b", re.IGNORECASE)
|
|
635
|
+
FORGE_SETTLE = ("check it with the forge before anything goes to the owner (`gh release list`, `gh issue view <N>`, "
|
|
636
|
+
"`gh pr list --author app/dependabot`), then tick it with what the forge shows")
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
def forge_checks(text: str) -> list[tuple[str, str | None]]:
|
|
640
|
+
"""What the forge can prove for a post-merge step: ("release", None), ("issue", "<N>"), ("dependabot", None)."""
|
|
641
|
+
checks: list[tuple[str, str | None]] = []
|
|
642
|
+
if RELEASE_STEP_RE.search(text or ""):
|
|
643
|
+
checks.append(("release", None))
|
|
644
|
+
checks += [("issue", number) for number in dict.fromkeys(ISSUE_REF_RE.findall(text or ""))]
|
|
645
|
+
if DEPENDABOT_RE.search(text or ""):
|
|
646
|
+
checks.append(("dependabot", None))
|
|
647
|
+
return checks
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
def _forge_step(entry: dict, forge: Forge) -> None:
|
|
651
|
+
"""Settle a post-merge step the history cannot prove with the forge: `evidence`, else `forge` when unreachable.
|
|
652
|
+
|
|
653
|
+
Only entries the sweep would hand to the owner as `unsettled` or `outside` are asked about; a decision or a
|
|
654
|
+
secret stays the owner's. Every check the line names must hold for `evidence`.
|
|
655
|
+
"""
|
|
656
|
+
if entry["class"] != "owner" or entry.get("owner_reason") not in ("unsettled", "outside"):
|
|
657
|
+
return
|
|
658
|
+
checks = forge_checks(entry.get("subject") or entry.get("text") or "")
|
|
659
|
+
if not checks:
|
|
660
|
+
return
|
|
661
|
+
day = entry.get("merged_on")
|
|
662
|
+
if not forge.reachable:
|
|
663
|
+
entry.update({"class": "forge", "owner": False, "owner_reason": None, "settle": FORGE_SETTLE,
|
|
664
|
+
"tried": entry.get("tried", []) + ["the forge: not reachable here (no `gh`, no GitHub remote or "
|
|
665
|
+
"no credentials); an agent with `gh` checks it"]})
|
|
666
|
+
return
|
|
667
|
+
found: list[dict] = []
|
|
668
|
+
missing: list[str] = []
|
|
669
|
+
for kind, value in checks:
|
|
670
|
+
if kind == "release":
|
|
671
|
+
release = forge.release_after(day)
|
|
672
|
+
if release:
|
|
673
|
+
found.append(_evidence("release", release.get("tag_name") or "?",
|
|
674
|
+
f"published {release['published_at'][:10]}, on or after the merge ({day})"))
|
|
675
|
+
else:
|
|
676
|
+
missing.append(f"a release published on or after {day}: none")
|
|
677
|
+
elif kind == "issue":
|
|
678
|
+
issue = forge.issue(value)
|
|
679
|
+
pull = (issue or {}).get("pull_request") or {}
|
|
680
|
+
if issue and issue.get("state") == "closed":
|
|
681
|
+
what = "pull request merged" if pull.get("merged_at") else ("pull request closed" if pull else "closed")
|
|
682
|
+
found.append(_evidence("issue", f"#{value}", f"{what} {(issue.get('closed_at') or '')[:10]}".strip()))
|
|
683
|
+
else:
|
|
684
|
+
missing.append(f"#{value}: {issue.get('state') if issue else 'not found'}")
|
|
685
|
+
else:
|
|
686
|
+
pulls = forge.open_dependabot_before(day)
|
|
687
|
+
if pulls == []:
|
|
688
|
+
found.append(_evidence("forge", "dependabot", f"no open Dependabot pull request opened by {day}"))
|
|
689
|
+
else:
|
|
690
|
+
missing.append(f"open Dependabot pull requests opened by {day}: "
|
|
691
|
+
+ (", ".join(f"#{pull.get('number')}" for pull in pulls) if pulls else "unknown"))
|
|
692
|
+
if not missing:
|
|
693
|
+
entry.update({"class": "evidence", "owner": False, "owner_reason": None, "evidence": found, "tried": [],
|
|
694
|
+
"settle": SETTLE.get(entry["code"], "fix the file it names")})
|
|
695
|
+
else:
|
|
696
|
+
entry["tried"] = entry.get("tried", []) + [f"the forge: {note}" for note in missing]
|
|
@@ -204,6 +204,11 @@ Overwriting a roadmap without archiving it is never an option. In `--auto`: revi
|
|
|
204
204
|
free slot", never a noun like "booking system"), `Unlocks` (foundations only), Prerequisites,
|
|
205
205
|
Touches (estimate), Unknowns, Risk (one line: why it sits here and what could go wrong),
|
|
206
206
|
Baseline (how it is measured before and after) and PRD refs (literal IDs, not paraphrases).
|
|
207
|
+
**Size (optional):** only when the owner asks for sizes or `workflow.json` sets
|
|
208
|
+
`roadmap.sizes: true`, add `- **Size:** S | M | L` after `Touches (estimate)` (WORKFLOW §5,
|
|
209
|
+
"Sizes and slices"). Sizes are relative to each other and read from the slicing signals (phases,
|
|
210
|
+
migrations, surfaces, unknowns; [references/slicing.md](references/slicing.md)), never hours,
|
|
211
|
+
days, points or dates. Without that word or key, write no size.
|
|
207
212
|
|
|
208
213
|
11. **Header and `## Order`.**
|
|
209
214
|
- frontmatter: `prd_version` = the PRD `version`;
|
|
@@ -215,6 +220,11 @@ Overwriting a roadmap without archiving it is never an option. In `--auto`: revi
|
|
|
215
220
|
- `## Order` opens with the framing (optimising for, first proof, main risk, depth), then the
|
|
216
221
|
reasoning for the order, `### Starting point` (the confirmed baseline, one line per layer
|
|
217
222
|
with a file), `### Lanes`, and one line pointing to deferred ideas in the backlog.
|
|
223
|
+
- With sizes (step 10): one `**Sizes:**` line under `## Order` that defines S, M and L for this
|
|
224
|
+
roadmap, relative to each other, and a `### Slices` block after `### Lanes`:
|
|
225
|
+
`| Slice | Items | Size |`, slices in order, the first usable slice in bold, each size as counts
|
|
226
|
+
(`2 S, 1 M`). Every sized item sits in exactly one slice. Slices are what the owner funds;
|
|
227
|
+
lanes stay what runs in parallel.
|
|
218
228
|
- Define any strategy term (north star, riskiest assumption, …) in one plain sentence on first
|
|
219
229
|
use, or replace it with plain words. A teammate must be able to read the roadmap cold.
|
|
220
230
|
|
|
@@ -277,8 +287,8 @@ Exactly the structure of WORKFLOW §5. Parser-critical rules:
|
|
|
277
287
|
and `blocked`. `ready` means the item itself has no open decision; whether its prerequisites
|
|
278
288
|
are merged is checked by the orchestrator.
|
|
279
289
|
- Every item block has `- **Change ID:** \`<id>\`` followed directly by `- **Status:** <same as row>`.
|
|
280
|
-
Extra fields (`Unlocks`, `Touches (estimate)`, `Input`) come after those two.
|
|
281
|
-
- The framing, baseline, lanes and deferred ideas live under `## Order`; owner questions under
|
|
290
|
+
Extra fields (`Unlocks`, `Touches (estimate)`, the optional `Size`, `Input`) come after those two.
|
|
291
|
+
- The framing, baseline, lanes, the optional sizes and slices, and deferred ideas live under `## Order`; owner questions under
|
|
282
292
|
`## Owner decisions and checks`. Do not add other top-level sections.
|
|
283
293
|
- `## Done` starts empty; `softure-archive` is its only writer.
|
|
284
294
|
|
|
@@ -312,7 +322,10 @@ Record each choice under `## Decisions (auto)` at the end of the file:
|
|
|
312
322
|
item sits in exactly one lane.
|
|
313
323
|
- [ ] The table and item blocks agree on IDs, change-ids and statuses; change-ids are unique
|
|
314
324
|
kebab-case outcomes, not IDs, dates or activities.
|
|
315
|
-
- [ ] No estimates,
|
|
325
|
+
- [ ] No estimates in time (hours, days, points) and no dates for delivery; no implementation steps.
|
|
326
|
+
- [ ] Sizes only when asked (the owner's word or `roadmap.sizes: true`): then every item has `S`, `M`
|
|
327
|
+
or `L`, the `**Sizes:**` line defines them, and every item sits in exactly one slice whose size
|
|
328
|
+
sum matches its items. Without that, no item has a size.
|
|
316
329
|
- [ ] Strategy terms are defined on first use.
|
|
317
330
|
- [ ] The first item can start today with no open owner decision.
|
|
318
331
|
|
|
@@ -321,7 +334,8 @@ Record each choice under `## Decisions (auto)` at the end of the file:
|
|
|
321
334
|
- Do not plan implementation steps. That is `softure-plan`, per change.
|
|
322
335
|
- Do not change the status of an item that is in progress. That belongs to the orchestrators
|
|
323
336
|
and `softure-archive`.
|
|
324
|
-
- Do not estimate in hours, days, points or
|
|
337
|
+
- Do not estimate in hours, days, points or dates. Order and slice size are the planning tools here;
|
|
338
|
+
a relative size (S / M / L) is written only when the owner asks for it or `roadmap.sizes` is true.
|
|
325
339
|
- Do not chain into the next skill on your own; the handoff is a recommendation.
|
|
326
340
|
- Do not implement roadmap items in the session that wrote the roadmap. In a coordinated run
|
|
327
341
|
(autonomous mode, a hosted project), the roadmap thread commits and merges `roadmap.md` together
|
|
@@ -150,6 +150,36 @@ What makes it good:
|
|
|
150
150
|
- mail is adopted from a module rather than built;
|
|
151
151
|
- no estimates, no dates other than the framing date, no implementation steps.
|
|
152
152
|
|
|
153
|
+
## The same roadmap with sizes (optional)
|
|
154
|
+
|
|
155
|
+
Only when the owner asks for sizes (here: "the first usable slice now, the rest after it") or
|
|
156
|
+
`workflow.json` sets `roadmap.sizes: true`. The table, the statuses and the first two fields of each
|
|
157
|
+
item stay as they are; three things are added.
|
|
158
|
+
|
|
159
|
+
Under `## Order`, after `### Lanes`:
|
|
160
|
+
|
|
161
|
+
```markdown
|
|
162
|
+
**Sizes:** relative to each other, never hours or dates. S: one or two phases, no migration, one
|
|
163
|
+
surface. M: up to four phases or one migration. L: four phases with a migration and open unknowns.
|
|
164
|
+
|
|
165
|
+
### Slices
|
|
166
|
+
| Slice | Items | Size |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| **1. First usable: a visitor books online** | BK-1, BK-2 | 1 M, 1 L |
|
|
169
|
+
| 2. Clients and staff manage bookings | BK-3, BK-4, BK-5 | 2 S, 1 M |
|
|
170
|
+
| 3. Deposits and sharing | BK-6, BK-7 | 1 S, 1 M |
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
In each item block, after `Touches (estimate)`:
|
|
174
|
+
|
|
175
|
+
```markdown
|
|
176
|
+
- **Touches (estimate):** `lib/availability/**`, `drizzle/` (one migration), owner settings form.
|
|
177
|
+
- **Size:** M
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Every item has a size and sits in exactly one slice, each slice's sum counts its items' sizes, and
|
|
181
|
+
nothing is in hours, days or dates.
|
|
182
|
+
|
|
153
183
|
## A bad version of the same roadmap
|
|
154
184
|
|
|
155
185
|
```markdown
|
|
@@ -18,8 +18,17 @@ An item is the right size when:
|
|
|
18
18
|
- it has at most three unknowns; more means research would be a project of its own;
|
|
19
19
|
- it can merge without a feature flag, or the flag is part of the item.
|
|
20
20
|
|
|
21
|
-
Size is expressed by these signals, never in hours, days
|
|
22
|
-
|
|
21
|
+
Size is expressed by these signals, never in hours, days or points. Agent execution is not linear
|
|
22
|
+
in calendar time, and an estimate in the roadmap gets read as a promise.
|
|
23
|
+
|
|
24
|
+
**Relative sizes, on request.** When the owner funds the roadmap in slices and asks for sizes (or
|
|
25
|
+
`workflow.json` sets `roadmap.sizes: true`), give each item `S`, `M` or `L` from the same signals,
|
|
26
|
+
relative to the other items of this roadmap, and define them once under `## Order`. A starting
|
|
27
|
+
point: `S` = one or two phases, no migration, one surface; `M` = up to four phases or one migration;
|
|
28
|
+
`L` = at the limits above (four phases, a migration, three unknowns); anything bigger is split, not
|
|
29
|
+
sized `XL`. Then group the items into `### Slices` (WORKFLOW §5): the first usable slice is the
|
|
30
|
+
smallest set that someone can use on its own, each later slice adds one more usable step, and each
|
|
31
|
+
slice shows its size sum as counts (`2 S, 1 M`).
|
|
23
32
|
|
|
24
33
|
## When an item is too big: split patterns
|
|
25
34
|
|
|
@@ -115,4 +124,4 @@ risk is `capacity`, look harder for parallel lanes: they are the owner's best le
|
|
|
115
124
|
| "Change the button colour on the invoice page" | too small, no outcome | fold into the item whose screen it is |
|
|
116
125
|
| "Set up the API layer" | generic foundation, no `Unlocks` | "(foundation) invoice numbering is gap-free per year; unlocks IN-2, IN-4" |
|
|
117
126
|
| "Add analytics dashboard" (not in PRD) | invented scope | owner question or backlog entry |
|
|
118
|
-
| "Wiki search (2 days, M)" | estimate and size
|
|
127
|
+
| "Wiki search (2 days, M)" | a time estimate, and a size in the title | drop the estimate; a size goes only in the optional `Size` field, on request; split by data subset if it is big |
|