@softure-ai/skills 0.21.0 → 0.22.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 +4 -3
- package/WORKFLOW.md +21 -14
- package/package.json +1 -1
- package/scripts/portfolio.py +1 -1
- package/skills/softure-doctor/SKILL.md +31 -14
- package/skills/softure-doctor/scripts/context_state.py +16 -1
- package/skills/softure-doctor/scripts/doctor.py +139 -34
- package/skills/softure-doctor/scripts/doctor_fix.py +64 -20
- package/skills/softure-doctor/scripts/doctor_sweep.py +180 -36
package/README.md
CHANGED
|
@@ -48,9 +48,10 @@ usually fails on history. Put it right, in this order, one pass per repository:
|
|
|
48
48
|
statuses, with the old value kept as `legacy_status`; archive index links to moved files). Commit.
|
|
49
49
|
2. `npx softure-skills doctor --sweep --json`, worked by an agent with the `softure-doctor` skill
|
|
50
50
|
("Sweep history to zero"): every entry settled with its evidence (commit, release, file), never
|
|
51
|
-
without, in one change, until the doctor exits 0.
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
without, in one change, until the doctor exits 0. Entries classed `superseded` (later roadmaps,
|
|
52
|
+
releases or changes made them obsolete) are closed by the agent as obsolete, never forwarded.
|
|
53
|
+
3. The owner's short list: only real owner items (a decision about future work, a secret, account or
|
|
54
|
+
connector, a step outside the repository), carried to the live roadmap or an `owner-word` issue.
|
|
54
55
|
4. The CI line above, once the doctor is at zero.
|
|
55
56
|
|
|
56
57
|
`npx softure-skills doctor --baseline` exists only as a last resort, for a project that cannot finish
|
package/WORKFLOW.md
CHANGED
|
@@ -780,13 +780,13 @@ its own `change.md` without touching `state.json`, and stays green.
|
|
|
780
780
|
| `roadmap-archived-not-removed` | `roadmap.md` is still there although the same roadmap (slug and version) is in `foundation/archive/` |
|
|
781
781
|
| `roadmap-status-mismatch` | `roadmap.md` says `done` while rows are open, or `waiting` (a queued roadmap's status) |
|
|
782
782
|
| `archived-change-status` | an archived `change.md` whose status is not `archived` |
|
|
783
|
-
| `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate) |
|
|
783
|
+
| `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate; an item struck through or carrying a dropped/cancelled/not-applicable note is dropped, not open) |
|
|
784
784
|
| `archived-roadmap-open-items` | an archived roadmap with rows that are not `done`, `done_code`, dropped or carried |
|
|
785
|
-
| `archived-roadmap-summary` | an archived roadmap whose `## Summary` merge column holds
|
|
785
|
+
| `archived-roadmap-summary` | an archived roadmap whose `## Summary` item table (the table with a merge column; other tables there are ignored) holds a placeholder in the merge column; a SHA, a release tag, `carried`, `dropped` and `— <reason>` pass |
|
|
786
786
|
| `archived-roadmap-open-checks` | an archived roadmap with an unticked `## Owner decisions and checks` entry, or an unticked `## Before the next release` step once its release is recorded or a later roadmap was closed |
|
|
787
787
|
| `queued-roadmap-done` | a queued roadmap whose rows are all done, never archived |
|
|
788
788
|
| `backlog-without-roadmap` | `backlog/roadmap-<slug>/` without `roadmaps/roadmap-<slug>.md` (or the promoted main roadmap) |
|
|
789
|
-
| `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links or
|
|
789
|
+
| `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links a missing file: a markdown link, or a cell that is only a path in a file column (`File`, `Path`, `Document`, `Link`); a path mentioned in a description cell is not a link |
|
|
790
790
|
| `state-missing` | `context/state.json` is gone although git history holds it |
|
|
791
791
|
| `state-stale` | `context/state.json` does not match the markdown |
|
|
792
792
|
| `baseline-stale` | `context/doctor-baseline.json` lists a failure that no longer occurs (remove it), or is unreadable |
|
|
@@ -796,11 +796,13 @@ left after them; `--fix --write` applies them, only under `context/`, and a seco
|
|
|
796
796
|
|
|
797
797
|
- an archived change's `status` becomes `archived`; the old value is kept as `legacy_status` in its front matter;
|
|
798
798
|
- an index row inside `context/archive/` or `context/foundation/archive/` that links a missing file is rewritten to
|
|
799
|
-
the file's current path when git history shows where it moved (rename detection, followed across moves);
|
|
800
|
-
|
|
799
|
+
the file's current path when git history shows where it moved (rename detection, followed across moves); a file
|
|
800
|
+
deleted on purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
801
|
+
- an unticked Progress item of an archived plan that is struck through or carries a dropped/cancelled/not-applicable
|
|
802
|
+
note is normalised to `- [x] ~~<item>~~ — dropped: <note>`.
|
|
801
803
|
|
|
802
|
-
A row whose
|
|
803
|
-
|
|
804
|
+
A row whose move or deletion the history does not show, and a live index, are left alone and named. A shallow clone
|
|
805
|
+
works on the commits it holds and names what lies past its edge. Everything else is a judgement case.
|
|
804
806
|
|
|
805
807
|
**Judgement cases: the sweep.** `npx softure-skills doctor --sweep [--json]` (read-only) lists every remaining failure
|
|
806
808
|
as one worklist entry per thing to settle (an unticked Progress item, a `## Summary` placeholder, an open row, an open
|
|
@@ -808,11 +810,16 @@ owner check), with `path`, `line`, the exact `text`, and evidence pointers found
|
|
|
808
810
|
Progress items the commits that touched the phase's files after the plan's date (and the SHA the phase's ticked items
|
|
809
811
|
cite); for `## Summary` placeholders the merge commit of the item's change (first-parent log, branch name, change ID in
|
|
810
812
|
the message); for open rows and owner checks the item's archived change, merge commit, the release that contains it,
|
|
811
|
-
and later roadmaps that mention the item.
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
813
|
+
and later roadmaps that mention the item. Each entry has a class. `evidence`: the repository settles it. `superseded`:
|
|
814
|
+
no direct evidence, but later work made it obsolete (for an owner check or open row of an archived roadmap, a later
|
|
815
|
+
roadmap was closed and a release shipped after it, or the same item ID or file area appears in a later archived change;
|
|
816
|
+
for a Progress item, a later phase of the same plan is ticked); its evidence names that roadmap, release or change, and
|
|
817
|
+
the agent closes it as `obsolete: superseded by <ref>` itself, never forwards it. `owner`: only for what is still
|
|
818
|
+
meaningful today, a decision about future work, a secret, account or connector, or a step outside the repository whose
|
|
819
|
+
effect the agent cannot see; the entry says which (`owner_reason`) and what the sweep looked for (`tried`). The
|
|
820
|
+
`softure-doctor` skill ("Sweep history to zero") tells an agent how to work it: every entry is settled with its evidence
|
|
821
|
+
written into the line, never without; the owner entries are carried to the live roadmap's `## Owner decisions and
|
|
822
|
+
checks` or an `owner-word` issue and collected in one short list for the owner; nothing else is left open.
|
|
816
823
|
|
|
817
824
|
**Baseline: a last resort.** For a project that cannot finish the sweep at once, `doctor --baseline` writes the failures
|
|
818
825
|
that remain to `context/doctor-baseline.json` (`{ "note", "created", "entries": [ { "code", "path", "message" } ] }`).
|
|
@@ -861,8 +868,8 @@ long ago. The history is put right, not hidden. One pass per repository, in this
|
|
|
861
868
|
`softure-doctor` skill describes ("Sweep history to zero"): every tick, SHA, status and obsolete mark carries its
|
|
862
869
|
evidence (commit, release, file), never without. Regenerate the state, re-run the doctor until it exits 0, and land it
|
|
863
870
|
as one change: `docs(context): settle history to zero`.
|
|
864
|
-
3. **The owner's list.** What only the owner can settle (a decision
|
|
865
|
-
nothing shows done) was carried to the live roadmap's `## Owner decisions and checks` or an `owner-word` issue; the
|
|
871
|
+
3. **The owner's list.** What only the owner can settle (a decision about future work, a secret, account or connector,
|
|
872
|
+
a step outside the repository that nothing shows done) was carried to the live roadmap's `## Owner decisions and checks` or an `owner-word` issue; the
|
|
866
873
|
agent's report lists it once, short: `ID | what the owner decides or does | where it lives now`. Nothing else
|
|
867
874
|
waits, so `portfolio --owner` shows only these and the live roadmaps' entries.
|
|
868
875
|
4. **The CI line at zero.** Once `npx softure-skills doctor` exits 0 on the main branch, add it to the CI check
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/skills",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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/scripts/portfolio.py
CHANGED
|
@@ -54,37 +54,47 @@ Each problem is one line `FAIL <code> <path>: <what>`. Fix the file it names, ne
|
|
|
54
54
|
| `roadmap-archived-not-removed` | the close moved a copy and left `roadmap.md`: remove it (promote the next one only on the owner's word) |
|
|
55
55
|
| `roadmap-status-mismatch` | set `status` to match the rows (`done` only when every row is closed; `waiting` belongs to queued roadmaps) |
|
|
56
56
|
| `archived-change-status` | stamp the archived `change.md` `status: archived` (and `archived_at`) |
|
|
57
|
-
| `archived-change-progress` | the change was archived with open Automated items: tick them with their SHA when the work is on the main branch, or mark them `~~dropped~~ — dropped: <reason
|
|
57
|
+
| `archived-change-progress` | the change was archived with open Automated items: tick them with their SHA when the work is on the main branch, or mark them `~~dropped~~ — dropped: <reason>`. An item struck through or carrying a dropped/cancelled/not-applicable note is already dropped and never counts (`--fix` normalises it) |
|
|
58
58
|
| `archived-roadmap-open-items` | rows of an archived roadmap end `done`, `done_code`, dropped or carried (with where they went) |
|
|
59
59
|
| `archived-roadmap-open-checks` | an archived roadmap still holds unticked owner entries: tick each with its evidence (`— done: <sha / release / path>`), as obsolete (`— obsolete: <reason>`), or carry it to a live roadmap or an `owner-word` issue and tick it with where it went |
|
|
60
|
-
| `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into
|
|
60
|
+
| `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into the row's merge cell. Only the item table (the one with a merge column) is read; a SHA, a release tag (where the roadmap records a release instead of a merge), `carried`, `dropped` and `— <reason>` pass |
|
|
61
61
|
| `queued-roadmap-done` | archive the finished queued roadmap to `foundation/archive/` |
|
|
62
62
|
| `backlog-without-roadmap` | move live entries to a queued roadmap, then remove the folder |
|
|
63
|
-
| `index-missing-file` | fix or drop the
|
|
63
|
+
| `index-missing-file` | a real link (a markdown link, or a cell that is only a path in a file column) points at a missing file: fix or drop the row; a path mentioned in a description cell never fails |
|
|
64
64
|
| `state-missing` / `state-stale` | `context_state.py write`, commit `context/state.json` |
|
|
65
65
|
| `baseline-stale` | a baselined failure is fixed: `doctor.py --baseline` rewrites the file without it (commit it) |
|
|
66
66
|
|
|
67
67
|
## Mechanical repairs: `--fix`
|
|
68
68
|
|
|
69
69
|
`doctor.py --fix` prints every edit it would make and the failures left after them; `--fix --write`
|
|
70
|
-
applies them. It writes only under `context/`, and a second run changes nothing.
|
|
70
|
+
applies them. It writes only under `context/`, and a second run changes nothing. Three shapes are
|
|
71
71
|
mechanical:
|
|
72
72
|
|
|
73
73
|
- `archived-change-status`: the archived `change.md` gets `status: archived`, and the old value is kept
|
|
74
74
|
as `legacy_status` in its front matter (`implemented`, `done`, `impl_reviewed`, … stay readable);
|
|
75
75
|
- `index-missing-file` in an index inside an archive folder: the link is rewritten to the file's current
|
|
76
|
-
path when git history shows where it moved (renames followed across several moves); a file
|
|
77
|
-
|
|
76
|
+
path when git history shows where it moved (renames followed across several moves); a file deleted on
|
|
77
|
+
purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
78
|
+
- a dropped Progress item of an archived plan (unticked, but struck through or carrying an explicit
|
|
79
|
+
dropped/cancelled/not-applicable note) is normalised to `- [x] ~~<item>~~ — dropped: <note>`.
|
|
78
80
|
|
|
79
|
-
It skips, and names, every row it cannot settle from history (a live index, a target
|
|
80
|
-
|
|
81
|
+
It skips, and names, every row it cannot settle from history (a live index, a target whose move or
|
|
82
|
+
deletion the history does not show). A shallow clone works on the commits it holds and names what lies
|
|
83
|
+
past its edge (`git fetch --deepen <n>` reaches further). Those and every other failure are judgement cases.
|
|
81
84
|
|
|
82
85
|
## Sweep history to zero
|
|
83
86
|
|
|
84
87
|
`doctor.py --sweep --json` lists every failure left after `--fix` as one entry per thing to settle:
|
|
85
88
|
`code`, `path`, `line` and the exact `text` of the line, `evidence` (pointers of kind `commit`,
|
|
86
|
-
`release` or `file`, each with a note), `settle` (what to do), and
|
|
87
|
-
|
|
89
|
+
`release` or `file`, each with a note), `settle` (what to do), and a `class`:
|
|
90
|
+
|
|
91
|
+
| Class | Means | Who settles it |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `evidence` | the repository holds proof (below) | the agent, with that proof |
|
|
94
|
+
| `superseded` | no direct proof, but later work made it obsolete: for an owner check or open row of an archived roadmap, a later roadmap was closed and a release shipped after it, or the same item ID or file area appears in a later archived change; for a Progress item, a later phase of the same plan is ticked. Its `evidence` names the roadmap, release or change | the agent, as obsolete; never forwarded |
|
|
95
|
+
| `owner` (`owner: true`) | still meaningful today and only the owner can settle it: a decision about future work (`owner_reason: decision`), a secret, account or connector (`secret`), a step outside the repository whose effect the agent cannot see (`outside`), or nothing found at all (`unsettled`). `tried` says what the sweep looked for | the owner |
|
|
96
|
+
|
|
97
|
+
The evidence it looks for:
|
|
88
98
|
|
|
89
99
|
| Code | Evidence |
|
|
90
100
|
|---|---|
|
|
@@ -101,13 +111,20 @@ Work the list in one change per repository (`docs(context): settle history to ze
|
|
|
101
111
|
it proves. **Settle with evidence, never without:** write the proof into the line itself.
|
|
102
112
|
- Progress item: `- [x] <text> — <sha>` when that commit did it; `- [x] ~~<text>~~ — dropped: <reason>`
|
|
103
113
|
when the evidence shows it was never done and is no longer wanted.
|
|
104
|
-
- Summary placeholder: the merge SHA in the `Merge` cell
|
|
114
|
+
- Summary placeholder: the merge SHA in the `Merge` cell (a release tag, `carried`, `dropped` or
|
|
115
|
+
`— <reason>` where there is no merge).
|
|
105
116
|
- Open row: `done` (it shipped), `carried (to <path>)` (a later roadmap took it), `dropped (<reason>)`.
|
|
106
117
|
- Open check: `- [x] <text> — done: <sha | release | path>`, `- [x] <text> — obsolete: <reason, with
|
|
107
118
|
the evidence that made it obsolete>`, or carried (below).
|
|
119
|
+
- `superseded` entry: close it yourself as obsolete, with its evidence: `- [x] <text> — obsolete:
|
|
120
|
+
superseded by <release / roadmap / change>` (a row: `dropped (obsolete: superseded by <ref>)`).
|
|
121
|
+
Never forward it to the owner: a screenshot review of a page rebuilt since, or "after the release,
|
|
122
|
+
re-run X" for a release long gone, has no answer the owner could give.
|
|
108
123
|
3. **Only true owner items stay open, in one place.** An entry is the owner's when the evidence does
|
|
109
|
-
not settle it and only the owner can: a
|
|
110
|
-
|
|
124
|
+
not settle it, nothing later superseded it, and only the owner can: a decision about future work
|
|
125
|
+
that is still open, a secret, account or connector, or a step outside the repository (a production
|
|
126
|
+
setting, a real device) whose effect the agent cannot see. Before forwarding an `unsettled` entry,
|
|
127
|
+
try what its `tried` lines did not, and say in the report what you tried. Carry it to the
|
|
111
128
|
live roadmap's `## Owner decisions and checks` (or an `owner-word` issue, WORKFLOW §8.6) and tick
|
|
112
129
|
the archived line `— carried to <path | #N>`. Never carry a check whose work the evidence shows done,
|
|
113
130
|
and never tick a decision on the owner's behalf.
|
|
@@ -137,7 +154,7 @@ script run creates it.
|
|
|
137
154
|
- `context/state.json` is written by scripts only. Never edit it by hand; regenerate it.
|
|
138
155
|
- Never tick, fill or close anything in the sweep without the evidence written into the line.
|
|
139
156
|
- The doctor never edits anything, except `--fix --write`, which is run on purpose and edits only the
|
|
140
|
-
|
|
157
|
+
mechanical shapes above. A skill that runs it fixes only the files it owns in that run.
|
|
141
158
|
- `open_changes`, `updated_at` and owner-queue entries from open changes are refreshed on every write
|
|
142
159
|
and never make the file stale, so a change branch that edits its own `change.md` keeps a green doctor.
|
|
143
160
|
- `owner_queue` reads only what is live (WORKFLOW §12.1): an unticked entry left in an archived roadmap
|
|
@@ -581,6 +581,21 @@ def repo_root(start: str) -> str:
|
|
|
581
581
|
return out.stdout.strip() if out.returncode == 0 else os.path.abspath(start)
|
|
582
582
|
|
|
583
583
|
|
|
584
|
+
def quiet_broken_pipe(run) -> int:
|
|
585
|
+
"""Run a CLI entry point; when stdout is closed early (`doctor --sweep | head`), stop quietly with 141.
|
|
586
|
+
|
|
587
|
+
141 is what a shell reports for a process ended by SIGPIPE; no traceback, no "Exception ignored".
|
|
588
|
+
"""
|
|
589
|
+
try:
|
|
590
|
+
code = run()
|
|
591
|
+
sys.stdout.flush()
|
|
592
|
+
return code
|
|
593
|
+
except BrokenPipeError:
|
|
594
|
+
devnull = os.open(os.devnull, os.O_WRONLY)
|
|
595
|
+
os.dup2(devnull, sys.stdout.fileno()) # the interpreter's final flush must not fail again
|
|
596
|
+
return 141
|
|
597
|
+
|
|
598
|
+
|
|
584
599
|
def main(argv: list[str] | None = None) -> int:
|
|
585
600
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
586
601
|
root = None
|
|
@@ -619,4 +634,4 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
619
634
|
|
|
620
635
|
|
|
621
636
|
if __name__ == "__main__":
|
|
622
|
-
sys.exit(main
|
|
637
|
+
sys.exit(quiet_broken_pipe(main))
|
|
@@ -14,22 +14,27 @@ what they own. Each problem is one line `FAIL <code> <path>: <what>`; the codes:
|
|
|
14
14
|
roadmap-archived-not-removed roadmap.md is still there although the same roadmap is in foundation/archive/
|
|
15
15
|
roadmap-status-mismatch roadmap.md `status` contradicts its rows (done with open rows; waiting)
|
|
16
16
|
archived-change-status an archived change.md whose status is not `archived`
|
|
17
|
-
archived-change-progress an archived plan.md with unticked Automated items in `## Progress`
|
|
17
|
+
archived-change-progress an archived plan.md with unticked Automated items in `## Progress` (an item
|
|
18
|
+
struck through or noted dropped/cancelled/not applicable is dropped, not open)
|
|
18
19
|
archived-roadmap-open-items an archived roadmap with rows that are not done, done_code, dropped or carried
|
|
19
|
-
archived-roadmap-summary an archived roadmap whose `## Summary`
|
|
20
|
+
archived-roadmap-summary an archived roadmap whose `## Summary` item table holds a placeholder in its merge
|
|
21
|
+
column (a SHA, a release tag, carried, dropped or a dash with a reason pass)
|
|
20
22
|
archived-roadmap-open-checks an archived roadmap with unticked owner decisions or checks (or pre-release
|
|
21
23
|
steps, once its release is recorded or a later roadmap was closed)
|
|
22
24
|
queued-roadmap-done a queued roadmap in foundation/roadmaps/ whose rows are all done
|
|
23
25
|
backlog-without-roadmap a backlog/roadmap-<slug>/ folder without its queued (or promoted) roadmap
|
|
24
26
|
index-missing-file an index row (README.md / INDEX.md table under context/) links a missing file
|
|
27
|
+
(a markdown link, or a cell that is only a path in a file column; a mention
|
|
28
|
+
in a description cell is not a link)
|
|
25
29
|
state-missing context/state.json is missing although the project has written it before
|
|
26
30
|
state-stale context/state.json does not match the markdown
|
|
27
31
|
baseline-stale context/doctor-baseline.json lists a failure that is fixed (remove it), or is unreadable
|
|
28
32
|
|
|
29
33
|
`--fix` repairs what is mechanical (an archived change's status; an archived index row whose target
|
|
30
|
-
moved, found through git history) and prints every edit; see doctor_fix.py. It is a dry run unless
|
|
34
|
+
moved or was deleted on purpose, found through git history; a dropped Progress item, normalised) and prints every edit; see doctor_fix.py. It is a dry run unless
|
|
31
35
|
`--write` is given, and it writes only under `context/`. `--sweep` lists every remaining failure with
|
|
32
|
-
the evidence an agent needs to settle it from the repository alone
|
|
36
|
+
the evidence an agent needs to settle it from the repository alone, classed `evidence`, `superseded` (later
|
|
37
|
+
work made it obsolete; the agent closes it) or `owner`; see doctor_sweep.py.
|
|
33
38
|
|
|
34
39
|
`--baseline` is a last resort for a project that cannot finish the sweep at once: it writes the failures
|
|
35
40
|
that remain to `context/doctor-baseline.json`, and the check then fails only on new failures and on
|
|
@@ -41,6 +46,8 @@ gets a note, not a failure: the first run of `wt-roadmap.py`, `softure-archive`
|
|
|
41
46
|
creates it. Fix a stale or missing file with `npx softure-skills state` (or
|
|
42
47
|
`python3 .claude/skills/softure-doctor/scripts/context_state.py write`) and commit it.
|
|
43
48
|
|
|
49
|
+
Piped into a reader that stops early (`doctor --sweep | head`), it ends quietly with exit 141, no traceback.
|
|
50
|
+
|
|
44
51
|
Importable: `from doctor import run_checks` (takes any reader of context_state).
|
|
45
52
|
"""
|
|
46
53
|
from __future__ import annotations
|
|
@@ -55,7 +62,8 @@ sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/s
|
|
|
55
62
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
56
63
|
from context_state import ( # noqa: E402
|
|
57
64
|
ARCHIVE_ROADMAPS_DIR, CHANGES_DIR, OWNER_SECTION, QUEUED_DIR, RELEASE_SECTION, ROADMAP_PATH, STATE_PATH,
|
|
58
|
-
FsReader, frontmatter, open_checkboxes, pending_release_roadmap, roadmap_rows, sections,
|
|
65
|
+
FsReader, frontmatter, open_checkboxes, pending_release_roadmap, quiet_broken_pipe, roadmap_rows, sections,
|
|
66
|
+
staleness,
|
|
59
67
|
)
|
|
60
68
|
|
|
61
69
|
ARCHIVE_DIR = "context/archive"
|
|
@@ -65,9 +73,13 @@ BACKLOG_DIR = "context/backlog"
|
|
|
65
73
|
CLOSED_STATUSES = ("done", "done_code", "dropped", "carried")
|
|
66
74
|
SHA_RE = re.compile(r"\b[0-9a-f]{7,40}\b")
|
|
67
75
|
EMPTY_MERGE = {"—", "-", "–", "n/a", "none", "no merge", "not merged"}
|
|
76
|
+
RELEASE_TAG_RE = re.compile(r"(?<![\w.])v?\d+\.\d+\.\d+(?:-[\w.]+)?(?![\w.])")
|
|
77
|
+
MERGE_COLUMN_RE = re.compile(r"\bmerge")
|
|
68
78
|
LINK_RE = re.compile(r"\[[^\]]*\]\(([^)\s]+)(?:\s+\"[^\"]*\")?\)")
|
|
69
79
|
INDEX_NAMES = ("README.md", "INDEX.md")
|
|
70
|
-
|
|
80
|
+
_PATH = r"(?:\.{1,2}/)?(?:[\w.-]+/)*[\w.-]+\.md|(?:\.{1,2}/)?(?:[\w.-]+/)+"
|
|
81
|
+
WHOLE_PATH_RE = re.compile(r"(?P<tick>`?)(?P<path>" + _PATH + r")(?P=tick)") # a cell that is only a path
|
|
82
|
+
FILE_COLUMN_RE = re.compile(r"\b(?:files?|paths?|documents?|docs?|links?|artifacts?)\b")
|
|
71
83
|
|
|
72
84
|
|
|
73
85
|
class Finding:
|
|
@@ -144,10 +156,45 @@ def check_archived_changes(reader) -> list[Finding]:
|
|
|
144
156
|
return findings
|
|
145
157
|
|
|
146
158
|
|
|
159
|
+
DROP_WORDS = r"(?:dropped|cancell?ed|not applicable|n/a|obsolete|won't do|wontfix|skipped|replaced by)"
|
|
160
|
+
DROP_NOTE_RE = re.compile(r"\s+(?:—|–|--?)\s+(?P<note>" + DROP_WORDS + r"\b.*)$", re.IGNORECASE)
|
|
161
|
+
DROP_PAREN_RE = re.compile(r"\s*\((?P<note>" + DROP_WORDS + r"\b[^)]*)\)\s*$", re.IGNORECASE)
|
|
162
|
+
STRUCK_RE = re.compile(r"^~~(?P<body>.+?)~~(?P<rest>.*)$")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def dropped_item(text: str) -> tuple[str, str] | None:
|
|
166
|
+
"""(item, note) when a checkbox text says the item was dropped; None otherwise.
|
|
167
|
+
|
|
168
|
+
Dropped by its own text: struck through (`~~1.1 ...~~`, with or without a note after it), or carrying an
|
|
169
|
+
explicit note after a dash or in parentheses (`— cancelled, replaced by 1.12`, `(not applicable)`).
|
|
170
|
+
"""
|
|
171
|
+
text = text.strip()
|
|
172
|
+
struck = STRUCK_RE.match(text)
|
|
173
|
+
if struck:
|
|
174
|
+
rest = re.sub(r"^\s*(?:—|–|--?|:)?\s*", "", struck.group("rest")).strip()
|
|
175
|
+
return struck.group("body").strip(), rest or "struck through, no reason recorded"
|
|
176
|
+
for pattern in (DROP_NOTE_RE, DROP_PAREN_RE):
|
|
177
|
+
found = pattern.search(text)
|
|
178
|
+
if found and found.start() > 0:
|
|
179
|
+
return text[:found.start()].strip(), found.group("note").strip()
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def dropped_line(text: str) -> str | None:
|
|
184
|
+
"""The normalised `~~<item>~~ — dropped: <note>` for a dropped checkbox text; None when it is not dropped."""
|
|
185
|
+
found = dropped_item(text)
|
|
186
|
+
if not found:
|
|
187
|
+
return None
|
|
188
|
+
item, note = found
|
|
189
|
+
note = re.sub(r"^dropped\s*:?\s*", "", note, flags=re.IGNORECASE) or "no reason recorded"
|
|
190
|
+
return f"~~{item}~~ — dropped: {note}"
|
|
191
|
+
|
|
192
|
+
|
|
147
193
|
def unticked_automated(plan: str) -> list[str]:
|
|
148
|
-
"""Open `- [ ]` items of `## Progress` that are not under a `#### Manual` heading.
|
|
194
|
+
"""Open `- [ ]` items of `## Progress` that are not under a `#### Manual` heading and not dropped.
|
|
149
195
|
|
|
150
|
-
Open Manual items are legitimate in an archived plan (manual mode carries them to the owner).
|
|
196
|
+
Open Manual items are legitimate in an archived plan (manual mode carries them to the owner). An item
|
|
197
|
+
struck through or carrying a dropped/cancelled/not-applicable note is dropped by its own text.
|
|
151
198
|
"""
|
|
152
199
|
progress = sections(plan).get("Progress", [])
|
|
153
200
|
open_items = []
|
|
@@ -160,7 +207,7 @@ def unticked_automated(plan: str) -> list[str]:
|
|
|
160
207
|
manual = False
|
|
161
208
|
continue
|
|
162
209
|
match = re.match(r"^\s*- \[ \] (.+)$", line)
|
|
163
|
-
if match and not manual:
|
|
210
|
+
if match and not manual and not dropped_item(match.group(1)):
|
|
164
211
|
open_items.append(match.group(1).strip())
|
|
165
212
|
return open_items
|
|
166
213
|
|
|
@@ -193,31 +240,56 @@ def check_archived_roadmaps(reader) -> list[Finding]:
|
|
|
193
240
|
bad = summary_placeholders(text)
|
|
194
241
|
if bad:
|
|
195
242
|
findings.append(Finding("archived-roadmap-summary", path,
|
|
196
|
-
"## Summary merge column holds placeholders instead of merge SHAs: "
|
|
243
|
+
"## Summary merge column holds placeholders instead of merge SHAs or outcomes: "
|
|
197
244
|
+ "; ".join(bad[:4])))
|
|
198
245
|
return findings
|
|
199
246
|
|
|
200
247
|
|
|
201
|
-
def
|
|
202
|
-
"""Rows of the
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
248
|
+
def summary_rows(text: str) -> list[dict]:
|
|
249
|
+
"""Rows of the item table under `## Summary`: the table whose header has a merge column.
|
|
250
|
+
|
|
251
|
+
Other tables under `## Summary` (finding numbers, test counts) are not the item table and are skipped.
|
|
252
|
+
Each row: `line` (1-based in `text`), `text`, `item` (first cell), `cell` (the merge cell) and `ok`.
|
|
253
|
+
"""
|
|
254
|
+
rows: list[dict] = []
|
|
255
|
+
in_summary = False
|
|
256
|
+
header: list[str] | None = None
|
|
257
|
+
merge = None
|
|
258
|
+
for number, line in enumerate((text or "").split("\n"), start=1):
|
|
259
|
+
if line.startswith("## "):
|
|
260
|
+
in_summary = line[3:].strip() == "Summary"
|
|
261
|
+
header = None
|
|
262
|
+
continue
|
|
263
|
+
if not in_summary:
|
|
264
|
+
continue
|
|
207
265
|
if not line.strip().startswith("|"):
|
|
266
|
+
header = None
|
|
208
267
|
continue
|
|
209
|
-
|
|
268
|
+
cells = _table_cells(line)
|
|
210
269
|
if header is None:
|
|
211
|
-
header = [cell.lower() for cell in
|
|
212
|
-
|
|
213
|
-
if all(re.fullmatch(r":?-{3,}:?", cell) for cell in parts if cell):
|
|
270
|
+
header = [cell.strip("*` ").lower() for cell in cells]
|
|
271
|
+
merge = next((index for index, name in enumerate(header) if MERGE_COLUMN_RE.search(name)), None)
|
|
214
272
|
continue
|
|
215
|
-
|
|
216
|
-
cell = parts[index] if index < len(parts) else ""
|
|
217
|
-
if SHA_RE.search(cell) or cell.strip("`* ").lower() in EMPTY_MERGE:
|
|
273
|
+
if merge is None or _is_separator(cells):
|
|
218
274
|
continue
|
|
219
|
-
|
|
220
|
-
|
|
275
|
+
cell = cells[merge] if merge < len(cells) else ""
|
|
276
|
+
rows.append({"line": number, "text": line, "item": cells[0], "cell": cell, "ok": merge_cell_ok(cell)})
|
|
277
|
+
return rows
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def merge_cell_ok(cell: str) -> bool:
|
|
281
|
+
"""A merge cell records an outcome: a SHA, a release tag, carried/dropped, or a dash (with or without a reason)."""
|
|
282
|
+
value = cell.strip("`* ").lower()
|
|
283
|
+
if SHA_RE.search(cell) or RELEASE_TAG_RE.search(cell):
|
|
284
|
+
return True
|
|
285
|
+
if value in EMPTY_MERGE or value[:1] in ("—", "–", "-"):
|
|
286
|
+
return True
|
|
287
|
+
return bool(re.match(r"(?:carried|dropped|obsolete|superseded|cancell?ed|not merged|no merge)\b", value))
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def summary_placeholders(text: str) -> list[str]:
|
|
291
|
+
"""Item-table rows of `## Summary` whose merge cell is a placeholder, not an outcome."""
|
|
292
|
+
return [f"{row['item']}: \"{row['cell']}\"" for row in summary_rows(text) if not row["ok"]]
|
|
221
293
|
|
|
222
294
|
|
|
223
295
|
def check_queued_and_backlog(reader) -> list[Finding]:
|
|
@@ -245,8 +317,20 @@ def check_queued_and_backlog(reader) -> list[Finding]:
|
|
|
245
317
|
return findings
|
|
246
318
|
|
|
247
319
|
|
|
320
|
+
def _table_cells(line: str) -> list[str]:
|
|
321
|
+
return [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _is_separator(cells: list[str]) -> bool:
|
|
325
|
+
return all(re.fullmatch(r":?-{3,}:?", cell) for cell in cells if cell) and any(cells)
|
|
326
|
+
|
|
327
|
+
|
|
248
328
|
def missing_index_targets(reader) -> list[dict]:
|
|
249
|
-
"""Every link
|
|
329
|
+
"""Every real link in an index row (README.md / INDEX.md table under context/) whose target does not exist.
|
|
330
|
+
|
|
331
|
+
A real link is a markdown link anywhere in the row, or a cell whose whole content is a path (in backticks
|
|
332
|
+
or bare) in a column that indexes files (`File`, `Path`, `Document`, `Link`, ...). A path merely mentioned
|
|
333
|
+
in a description cell (see `change.md`) is not a link and never fails.
|
|
250
334
|
|
|
251
335
|
Each entry: `path` (the index), `line` (1-based), `text` (the line), `kind` (`link` or `code`), `target`
|
|
252
336
|
(as written), `base` (the index folder) and `candidates` (the repository paths the target may mean).
|
|
@@ -256,8 +340,16 @@ def missing_index_targets(reader) -> list[dict]:
|
|
|
256
340
|
if os.path.basename(path) not in INDEX_NAMES:
|
|
257
341
|
continue
|
|
258
342
|
base = os.path.dirname(path)
|
|
343
|
+
header: list[str] | None = None
|
|
259
344
|
for number, line in enumerate((reader.read(path) or "").splitlines(), start=1):
|
|
260
345
|
if not line.strip().startswith("|"):
|
|
346
|
+
header = None
|
|
347
|
+
continue
|
|
348
|
+
cells = _table_cells(line)
|
|
349
|
+
if header is None:
|
|
350
|
+
header = [cell.strip("*` ").lower() for cell in cells]
|
|
351
|
+
continue
|
|
352
|
+
if _is_separator(cells):
|
|
261
353
|
continue
|
|
262
354
|
for target in LINK_RE.findall(line):
|
|
263
355
|
if re.match(r"^[a-z][a-z0-9+.-]*:", target, re.IGNORECASE) or target.startswith("#"):
|
|
@@ -271,8 +363,14 @@ def missing_index_targets(reader) -> list[dict]:
|
|
|
271
363
|
if not reader.exists(resolved.rstrip("/")):
|
|
272
364
|
out.append({"path": path, "line": number, "text": line, "kind": "link", "target": target,
|
|
273
365
|
"base": base, "candidates": [resolved.rstrip("/")]})
|
|
274
|
-
for
|
|
275
|
-
|
|
366
|
+
for column, cell in enumerate(cells):
|
|
367
|
+
if column >= len(header) or not FILE_COLUMN_RE.search(header[column]):
|
|
368
|
+
continue
|
|
369
|
+
whole = WHOLE_PATH_RE.fullmatch(cell)
|
|
370
|
+
if not whole:
|
|
371
|
+
continue
|
|
372
|
+
target = whole.group("path")
|
|
373
|
+
# A path cell: relative to the index, to context/ or to the repository root.
|
|
276
374
|
candidates = [os.path.normpath(os.path.join(prefix, target)).replace(os.sep, "/").rstrip("/")
|
|
277
375
|
for prefix in (base, "context", ".")]
|
|
278
376
|
inside = [c for c in candidates if c.startswith("context/")]
|
|
@@ -490,11 +588,14 @@ def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
|
490
588
|
import doctor_sweep
|
|
491
589
|
|
|
492
590
|
entries = doctor_sweep.sweep(reader, git_root)
|
|
493
|
-
owner = [entry for entry in entries if entry["owner"]
|
|
591
|
+
owner = [entry for entry in entries if entry["class"] == "owner"]
|
|
592
|
+
superseded = [entry for entry in entries if entry["class"] == "superseded"]
|
|
593
|
+
with_evidence = len(entries) - len(owner) - len(superseded)
|
|
494
594
|
if as_json:
|
|
495
595
|
print(json.dumps({"root": root, "entries": entries,
|
|
496
|
-
"summary": {"total": len(entries), "with_evidence":
|
|
497
|
-
"owner": len(owner)}},
|
|
596
|
+
"summary": {"total": len(entries), "with_evidence": with_evidence,
|
|
597
|
+
"superseded": len(superseded), "owner": len(owner)}},
|
|
598
|
+
indent=2, ensure_ascii=False))
|
|
498
599
|
return 1 if entries else 0
|
|
499
600
|
if not entries:
|
|
500
601
|
print("softure-doctor --sweep: nothing to settle, the context/ contract is OK")
|
|
@@ -504,11 +605,15 @@ def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
|
504
605
|
print(f"{entry['code']} {where}: {entry['subject']}")
|
|
505
606
|
for evidence in entry["evidence"]:
|
|
506
607
|
print(f" evidence {evidence['kind']} {evidence['ref']}: {evidence['note']}")
|
|
608
|
+
if entry["class"] == "superseded":
|
|
609
|
+
print(" superseded: later work made it obsolete; close it yourself, never forward it")
|
|
507
610
|
if entry["owner"]:
|
|
508
|
-
print(" owner:
|
|
611
|
+
print(f" owner ({entry['owner_reason']}): only the owner can settle it")
|
|
612
|
+
for tried in entry["tried"]:
|
|
613
|
+
print(f" tried: {tried}")
|
|
509
614
|
print(f" settle: {entry['settle']}")
|
|
510
615
|
print(f"softure-doctor --sweep: {len(entries)} entr{'y' if len(entries) == 1 else 'ies'} to settle, "
|
|
511
|
-
f"{
|
|
616
|
+
f"{with_evidence} with evidence, {len(superseded)} superseded, {len(owner)} for the owner")
|
|
512
617
|
return 1
|
|
513
618
|
|
|
514
619
|
|
|
@@ -570,4 +675,4 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
570
675
|
|
|
571
676
|
|
|
572
677
|
if __name__ == "__main__":
|
|
573
|
-
sys.exit(main
|
|
678
|
+
sys.exit(quiet_broken_pipe(main))
|
|
@@ -4,18 +4,23 @@
|
|
|
4
4
|
doctor.py --fix [--write] [--json] [--root <dir>]
|
|
5
5
|
npx softure-skills doctor --fix [--write]
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Three shapes are mechanical, and only files under `context/` are edited:
|
|
8
8
|
|
|
9
9
|
archived-change-status an archived change.md gets `status: archived`; the old value is kept as
|
|
10
10
|
`legacy_status` in its front matter (a missing status gets none)
|
|
11
11
|
index-missing-file a row of an index inside an archive folder (`context/archive/`,
|
|
12
12
|
`context/foundation/archive/`) that links a missing file is rewritten to the
|
|
13
13
|
file's current path when git history shows where it moved (rename detection,
|
|
14
|
-
followed across several moves); a file that was deleted
|
|
15
|
-
|
|
14
|
+
followed across several moves); a file that was deleted on purpose (git shows
|
|
15
|
+
the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
dropped Progress item an unticked item of an archived plan's `## Progress` that is struck through or
|
|
18
|
+
carries a dropped/cancelled/not-applicable note is normalised to
|
|
19
|
+
`- [x] ~~<item>~~ — dropped: <note>` (the doctor already reads it as dropped)
|
|
20
|
+
|
|
21
|
+
Everything else (an index row whose target is not in the history this checkout holds, a live index)
|
|
22
|
+
is a judgement case: `doctor.py --sweep` lists it with evidence. A shallow clone works: what it cannot
|
|
23
|
+
see is skipped and named, never guessed.
|
|
19
24
|
Every edit is printed; a second run after `--write` changes nothing.
|
|
20
25
|
|
|
21
26
|
Importable: `from doctor_fix import plan_fixes, apply_fixes`.
|
|
@@ -32,7 +37,7 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
32
37
|
from context_state import frontmatter # noqa: E402
|
|
33
38
|
|
|
34
39
|
ARCHIVE_PREFIXES = ("context/archive/", "context/foundation/archive/")
|
|
35
|
-
|
|
40
|
+
REMOVED_MARK = "removed in"
|
|
36
41
|
MAX_HOPS = 10
|
|
37
42
|
|
|
38
43
|
|
|
@@ -40,14 +45,17 @@ MAX_HOPS = 10
|
|
|
40
45
|
|
|
41
46
|
|
|
42
47
|
class History:
|
|
43
|
-
"""Where files under a git checkout went. `usable` is False without git
|
|
48
|
+
"""Where files under a git checkout went. `usable` is False without git; `shallow` marks a shallow
|
|
49
|
+
clone, whose answers cover only the commits it holds."""
|
|
44
50
|
|
|
45
51
|
def __init__(self, root: str | None) -> None:
|
|
46
52
|
self.root = root
|
|
47
53
|
self.usable = False
|
|
54
|
+
self.shallow = False
|
|
48
55
|
if root:
|
|
49
56
|
probe = self._git("rev-parse", "--is-shallow-repository")
|
|
50
|
-
self.usable = probe.returncode == 0
|
|
57
|
+
self.usable = probe.returncode == 0
|
|
58
|
+
self.shallow = probe.stdout.strip() == "true"
|
|
51
59
|
|
|
52
60
|
def _git(self, *args: str) -> subprocess.CompletedProcess:
|
|
53
61
|
return subprocess.run(["git", "-C", self.root or ".", *args], capture_output=True, text=True)
|
|
@@ -60,12 +68,12 @@ class History:
|
|
|
60
68
|
return os.path.exists(os.path.join(self.root or ".", rel))
|
|
61
69
|
|
|
62
70
|
def trace(self, rel: str) -> tuple[str, str] | None:
|
|
63
|
-
"""("moved", <current path>) or ("
|
|
64
|
-
the
|
|
71
|
+
"""("moved", <current path>) or ("removed", <short sha of the commit that deleted it>); None when
|
|
72
|
+
the history this checkout holds shows neither (never there, or past a shallow clone's edge)."""
|
|
65
73
|
if not self.usable:
|
|
66
74
|
return None
|
|
67
75
|
current = rel.rstrip("/")
|
|
68
|
-
|
|
76
|
+
last = None
|
|
69
77
|
for _ in range(MAX_HOPS):
|
|
70
78
|
if current != rel.rstrip("/") and self.exists_now(current):
|
|
71
79
|
return "moved", current
|
|
@@ -73,17 +81,27 @@ class History:
|
|
|
73
81
|
sha = log.stdout.strip()
|
|
74
82
|
if log.returncode != 0 or not sha:
|
|
75
83
|
break
|
|
76
|
-
|
|
77
|
-
last_having = parent.stdout.strip() if parent.returncode == 0 else sha
|
|
84
|
+
last = (sha, current)
|
|
78
85
|
moved_to = self._renamed_in(sha, current)
|
|
79
86
|
if not moved_to or moved_to == current:
|
|
80
87
|
break
|
|
81
88
|
current = moved_to
|
|
82
|
-
if
|
|
89
|
+
if last is None:
|
|
83
90
|
return None
|
|
84
91
|
if current != rel.rstrip("/") and self.exists_now(current):
|
|
85
92
|
return "moved", current
|
|
86
|
-
|
|
93
|
+
sha, path = last
|
|
94
|
+
if self.exists_now(path) or not self._deleted_in(sha, path):
|
|
95
|
+
return None
|
|
96
|
+
return "removed", self.short(sha)
|
|
97
|
+
|
|
98
|
+
def _deleted_in(self, sha: str, path: str) -> bool:
|
|
99
|
+
"""Whether commit `sha` deletes `path` (a file, or every file under a folder)."""
|
|
100
|
+
shown = self._git("show", "-M", "--name-status", "--format=", sha)
|
|
101
|
+
statuses = [line.split("\t") for line in shown.stdout.splitlines()]
|
|
102
|
+
hits = [parts[0] for parts in statuses if len(parts) >= 2
|
|
103
|
+
and (parts[1] == path or parts[1].startswith(path + "/"))]
|
|
104
|
+
return bool(hits) and all(status == "D" for status in hits)
|
|
87
105
|
|
|
88
106
|
def _renamed_in(self, sha: str, path: str) -> str | None:
|
|
89
107
|
shown = self._git("show", "-M", "--name-status", "--format=", sha)
|
|
@@ -155,9 +173,10 @@ def _replace_target(line: str, missing: dict, replacement: str | None, gone_note
|
|
|
155
173
|
if replacement is not None:
|
|
156
174
|
return pattern.sub(lambda m: f"[{m.group(1)}]({replacement}{m.group(2)})", line, count=1)
|
|
157
175
|
return pattern.sub(lambda m: f"{m.group(1)} ({gone_note}: {target})", line, count=1)
|
|
176
|
+
cell = re.compile(r"(\|\s*)`?" + re.escape(target) + r"`?(\s*\|)")
|
|
158
177
|
if replacement is not None:
|
|
159
|
-
return
|
|
160
|
-
return
|
|
178
|
+
return cell.sub(lambda m: f"{m.group(1)}`{replacement}`{m.group(2)}", line, count=1)
|
|
179
|
+
return cell.sub(lambda m: f"{m.group(1)}{target} ({gone_note}){m.group(2)}", line, count=1)
|
|
161
180
|
|
|
162
181
|
|
|
163
182
|
def plan_fixes(reader, root: str | None) -> dict:
|
|
@@ -180,6 +199,28 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
180
199
|
files[rel] = fixed[0]
|
|
181
200
|
edits.append({"code": "archived-change-status", "path": rel, "what": fixed[1]})
|
|
182
201
|
|
|
202
|
+
for name, is_dir in reader.listdir(doctor.ARCHIVE_DIR):
|
|
203
|
+
if not is_dir:
|
|
204
|
+
continue
|
|
205
|
+
rel = f"{doctor.ARCHIVE_DIR}/{name}/plan.md"
|
|
206
|
+
text = reader.read(rel)
|
|
207
|
+
if text is None:
|
|
208
|
+
continue
|
|
209
|
+
lines = text.split("\n")
|
|
210
|
+
in_progress = False
|
|
211
|
+
for index, line in enumerate(lines):
|
|
212
|
+
if line.startswith("## "):
|
|
213
|
+
in_progress = line[3:].strip() == "Progress"
|
|
214
|
+
continue
|
|
215
|
+
box = re.match(r"^(\s*)- \[ \] (.+)$", line) if in_progress else None
|
|
216
|
+
normalised = doctor.dropped_line(box.group(2)) if box else None
|
|
217
|
+
if normalised:
|
|
218
|
+
lines[index] = f"{box.group(1)}- [x] {normalised}"
|
|
219
|
+
edits.append({"code": "archived-change-progress", "path": rel, "line": index + 1,
|
|
220
|
+
"what": f"dropped item normalised: {normalised}"})
|
|
221
|
+
if lines != text.split("\n"):
|
|
222
|
+
files[rel] = "\n".join(lines)
|
|
223
|
+
|
|
183
224
|
history = History(root)
|
|
184
225
|
for missing in doctor.missing_index_targets(reader):
|
|
185
226
|
if not missing["path"].startswith(ARCHIVE_PREFIXES):
|
|
@@ -188,7 +229,7 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
188
229
|
continue
|
|
189
230
|
if not history.usable:
|
|
190
231
|
skipped.append({"code": "index-missing-file", "path": missing["path"], "target": missing["target"],
|
|
191
|
-
"why": "
|
|
232
|
+
"why": "not a git checkout"})
|
|
192
233
|
continue
|
|
193
234
|
found = None
|
|
194
235
|
for candidate in missing["candidates"]:
|
|
@@ -197,8 +238,11 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
197
238
|
found = (candidate, traced)
|
|
198
239
|
break
|
|
199
240
|
if not found:
|
|
241
|
+
why = ("not moved or deleted in the history this shallow clone holds (fetch more with "
|
|
242
|
+
"`git fetch --deepen`), or never in git: fix or drop the row (--sweep)" if history.shallow
|
|
243
|
+
else "git shows no move or deletion (never in git?): fix or drop the row (--sweep)")
|
|
200
244
|
skipped.append({"code": "index-missing-file", "path": missing["path"], "target": missing["target"],
|
|
201
|
-
"why":
|
|
245
|
+
"why": why})
|
|
202
246
|
continue
|
|
203
247
|
candidate, (kind, value) = found
|
|
204
248
|
text = files.get(missing["path"], reader.read(missing["path"]) or "")
|
|
@@ -211,7 +255,7 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
211
255
|
lines[index] = _replace_target(lines[index], missing, new_target, None)
|
|
212
256
|
what = f"`{missing['target']}` -> `{new_target}` (moved to {value})"
|
|
213
257
|
else:
|
|
214
|
-
note = f"{
|
|
258
|
+
note = f"{REMOVED_MARK} {value}"
|
|
215
259
|
lines[index] = _replace_target(lines[index], missing, None, note)
|
|
216
260
|
what = f"`{missing['target']}` marked ({note})"
|
|
217
261
|
files[missing["path"]] = "\n".join(lines)
|
|
@@ -17,9 +17,20 @@ evidence found in the repository, and how to settle it:
|
|
|
17
17
|
the roadmap was closed
|
|
18
18
|
anything else the file to fix (and `--fix` for the mechanical shapes)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
the
|
|
20
|
+
Every entry has a `class`:
|
|
21
|
+
|
|
22
|
+
evidence the repository holds evidence that settles it (above); the agent settles it with that proof
|
|
23
|
+
superseded no direct evidence, but later work made it obsolete: for an owner check or open row of an
|
|
24
|
+
archived roadmap, a later roadmap was closed and a release shipped after it, or the same
|
|
25
|
+
item ID or file area appears in a later archived change; for a Progress item, a later
|
|
26
|
+
phase of the same plan is ticked (or a later archived change has the item's area). The
|
|
27
|
+
agent closes it as `obsolete: superseded by <ref>` itself, never forwards it
|
|
28
|
+
owner only the owner can settle it: a decision about future work, a secret, account or connector,
|
|
29
|
+
or a step outside the repository whose effect the agent cannot see (`owner_reason` says
|
|
30
|
+
which; `unsettled` when nothing at all was found), with `tried`: what the sweep looked for
|
|
31
|
+
|
|
32
|
+
`"owner": true` marks the owner class. The skill section "Sweep history to zero" tells an agent how to
|
|
33
|
+
work the list: settle every entry with its evidence, never without.
|
|
23
34
|
|
|
24
35
|
Importable: `from doctor_sweep import sweep`.
|
|
25
36
|
"""
|
|
@@ -33,24 +44,48 @@ import sys
|
|
|
33
44
|
sys.dont_write_bytecode = True
|
|
34
45
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
35
46
|
from context_state import ( # noqa: E402
|
|
36
|
-
ARCHIVE_ROADMAPS_DIR, OWNER_SECTION, QUEUED_DIR, RELEASE_SECTION, ROADMAP_PATH, CHECKBOX_RE,
|
|
37
|
-
ITEM_REF_RE, archived_roadmap_files, frontmatter, pending_release_roadmap, roadmap_rows, sections,
|
|
47
|
+
ARCHIVE_ROADMAPS_DIR, OWNER_SECTION, QUEUED_DIR, RELEASE_LINE_RE, RELEASE_SECTION, ROADMAP_PATH, CHECKBOX_RE,
|
|
48
|
+
ITEM_REF_RE, SECRET_RE, archived_roadmap_files, frontmatter, pending_release_roadmap, roadmap_rows, sections,
|
|
38
49
|
)
|
|
39
50
|
|
|
40
51
|
SHA_TAIL_RE = re.compile(r"\b([0-9a-f]{7,40})\b")
|
|
41
52
|
PATH_RE = re.compile(r"`((?:[\w.-]+/)+[\w.-]+\.\w+|[\w.-]+\.(?:ts|tsx|js|jsx|mjs|py|cs|go|rs|java|kt|rb|php|sql|css|scss|html|json|yml|yaml|sh))`")
|
|
42
53
|
SEMVER_TAG_RE = re.compile(r"^v?\d+\.\d+\.\d+")
|
|
54
|
+
AREA_RE = re.compile(r"`((?:\.{0,2}/)?(?:[\w.@-]+/)+[\w.@-]*)`")
|
|
43
55
|
LIMIT = 3
|
|
44
56
|
|
|
57
|
+
# What only the owner can settle (WORKFLOW §12.4); everything else is the agent's.
|
|
58
|
+
OWNER_KINDS = (
|
|
59
|
+
("decision", re.compile(r"\b(?:decide|decision|choose|agree on|sign[- ]off)\b", re.IGNORECASE)),
|
|
60
|
+
("secret", re.compile(SECRET_RE.pattern + r"|\b(?:accounts?|connectors?|oauth|dns|domains?|certificates?|billing"
|
|
61
|
+
r"|subscriptions?|licen[cs]es?)\b|`[A-Z][A-Z0-9]*_[A-Z0-9_]+`", re.IGNORECASE)),
|
|
62
|
+
("outside", re.compile(r"\b(?:in production|on production|production (?:environment|settings?)|in staging"
|
|
63
|
+
r"|app store|play store|real (?:phone|device)|with the (?:client|customer|vendor)"
|
|
64
|
+
r"|support ticket|by (?:e-?mail|phone) to)\b", re.IGNORECASE)),
|
|
65
|
+
)
|
|
66
|
+
|
|
45
67
|
SETTLE = {
|
|
46
68
|
"archived-change-progress": "tick it with the SHA that did it (`- [x] <text> — <sha>`), or, when the work was "
|
|
47
69
|
"never done, `- [x] ~~<text>~~ — dropped: <reason>`",
|
|
48
|
-
"archived-roadmap-summary": "put the merge SHA into the row's Merge cell (
|
|
70
|
+
"archived-roadmap-summary": "put the merge SHA into the row's Merge cell (a release tag where the roadmap records "
|
|
71
|
+
"a release instead; `carried`, `dropped` or `— <reason>` for a row with no merge)",
|
|
49
72
|
"archived-roadmap-open-items": "set the row's status to `done` when the evidence shows it shipped, "
|
|
50
73
|
"`carried (to <path>)` when a later roadmap took it, or `dropped (<reason>)`",
|
|
51
74
|
"archived-roadmap-open-checks": "tick it with its evidence (`— done: <sha | release | path>`), as obsolete "
|
|
52
75
|
"(`— obsolete: <reason>`), or carry it to a live roadmap or an owner-word issue "
|
|
53
76
|
"and tick it with where it went (`— carried to <path | #N>`)",
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
SETTLE_SUPERSEDED = {
|
|
80
|
+
"archived-change-progress": "close it yourself: `- [x] <text> — obsolete: superseded by <ref>` (never forward it)",
|
|
81
|
+
"archived-roadmap-open-items": "set the row's status to `dropped (obsolete: superseded by <ref>)` (never forward it)",
|
|
82
|
+
"archived-roadmap-open-checks": "close it yourself: `- [x] <text> — obsolete: superseded by <ref>` "
|
|
83
|
+
"(never forward it to the owner)",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
SETTLE_OWNER = {
|
|
87
|
+
"archived-roadmap-open-checks": "the owner's: carry it to the live roadmap's `## Owner decisions and checks` (or "
|
|
88
|
+
"an owner-word issue) and tick it `— carried to <path | #N>`",
|
|
54
89
|
"archived-change-status": "mechanical: `doctor --fix --write`",
|
|
55
90
|
"index-missing-file": "point the row at the file's current path, or drop the row",
|
|
56
91
|
"roadmap-archived-not-removed": "remove roadmap.md (the close moved it)",
|
|
@@ -68,9 +103,11 @@ class Git:
|
|
|
68
103
|
def __init__(self, root: str | None) -> None:
|
|
69
104
|
self.root = root
|
|
70
105
|
self.usable = False
|
|
106
|
+
self.shallow = False
|
|
71
107
|
if root:
|
|
72
108
|
probe = self._run("rev-parse", "--is-shallow-repository")
|
|
73
|
-
self.usable = probe.returncode == 0
|
|
109
|
+
self.usable = probe.returncode == 0
|
|
110
|
+
self.shallow = probe.stdout.strip() == "true"
|
|
74
111
|
|
|
75
112
|
def _run(self, *args: str) -> subprocess.CompletedProcess:
|
|
76
113
|
return subprocess.run(["git", "-C", self.root or ".", *args], capture_output=True, text=True)
|
|
@@ -105,15 +142,15 @@ class Git:
|
|
|
105
142
|
tags = [tag for tag in out.stdout.split() if SEMVER_TAG_RE.match(tag)]
|
|
106
143
|
return tags[0] if tags else None
|
|
107
144
|
|
|
108
|
-
def release_after(self, day: str | None) -> dict | None:
|
|
109
|
-
"""The first release tag created on or after `day
|
|
145
|
+
def release_after(self, day: str | None, strict: bool = False) -> dict | None:
|
|
146
|
+
"""The first release tag created on or after `day` (after it, with `strict`)."""
|
|
110
147
|
if not self.usable or not day:
|
|
111
148
|
return None
|
|
112
149
|
out = self._run("for-each-ref", "--sort=creatordate", "--format=%(refname:short)\t%(creatordate:short)",
|
|
113
150
|
"refs/tags")
|
|
114
151
|
for line in out.stdout.splitlines():
|
|
115
152
|
tag, _, date = line.partition("\t")
|
|
116
|
-
if SEMVER_TAG_RE.match(tag) and date >= day:
|
|
153
|
+
if SEMVER_TAG_RE.match(tag) and (date > day if strict else date >= day):
|
|
117
154
|
return {"tag": tag, "date": date}
|
|
118
155
|
return None
|
|
119
156
|
|
|
@@ -178,10 +215,109 @@ def _item_evidence(reader, git: Git, path: str, item: str | None, change_id: str
|
|
|
178
215
|
return evidence
|
|
179
216
|
|
|
180
217
|
|
|
218
|
+
def owner_kind(text: str) -> str | None:
|
|
219
|
+
"""`decision`, `secret` or `outside` when the line is something only the owner can settle; None otherwise."""
|
|
220
|
+
for kind, pattern in OWNER_KINDS:
|
|
221
|
+
if pattern.search(text or ""):
|
|
222
|
+
return kind
|
|
223
|
+
return None
|
|
224
|
+
|
|
225
|
+
|
|
181
226
|
def _entry(code: str, path: str, line: int | None, text: str, subject: str, evidence: list[dict],
|
|
227
|
+
superseded: list[dict] | None = None, tried: list[str] | None = None, owner_text: str | None = None,
|
|
182
228
|
**extra) -> dict:
|
|
229
|
+
"""One worklist entry, classed `evidence`, `superseded` or `owner` (in that order of proof).
|
|
230
|
+
|
|
231
|
+
`owner_text` (the line, for checks and Progress items) lets a decision, a secret or a step outside the
|
|
232
|
+
repository stay the owner's even when later work exists; anything else without direct evidence is
|
|
233
|
+
superseded when later work made it obsolete, and the owner's (`unsettled`) only when nothing was found.
|
|
234
|
+
"""
|
|
235
|
+
kind = owner_kind(owner_text) if owner_text is not None else None
|
|
236
|
+
if evidence:
|
|
237
|
+
klass, reason, settle = "evidence", None, SETTLE.get(code, "fix the file it names")
|
|
238
|
+
elif kind:
|
|
239
|
+
klass, reason, settle = "owner", kind, SETTLE_OWNER.get(code, SETTLE.get(code, "fix the file it names"))
|
|
240
|
+
elif superseded:
|
|
241
|
+
klass, reason, settle = "superseded", None, SETTLE_SUPERSEDED.get(code, SETTLE.get(code, "fix the file it names"))
|
|
242
|
+
evidence = superseded
|
|
243
|
+
else:
|
|
244
|
+
klass, reason, settle = "owner", "unsettled", SETTLE.get(code, "fix the file it names")
|
|
183
245
|
return {"code": code, "path": path, "line": line, "text": text, "subject": subject, "evidence": evidence,
|
|
184
|
-
"
|
|
246
|
+
"class": klass, "owner": klass == "owner", "owner_reason": reason,
|
|
247
|
+
"tried": [] if klass == "evidence" else (tried or []), "settle": settle, **extra}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
# ---------------------------------------------------------------- superseded
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _areas(text: str) -> list[str]:
|
|
254
|
+
"""File areas a line names: the folder of each backticked path (`src/booking/page.tsx` -> `src/booking/`)."""
|
|
255
|
+
areas = []
|
|
256
|
+
for path in AREA_RE.findall(text or "") + PATH_RE.findall(text or ""):
|
|
257
|
+
folder = path if path.endswith("/") else (os.path.dirname(path) + "/" if "/" in path else "")
|
|
258
|
+
if folder and folder not in areas and folder.strip("./"):
|
|
259
|
+
areas.append(folder.lstrip("./") if folder.startswith("./") else folder)
|
|
260
|
+
return areas
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def _later_changes(reader, day: str | None, needles: list[str], exclude: str | None = None) -> list[dict]:
|
|
264
|
+
"""Archived changes dated after `day` whose change.md or plan.md names an item ID, change ID or file area."""
|
|
265
|
+
needles = [needle for needle in needles if needle]
|
|
266
|
+
if not day or not needles:
|
|
267
|
+
return []
|
|
268
|
+
found = []
|
|
269
|
+
for name, is_dir in sorted(reader.listdir("context/archive")):
|
|
270
|
+
date = re.match(r"^(\d{4}-\d{2}-\d{2})-", name)
|
|
271
|
+
folder = f"context/archive/{name}"
|
|
272
|
+
if not is_dir or not date or date.group(1) <= day or folder == exclude:
|
|
273
|
+
continue
|
|
274
|
+
for rel in ("change.md", "plan.md"):
|
|
275
|
+
text = reader.read(f"{folder}/{rel}") or ""
|
|
276
|
+
hit = next((needle for needle in needles
|
|
277
|
+
if re.search(r"(?<![\w-])" + re.escape(needle) + (r"" if needle.endswith("/") else r"(?![\w-])"),
|
|
278
|
+
text)), None)
|
|
279
|
+
if hit:
|
|
280
|
+
found.append(_evidence("file", f"{folder}/", f"a later archived change on the same "
|
|
281
|
+
f"{'area' if hit.endswith('/') else 'item'} (`{hit}`)"))
|
|
282
|
+
break
|
|
283
|
+
if found:
|
|
284
|
+
break
|
|
285
|
+
return found
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def _later_release(reader, git: Git, day: str, later: list[str]) -> dict | None:
|
|
289
|
+
"""The first release after `day`: a release tag, else a `Release:` line of a later archived roadmap."""
|
|
290
|
+
tag = git.release_after(day, strict=True)
|
|
291
|
+
if tag:
|
|
292
|
+
return _evidence("release", tag["tag"], f"released {tag['date']}, after {day}")
|
|
293
|
+
for path in later:
|
|
294
|
+
for line in sections(reader.read(path) or "").get("Summary", []):
|
|
295
|
+
match = RELEASE_LINE_RE.match(line.strip())
|
|
296
|
+
if match and (match.group("date") or "9999") > day:
|
|
297
|
+
return _evidence("release", match.group("version"), f"released {match.group('date') or 'later'}, "
|
|
298
|
+
f"recorded in {path}")
|
|
299
|
+
return None
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def _superseded_roadmap_entry(reader, git: Git, path: str, text: str, needles: list[str]) -> tuple[list, list]:
|
|
303
|
+
"""(superseded evidence, what was tried) for an open check or row of the archived roadmap `path`."""
|
|
304
|
+
closed_on = _date_of(path, frontmatter(reader.read(path) or "")) or ""
|
|
305
|
+
later = [p for p in archived_roadmap_files(reader) if p > path and roadmap_rows(reader.read(p) or "")]
|
|
306
|
+
tried = []
|
|
307
|
+
evidence: list[dict] = []
|
|
308
|
+
release = _later_release(reader, git, closed_on, later) if later else None
|
|
309
|
+
if later and release:
|
|
310
|
+
evidence = [_evidence("file", later[0], f"a later roadmap, closed after {closed_on}"), release]
|
|
311
|
+
tried.append(f"a later closed roadmap: {later[0] if later else 'none'}; a release after {closed_on}: "
|
|
312
|
+
f"{release['ref'] if release else 'none'}")
|
|
313
|
+
areas = _areas(text)
|
|
314
|
+
if not evidence:
|
|
315
|
+
evidence = _later_changes(reader, closed_on, needles + areas)
|
|
316
|
+
tried.append(f"later archived changes naming {', '.join(f'`{n}`' for n in needles + areas) or 'its item or area'}: "
|
|
317
|
+
+ ("found" if evidence else "none"))
|
|
318
|
+
if git.shallow:
|
|
319
|
+
tried.append("the history is a shallow clone; `git fetch --deepen <n>` may find more")
|
|
320
|
+
return evidence, tried
|
|
185
321
|
|
|
186
322
|
|
|
187
323
|
# ---------------------------------------------------------------- per failure code
|
|
@@ -211,6 +347,8 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
211
347
|
in_progress = False
|
|
212
348
|
phase = None
|
|
213
349
|
phase_shas: dict[str, list[str]] = {}
|
|
350
|
+
phase_marks: dict[str, list[bool]] = {}
|
|
351
|
+
phase_lines: dict[str, int] = {}
|
|
214
352
|
pending: list[tuple[int, str, str, str]] = []
|
|
215
353
|
for number, line in enumerate(_lines(text), start=1):
|
|
216
354
|
if line.startswith("## "):
|
|
@@ -221,10 +359,12 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
221
359
|
heading = re.match(r"^### Phase (\d+)", line)
|
|
222
360
|
if heading:
|
|
223
361
|
phase = heading.group(1)
|
|
362
|
+
phase_lines.setdefault(phase, number)
|
|
224
363
|
continue
|
|
225
364
|
box = CHECKBOX_RE.match(line)
|
|
226
365
|
if not box:
|
|
227
366
|
continue
|
|
367
|
+
phase_marks.setdefault(phase or "", []).append(box.group("mark") != " ")
|
|
228
368
|
if box.group("mark") != " ":
|
|
229
369
|
tail = line.rsplit(" — ", 1)[-1] if " — " in line else ""
|
|
230
370
|
phase_shas.setdefault(phase or "", []).extend(SHA_TAIL_RE.findall(tail))
|
|
@@ -237,7 +377,20 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
237
377
|
files = sorted(set(phase_files.get(phase, [])))
|
|
238
378
|
evidence += _commit_evidence(git.touching(files, since), f"touched {', '.join(files)} after {since}")
|
|
239
379
|
evidence += _commit_evidence(merges, "merge of the change")
|
|
240
|
-
|
|
380
|
+
later = [p for p, marks in phase_marks.items() if p.isdigit() and phase.isdigit() and int(p) > int(phase)
|
|
381
|
+
and marks and all(marks)]
|
|
382
|
+
superseded = [_evidence("file", f"{path}:{phase_lines[p]}", f"phase {p}, later in the same plan, is ticked")
|
|
383
|
+
for p in sorted(later, key=int)[:1]]
|
|
384
|
+
tried = [f"commits citing or touching phase {phase or '?'} and merges naming `{change_id}`: none",
|
|
385
|
+
f"a later phase of the plan, all ticked: {'phase ' + later[0] if later else 'none'}"]
|
|
386
|
+
if not superseded:
|
|
387
|
+
superseded = _later_changes(reader, since, _areas(subject), exclude=folder)
|
|
388
|
+
tried.append(f"later archived changes on its area ({', '.join(_areas(subject)) or 'no area named'}): "
|
|
389
|
+
+ ("found" if superseded else "none"))
|
|
390
|
+
if git.shallow:
|
|
391
|
+
tried.append("the history is a shallow clone; `git fetch --deepen <n>` may find more")
|
|
392
|
+
entries.append(_entry("archived-change-progress", path, number, line, subject, evidence,
|
|
393
|
+
superseded=superseded, tried=tried, owner_text=subject))
|
|
241
394
|
return entries
|
|
242
395
|
|
|
243
396
|
|
|
@@ -250,26 +403,11 @@ def _summary_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
250
403
|
|
|
251
404
|
text = reader.read(path) or ""
|
|
252
405
|
rows = _roadmap_rows_by_id(text)
|
|
253
|
-
bad = {entry.split(":", 1)[0] for entry in doctor.summary_placeholders(text)}
|
|
254
406
|
entries = []
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
for number, line in enumerate(_lines(text), start=1):
|
|
258
|
-
if line.startswith("## "):
|
|
259
|
-
in_summary = line[3:].strip() == "Summary"
|
|
260
|
-
header = None
|
|
261
|
-
continue
|
|
262
|
-
if not in_summary or not line.strip().startswith("|"):
|
|
263
|
-
continue
|
|
264
|
-
cells = [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
265
|
-
if header is None:
|
|
266
|
-
header = [cell.lower() for cell in cells]
|
|
267
|
-
continue
|
|
268
|
-
if cells[0] not in bad:
|
|
407
|
+
for row in doctor.summary_rows(text):
|
|
408
|
+
if row["ok"]:
|
|
269
409
|
continue
|
|
270
|
-
|
|
271
|
-
cell = cells[index] if index < len(cells) else ""
|
|
272
|
-
item = cells[0]
|
|
410
|
+
item, cell = row["item"], row["cell"]
|
|
273
411
|
change_id = (rows.get(item) or {}).get("change_id")
|
|
274
412
|
evidence = _commit_evidence(git.merges_for(change_id), "merge of the item's change")
|
|
275
413
|
folder = _archived_change_folder(reader, change_id)
|
|
@@ -277,7 +415,7 @@ def _summary_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
277
415
|
shas = SHA_TAIL_RE.findall(reader.read(f"{folder}/plan.md") or "")
|
|
278
416
|
if shas:
|
|
279
417
|
evidence.append(_evidence("commit", shas[-1], f"last SHA in {folder}/plan.md (not a merge; prefer the merge)"))
|
|
280
|
-
entries.append(_entry("archived-roadmap-summary", path,
|
|
418
|
+
entries.append(_entry("archived-roadmap-summary", path, row["line"], row["text"], f"{item}: {cell}", evidence,
|
|
281
419
|
cell=cell, item=item, change_id=change_id))
|
|
282
420
|
return entries
|
|
283
421
|
|
|
@@ -295,8 +433,11 @@ def _open_item_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
295
433
|
row = rows.pop(match.group(1))
|
|
296
434
|
status = [cell.strip() for cell in line.strip().strip("|").split("|")][-1]
|
|
297
435
|
evidence = _item_evidence(reader, git, path, row["id"], row["change_id"])
|
|
436
|
+
superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
|
|
437
|
+
reader, git, path, line, [row["id"], row["change_id"]])
|
|
298
438
|
entries.append(_entry("archived-roadmap-open-items", path, number, line, f"{row['id']} ({row['status']})",
|
|
299
|
-
evidence,
|
|
439
|
+
evidence, superseded=superseded, tried=tried, item=row["id"],
|
|
440
|
+
change_id=row["change_id"], status=status))
|
|
300
441
|
return entries
|
|
301
442
|
|
|
302
443
|
|
|
@@ -322,8 +463,11 @@ def _open_check_entries(reader, git: Git, path: str) -> list[dict]:
|
|
|
322
463
|
evidence = _item_evidence(reader, git, path, item, change_id) if item else []
|
|
323
464
|
if release and section == RELEASE_SECTION:
|
|
324
465
|
evidence.append(_evidence("release", release["tag"], f"released {release['date']}, after the close"))
|
|
466
|
+
superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
|
|
467
|
+
reader, git, path, line, [item, change_id] if item else [])
|
|
325
468
|
entries.append(_entry("archived-roadmap-open-checks", path, number, line, box.group("text").strip(),
|
|
326
|
-
evidence,
|
|
469
|
+
evidence, superseded=superseded, tried=tried, owner_text=box.group("text"),
|
|
470
|
+
item=item, change_id=change_id, section=section))
|
|
327
471
|
return entries
|
|
328
472
|
|
|
329
473
|
|
|
@@ -341,12 +485,12 @@ def _index_entries(reader, root: str | None) -> list[dict]:
|
|
|
341
485
|
evidence.append(_evidence("file", traced[1], f"`{missing['target']}` moved here (git rename history)"))
|
|
342
486
|
break
|
|
343
487
|
if traced:
|
|
344
|
-
evidence.append(_evidence("commit", traced[1], f"
|
|
345
|
-
"
|
|
488
|
+
evidence.append(_evidence("commit", traced[1], f"deleted `{candidate}` on purpose (no rename); "
|
|
489
|
+
"`doctor --fix --write` marks the row (removed in it)"))
|
|
346
490
|
break
|
|
347
491
|
if not evidence:
|
|
348
492
|
evidence.append(_evidence("file", f"{missing['path']}:{missing['line']}",
|
|
349
|
-
"
|
|
493
|
+
"git shows no move or deletion of the target: fix the link or drop the row"))
|
|
350
494
|
entries.append(_entry("index-missing-file", missing["path"], missing["line"], missing["text"],
|
|
351
495
|
f"`{missing['target']}`", evidence, target=missing["target"]))
|
|
352
496
|
return entries
|