cribsheet 0.25.0.dev2__py3-none-any.whl → 0.25.0.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crib/app.py +198 -284
- crib/cli.py +33 -89
- crib/designs.py +252 -165
- crib/doctor.py +9 -5
- crib/facets.py +211 -57
- crib/facets.toml +2 -4
- crib/server.py +0 -1
- crib/verbs.py +67 -66
- crib/wording.py +30 -0
- crib/wording.toml +541 -0
- {cribsheet-0.25.0.dev2.dist-info → cribsheet-0.25.0.dev3.dist-info}/METADATA +1 -1
- {cribsheet-0.25.0.dev2.dist-info → cribsheet-0.25.0.dev3.dist-info}/RECORD +14 -13
- crib/graph_texts.py +0 -47
- {cribsheet-0.25.0.dev2.dist-info → cribsheet-0.25.0.dev3.dist-info}/WHEEL +0 -0
- {cribsheet-0.25.0.dev2.dist-info → cribsheet-0.25.0.dev3.dist-info}/entry_points.txt +0 -0
crib/app.py
CHANGED
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import contextlib
|
|
12
|
+
import functools
|
|
12
13
|
import dataclasses
|
|
13
14
|
import datetime
|
|
14
15
|
import os
|
|
@@ -1075,8 +1076,6 @@ class Crib:
|
|
|
1075
1076
|
# a done/declined/parked/superseded item
|
|
1076
1077
|
SIMILAR_DUPLICATE = 0.90 # body: the same thing again
|
|
1077
1078
|
SIMILAR_CONFUSABLE = 0.85 # title, with the body below SIMILAR_SETTLED
|
|
1078
|
-
_SETTLED_STATES = ("done", "verified", "declined", "parked", "superseded")
|
|
1079
|
-
_SIMILAR_KINDS = ("note", "design", "plan")
|
|
1080
1079
|
|
|
1081
1080
|
def _similar(self, proj: str, relpath: str, store: str = "notes") -> list[dict[str, Any]]:
|
|
1082
1081
|
"""What a just-written note / decision / plan item is close to, across
|
|
@@ -1116,7 +1115,8 @@ class Crib:
|
|
|
1116
1115
|
if e.kind == "dep" or e.kind in ("follows", "rests_on", "informed_by")}
|
|
1117
1116
|
noun = kind if kind in self.designs._stores else None
|
|
1118
1117
|
rows: list[dict[str, Any]] = []
|
|
1119
|
-
for k in
|
|
1118
|
+
for k in facets.item_kinds():
|
|
1119
|
+
spec = facets.by_noun(k)
|
|
1120
1120
|
for it in self.store.items({"project": proj, "kind": k}).values():
|
|
1121
1121
|
if it.id == me.id or not it.body_vec or not any(it.body_vec):
|
|
1122
1122
|
continue
|
|
@@ -1125,7 +1125,7 @@ class Crib:
|
|
|
1125
1125
|
status = it.facet.get("status")
|
|
1126
1126
|
# settled first: a twin of something done or declined is answered
|
|
1127
1127
|
# by that state, not by "merge them"
|
|
1128
|
-
if status
|
|
1128
|
+
if facets.settled(k, status) and (
|
|
1129
1129
|
b >= self.SIMILAR_SETTLED or t >= self.SIMILAR_CONFUSABLE
|
|
1130
1130
|
): # the same thing, or the same title, as finished work
|
|
1131
1131
|
verdict = "settled"
|
|
@@ -1142,8 +1142,11 @@ class Crib:
|
|
|
1142
1142
|
"score": round(b, 4), "title_score": round(t, 4),
|
|
1143
1143
|
"verdict": verdict,
|
|
1144
1144
|
"next": self._similar_next(verdict, k, it.relpath, status)}
|
|
1145
|
-
|
|
1146
|
-
|
|
1145
|
+
# a graph item close to a LIVE item it would rest on (the link
|
|
1146
|
+
# its facet takes toward that one by default), not yet linked
|
|
1147
|
+
if (noun and verdict in ("related", "duplicate")
|
|
1148
|
+
and facets.link_default(noun, k) == "rests_on"
|
|
1149
|
+
and spec.role(status) in ("open", "gated")
|
|
1147
1150
|
and it.id not in my_deps):
|
|
1148
1151
|
row["link"] = (f"probably builds on it: {noun}_dep_add "
|
|
1149
1152
|
f"{relpath} {it.relpath} (as rests_on)")
|
|
@@ -1154,17 +1157,19 @@ class Crib:
|
|
|
1154
1157
|
|
|
1155
1158
|
@staticmethod
|
|
1156
1159
|
def _similar_next(verdict: str, kind: str, relpath: str, status: str | None) -> str:
|
|
1157
|
-
|
|
1160
|
+
from . import verbs
|
|
1161
|
+
|
|
1162
|
+
tool = verbs.view(facets.by_noun(kind)).tool
|
|
1158
1163
|
if verdict == "duplicate":
|
|
1159
|
-
return (f"the same thing already exists: {
|
|
1164
|
+
return (f"the same thing already exists: {tool('append')} / {tool('edit')} "
|
|
1160
1165
|
f"{relpath} instead, and delete this one")
|
|
1161
1166
|
if verdict == "settled":
|
|
1162
|
-
return (f"already {status}: read it ({
|
|
1167
|
+
return (f"already {status}: read it ({tool('read')} {relpath}) before "
|
|
1163
1168
|
f"keeping this one")
|
|
1164
1169
|
if verdict == "confusable":
|
|
1165
1170
|
return ("titles alike, contents not: retitle this one (or that one) so "
|
|
1166
1171
|
"the difference shows")
|
|
1167
|
-
return f"related: {
|
|
1172
|
+
return f"related: {tool('read')} {relpath}"
|
|
1168
1173
|
|
|
1169
1174
|
async def store_note(
|
|
1170
1175
|
self,
|
|
@@ -1955,7 +1960,7 @@ class Crib:
|
|
|
1955
1960
|
# Tainted design notes, loaded LAZILY and at most once per lookup — a
|
|
1956
1961
|
# frontmatter-only graph scan, and only when a hit actually lands in the
|
|
1957
1962
|
# design store, so the ambient marker costs nothing on the common query.
|
|
1958
|
-
stale_designs: set[str] | None = None
|
|
1963
|
+
stale_designs: set[tuple[str, str]] | None = None
|
|
1959
1964
|
hits, seen = [], set()
|
|
1960
1965
|
line_maps: dict[tuple[str, str], dict[str, tuple[int, int]]] = {}
|
|
1961
1966
|
for h in raw:
|
|
@@ -1981,10 +1986,12 @@ class Crib:
|
|
|
1981
1986
|
span = line_maps[(pillar, rp)].get(
|
|
1982
1987
|
section_key(heading, int(h.metadata.get("occurrence", 1) or 1))
|
|
1983
1988
|
)
|
|
1984
|
-
|
|
1989
|
+
# a hit on an item whose facet reports staleness carries the marker
|
|
1990
|
+
spec = facets.by_store(pillar)
|
|
1991
|
+
if spec is not None and spec.report_taint:
|
|
1985
1992
|
if stale_designs is None:
|
|
1986
|
-
stale_designs = self.designs.
|
|
1987
|
-
stale = rp in stale_designs
|
|
1993
|
+
stale_designs = self.designs.tainted_items(proj)
|
|
1994
|
+
stale = (spec.noun, rp) in stale_designs
|
|
1988
1995
|
else:
|
|
1989
1996
|
stale = False
|
|
1990
1997
|
hits.append(
|
|
@@ -5384,93 +5391,32 @@ class Crib:
|
|
|
5384
5391
|
# core that takes it explicitly. The FACET is the interface — reads, writes and
|
|
5385
5392
|
# retrieval all have their own verbs here, so a caller never has to know the
|
|
5386
5393
|
# decisions are notes in a directory (they are; that's backend).
|
|
5387
|
-
async def
|
|
5388
|
-
self,
|
|
5389
|
-
title: str,
|
|
5390
|
-
content: str,
|
|
5391
|
-
deps: list[str] | None = None,
|
|
5392
|
-
project: str | None = None,
|
|
5393
|
-
sources: list[Any] | None = None,
|
|
5394
|
-
proposed: bool = False,
|
|
5395
|
-
cwd: Path | None = None,
|
|
5396
|
-
follows: list[str] | None = None,
|
|
5397
|
-
rests_on: list[str] | None = None,
|
|
5398
|
-
informed_by: list[str] | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
5399
|
-
"""Record a design decision (deps validated + `checked` seeded, `sources`
|
|
5400
|
-
captured at their current section hashes), with the same near-duplicate
|
|
5401
|
-
probe `note_store` runs.
|
|
5402
|
-
|
|
5403
|
-
A near-duplicate DECISION is worse than a near-duplicate note: it forks
|
|
5404
|
-
the graph, so two half-authoritative decisions each collect their own
|
|
5405
|
-
dependents and neither taints the other's."""
|
|
5406
|
-
proj = self.resolve_project(project, cwd)
|
|
5407
|
-
out = await self.designs.design_add(
|
|
5408
|
-
proj, title, content, deps, sources, proposed,
|
|
5409
|
-
_kinded(follows, rests_on, informed_by),
|
|
5410
|
-
facet=facet,
|
|
5411
|
-
)
|
|
5412
|
-
similar = await asyncio.to_thread(self._similar, proj, out["relpath"], facets.by_noun(facet).store)
|
|
5413
|
-
return {**out, "similar": similar}
|
|
5414
|
-
|
|
5415
|
-
def design_read(
|
|
5416
|
-
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
5417
|
-
"""A decision's dossier: body, status, annotated edges, taint + chains,
|
|
5418
|
-
and `suggested_deps`: live decisions it is close to but doesn't depend
|
|
5419
|
-
on (see `_similar`)."""
|
|
5420
|
-
proj = self.resolve_project(project, cwd)
|
|
5421
|
-
out = self.designs.design_read(proj, ref, facet=facet)
|
|
5422
|
-
return {**out, "suggested_deps": self._suggested_deps(proj, out, facets.by_noun(facet).store)}
|
|
5423
|
-
|
|
5424
|
-
async def design_edit(
|
|
5394
|
+
async def graph_edit(
|
|
5425
5395
|
self,
|
|
5426
5396
|
ref: str,
|
|
5427
5397
|
new_content: str,
|
|
5428
5398
|
project: str | None = None,
|
|
5429
5399
|
sources: list[Any] | None = None,
|
|
5430
|
-
cwd: Path | None = None, *, facet: str
|
|
5400
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5431
5401
|
"""Rewrite a decision through the facet; result names what it tainted.
|
|
5432
5402
|
`sources`, when given, replaces its citations."""
|
|
5433
|
-
return await self.designs.
|
|
5403
|
+
return await self.designs.graph_edit(
|
|
5434
5404
|
self.resolve_project(project, cwd), ref, new_content, sources, facet=facet
|
|
5435
5405
|
)
|
|
5436
5406
|
|
|
5437
|
-
|
|
5438
|
-
self,
|
|
5439
|
-
ref: str,
|
|
5440
|
-
content: str,
|
|
5441
|
-
project: str | None = None,
|
|
5442
|
-
cwd: Path | None = None,
|
|
5443
|
-
sources: list[Any] | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
5444
|
-
"""Extend a decision through the facet; result names what it tainted.
|
|
5445
|
-
`sources` ADDS citations (post-hoc doc wiring), never replaces."""
|
|
5446
|
-
return await self.designs.design_append(
|
|
5447
|
-
self.resolve_project(project, cwd), ref, content, sources, facet=facet
|
|
5448
|
-
)
|
|
5449
|
-
|
|
5450
|
-
def design_list(
|
|
5451
|
-
self, tainted: bool = False, project: str | None = None, cwd: Path | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
5452
|
-
"""Every decision as a flat table (`tainted` filters to the stale ones)."""
|
|
5453
|
-
return self.designs.design_list(self.resolve_project(project, cwd), tainted, facet=facet)
|
|
5454
|
-
|
|
5455
|
-
def design_export(
|
|
5456
|
-
self, project: str | None = None, cwd: Path | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
5407
|
+
def graph_export(
|
|
5408
|
+
self, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5457
5409
|
"""The whole decision graph as ONE consolidated markdown doc
|
|
5458
5410
|
(dep-topological, ties by rank/title/id — deterministic across runs)."""
|
|
5459
5411
|
return self.designs.export_facet(self.resolve_project(project, cwd), facet)
|
|
5460
5412
|
|
|
5461
|
-
def
|
|
5462
|
-
self, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5463
|
-
"""The whole plan as ONE consolidated markdown doc (same ordering
|
|
5464
|
-
contract as the design export)."""
|
|
5465
|
-
return self.designs.export_facet(self.resolve_project(project, cwd), facet)
|
|
5466
|
-
|
|
5467
|
-
def design_lookup(
|
|
5413
|
+
def graph_lookup(
|
|
5468
5414
|
self,
|
|
5469
5415
|
query: str,
|
|
5470
5416
|
project: str | None = None,
|
|
5471
5417
|
k: int = 8,
|
|
5472
5418
|
cwd: Path | None = None,
|
|
5473
|
-
hints: list[str] | None = None, *, facet: str
|
|
5419
|
+
hints: list[str] | None = None, *, facet: str) -> list[dict[str, Any]]:
|
|
5474
5420
|
"""Retrieval scoped to the DESIGN facet, each hit annotated with the facet
|
|
5475
5421
|
state that decides whether to trust it (`status`, `tainted`, edge counts).
|
|
5476
5422
|
|
|
@@ -5487,83 +5433,56 @@ class Crib:
|
|
|
5487
5433
|
kind=facet,
|
|
5488
5434
|
)
|
|
5489
5435
|
|
|
5490
|
-
def
|
|
5491
|
-
self,
|
|
5492
|
-
query: str,
|
|
5493
|
-
project: str | None = None,
|
|
5494
|
-
k: int = 8,
|
|
5495
|
-
cwd: Path | None = None,
|
|
5496
|
-
hints: list[str] | None = None, *, facet: str = "plan") -> list[dict[str, Any]]:
|
|
5497
|
-
"""Retrieval scoped to the PLAN facet, hits annotated as `design_lookup`
|
|
5498
|
-
annotates its own."""
|
|
5499
|
-
return self.designs.annotate_hits(
|
|
5500
|
-
self.resolve_project(project, cwd),
|
|
5501
|
-
[
|
|
5502
|
-
vars(h)
|
|
5503
|
-
for h in self.lookup(
|
|
5504
|
-
query, project, k, cwd=cwd, store=facets.by_noun(facet).store, hints=hints
|
|
5505
|
-
)
|
|
5506
|
-
],
|
|
5507
|
-
kind=facet,
|
|
5508
|
-
)
|
|
5509
|
-
|
|
5510
|
-
async def design_dep_add(
|
|
5436
|
+
async def graph_dep_add(
|
|
5511
5437
|
self,
|
|
5512
5438
|
ref: str,
|
|
5513
5439
|
dep_ref: str,
|
|
5514
5440
|
project: str | None = None,
|
|
5515
5441
|
cwd: Path | None = None,
|
|
5516
|
-
kind: str | None = None, *, facet: str
|
|
5442
|
+
kind: str | None = None, *, facet: str) -> dict[str, Any]:
|
|
5517
5443
|
"""Declare that a decision builds on another (cycle-checked)."""
|
|
5518
|
-
return await self.designs.
|
|
5444
|
+
return await self.designs.graph_dep_add(
|
|
5519
5445
|
self.resolve_project(project, cwd), ref, dep_ref, kind, facet=facet
|
|
5520
5446
|
)
|
|
5521
5447
|
|
|
5522
|
-
async def
|
|
5448
|
+
async def graph_dep_remove(
|
|
5523
5449
|
self,
|
|
5524
5450
|
ref: str,
|
|
5525
5451
|
dep_ref: str,
|
|
5526
5452
|
project: str | None = None,
|
|
5527
|
-
cwd: Path | None = None, *, facet: str
|
|
5453
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5528
5454
|
"""Drop a dependency edge between two decisions."""
|
|
5529
|
-
return await self.designs.
|
|
5455
|
+
return await self.designs.graph_dep_remove(
|
|
5530
5456
|
self.resolve_project(project, cwd), ref, dep_ref, facet=facet
|
|
5531
5457
|
)
|
|
5532
5458
|
|
|
5533
|
-
async def
|
|
5459
|
+
async def graph_forget(
|
|
5534
5460
|
self,
|
|
5535
5461
|
ref: str,
|
|
5536
5462
|
force: bool = False,
|
|
5537
5463
|
project: str | None = None,
|
|
5538
|
-
cwd: Path | None = None, *, facet: str
|
|
5464
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5539
5465
|
"""Delete a decision; blocks on dependents unless forced."""
|
|
5540
|
-
return await self.designs.
|
|
5466
|
+
return await self.designs.graph_forget(
|
|
5541
5467
|
self.resolve_project(project, cwd), ref, force, facet=facet
|
|
5542
5468
|
)
|
|
5543
5469
|
|
|
5544
|
-
def
|
|
5470
|
+
def graph_check(
|
|
5545
5471
|
self,
|
|
5546
5472
|
ref: str | None = None,
|
|
5547
5473
|
project: str | None = None,
|
|
5548
|
-
cwd: Path | None = None, *, facet: str
|
|
5474
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5549
5475
|
"""Which decisions are stale with respect to what they build on."""
|
|
5550
|
-
return self.designs.
|
|
5476
|
+
return self.designs.graph_check(self.resolve_project(project, cwd), ref, facet=facet)
|
|
5551
5477
|
|
|
5552
|
-
async def
|
|
5553
|
-
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str
|
|
5478
|
+
async def graph_reaffirm(
|
|
5479
|
+
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5554
5480
|
"""Re-record a decision's dep hashes after re-reading it (the cheap,
|
|
5555
5481
|
normal outcome of a taint — not error recovery)."""
|
|
5556
|
-
return await self.designs.
|
|
5482
|
+
return await self.designs.graph_reaffirm(
|
|
5557
5483
|
self.resolve_project(project, cwd), ref, facet=facet
|
|
5558
5484
|
)
|
|
5559
5485
|
|
|
5560
|
-
async def plan_reaffirm(
|
|
5561
|
-
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5562
|
-
"""Re-record a plan item's dep hashes after re-reading what moved — the
|
|
5563
|
-
plan-side twin of design_reaffirm (clears a benign taint without the
|
|
5564
|
-
dep_remove/dep_add dance, and without pretending the work moved)."""
|
|
5565
|
-
return await self.designs.plan_reaffirm(self.resolve_project(project, cwd), ref, facet=facet)
|
|
5566
|
-
|
|
5567
5486
|
async def graph_transition(
|
|
5568
5487
|
self, ref: str, verb: str, project: str | None = None, cwd: Path | None = None,
|
|
5569
5488
|
*, facet: str) -> dict[str, Any]:
|
|
@@ -5571,27 +5490,20 @@ class Crib:
|
|
|
5571
5490
|
return await self.designs.graph_transition(
|
|
5572
5491
|
self.resolve_project(project, cwd), ref, verb, facet=facet)
|
|
5573
5492
|
|
|
5574
|
-
async def
|
|
5575
|
-
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str
|
|
5493
|
+
async def graph_promote(
|
|
5494
|
+
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str, to: str | None = None) -> dict[str, Any]:
|
|
5576
5495
|
"""Promote an extracted decision: proposed → active, hashes seeded fresh."""
|
|
5577
|
-
return await self.designs.
|
|
5496
|
+
return await self.designs.graph_promote(
|
|
5578
5497
|
self.resolve_project(project, cwd), ref, facet=facet, to=to
|
|
5579
5498
|
)
|
|
5580
5499
|
|
|
5581
|
-
def
|
|
5582
|
-
self, relpath: str, project: str | None = None, cwd: Path | None = None, *, facet: str
|
|
5500
|
+
def graph_import(
|
|
5501
|
+
self, relpath: str, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5583
5502
|
"""A doc's sections + hashes + existing citations + the extraction
|
|
5584
5503
|
procedure — the read that precedes an LLM-driven design import. Each
|
|
5585
5504
|
section names the existing decisions `closest` to it (Stage E7)."""
|
|
5586
5505
|
proj = self.resolve_project(project, cwd)
|
|
5587
|
-
return self._import_matches(proj, self.designs.
|
|
5588
|
-
facet)
|
|
5589
|
-
|
|
5590
|
-
def plan_import(
|
|
5591
|
-
self, relpath: str, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5592
|
-
"""The same for the plan facet (actionable work rather than decisions)."""
|
|
5593
|
-
proj = self.resolve_project(project, cwd)
|
|
5594
|
-
return self._import_matches(proj, self.designs.plan_import(proj, relpath, facet=facet),
|
|
5506
|
+
return self._import_matches(proj, self.designs.graph_import(proj, relpath, facet=facet),
|
|
5595
5507
|
facet)
|
|
5596
5508
|
|
|
5597
5509
|
def _import_matches(self, proj: str, out: dict[str, Any],
|
|
@@ -5642,145 +5554,92 @@ class Crib:
|
|
|
5642
5554
|
for j in best]
|
|
5643
5555
|
return out
|
|
5644
5556
|
|
|
5645
|
-
def
|
|
5557
|
+
def graph_tree(
|
|
5646
5558
|
self,
|
|
5647
5559
|
ref: str | None = None,
|
|
5648
5560
|
direction: str = "deps",
|
|
5649
5561
|
depth: int = 6,
|
|
5650
5562
|
project: str | None = None,
|
|
5651
|
-
cwd: Path | None = None, *, facet: str
|
|
5563
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5652
5564
|
"""The dependency tree around a decision, taint-flagged."""
|
|
5653
|
-
return self.designs.
|
|
5565
|
+
return self.designs.graph_tree(
|
|
5654
5566
|
self.resolve_project(project, cwd), ref, direction, depth, facet=facet
|
|
5655
5567
|
)
|
|
5656
5568
|
|
|
5657
|
-
def
|
|
5658
|
-
self, project: str | None = None, cwd: Path | None = None, sources: bool = False, *, facet: str
|
|
5569
|
+
def graph_graph(
|
|
5570
|
+
self, project: str | None = None, cwd: Path | None = None, sources: bool = False, *, facet: str) -> dict[str, Any]:
|
|
5659
5571
|
"""The decision map as {nodes, edges} — the symbol graph's consumer
|
|
5660
5572
|
contract, for decisions. `tainted` is this graph's ※."""
|
|
5661
5573
|
return self.designs.facet_graph(
|
|
5662
5574
|
self.resolve_project(project, cwd), facet, sources
|
|
5663
5575
|
)
|
|
5664
5576
|
|
|
5665
|
-
def
|
|
5666
|
-
self, project: str | None = None, cwd: Path | None = None, sources: bool = False, *, facet: str = "plan") -> dict[str, Any]:
|
|
5667
|
-
"""The plan as {nodes, edges}, INCLUDING the design nodes items rest on —
|
|
5668
|
-
those edges gate, so a plan graph without them would misdraw the plan as
|
|
5669
|
-
self-contained."""
|
|
5670
|
-
return self.designs.facet_graph(
|
|
5671
|
-
self.resolve_project(project, cwd), facet, sources
|
|
5672
|
-
)
|
|
5673
|
-
|
|
5674
|
-
async def design_supersede(
|
|
5577
|
+
async def graph_supersede(
|
|
5675
5578
|
self,
|
|
5676
5579
|
ref: str,
|
|
5677
5580
|
by_ref: str | None = None,
|
|
5678
5581
|
project: str | None = None,
|
|
5679
|
-
cwd: Path | None = None, *, facet: str
|
|
5582
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5680
5583
|
"""Soft-delete a decision and taint its dependents."""
|
|
5681
|
-
return await self.designs.
|
|
5584
|
+
return await self.designs.graph_supersede(
|
|
5682
5585
|
self.resolve_project(project, cwd), ref, by_ref, facet=facet
|
|
5683
5586
|
)
|
|
5684
5587
|
|
|
5685
|
-
async def
|
|
5686
|
-
self,
|
|
5687
|
-
title: str | None = None,
|
|
5688
|
-
content: str = "",
|
|
5689
|
-
deps: list[str] | None = None,
|
|
5690
|
-
after: str | None = None,
|
|
5691
|
-
before: str | None = None,
|
|
5692
|
-
items: list[dict[str, Any]] | None = None,
|
|
5693
|
-
project: str | None = None,
|
|
5694
|
-
sources: list[Any] | None = None,
|
|
5695
|
-
cwd: Path | None = None,
|
|
5696
|
-
follows: list[str] | None = None,
|
|
5697
|
-
rests_on: list[str] | None = None,
|
|
5698
|
-
informed_by: list[str] | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5699
|
-
"""Add one plan item, or a whole batch (`items`), ranked at the end unless
|
|
5700
|
-
after/before place them. A single item answers with `similar` (what it
|
|
5701
|
-
is close to, with a verdict: see `_similar`)."""
|
|
5702
|
-
proj = self.resolve_project(project, cwd)
|
|
5703
|
-
out = await self.designs.plan_add(
|
|
5704
|
-
proj,
|
|
5705
|
-
title,
|
|
5706
|
-
content,
|
|
5707
|
-
deps,
|
|
5708
|
-
after,
|
|
5709
|
-
before,
|
|
5710
|
-
items,
|
|
5711
|
-
sources,
|
|
5712
|
-
_kinded(follows, rests_on, informed_by),
|
|
5713
|
-
facet=facet,
|
|
5714
|
-
)
|
|
5715
|
-
if not items and out.get("relpath"):
|
|
5716
|
-
out["similar"] = await asyncio.to_thread(
|
|
5717
|
-
self._similar, proj, out["relpath"], facets.by_noun(facet).store)
|
|
5718
|
-
return out
|
|
5719
|
-
|
|
5720
|
-
async def plan_status(
|
|
5721
|
-
self, ref: str, status: str, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5588
|
+
async def graph_status(
|
|
5589
|
+
self, ref: str, status: str, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5722
5590
|
"""Set a plan item's status (todo/in-progress/parked/done/verified)."""
|
|
5723
|
-
return await self.designs.
|
|
5591
|
+
return await self.designs.graph_status(
|
|
5724
5592
|
self.resolve_project(project, cwd), ref, status, facet=facet
|
|
5725
5593
|
)
|
|
5726
5594
|
|
|
5727
|
-
async def
|
|
5595
|
+
async def graph_park(
|
|
5728
5596
|
self,
|
|
5729
5597
|
ref: str,
|
|
5730
5598
|
project: str | None = None,
|
|
5731
5599
|
triggers: list[str] | None = None,
|
|
5732
5600
|
why: str | None = None,
|
|
5733
|
-
cwd: Path | None = None, *, facet: str
|
|
5601
|
+
cwd: Path | None = None, *, facet: str, to: str | None = None) -> dict[str, Any]:
|
|
5734
5602
|
"""Park an item — not now, with a stated reason; optionally watching refs
|
|
5735
5603
|
whose change SURFACES it (never auto-wakes it)."""
|
|
5736
|
-
return await self.designs.
|
|
5604
|
+
return await self.designs.graph_park(
|
|
5737
5605
|
self.resolve_project(project, cwd), ref, triggers, why, facet=facet, to=to
|
|
5738
5606
|
)
|
|
5739
5607
|
|
|
5740
|
-
async def
|
|
5608
|
+
async def graph_decline(
|
|
5741
5609
|
self,
|
|
5742
5610
|
ref: str,
|
|
5743
5611
|
why: str | None = None,
|
|
5744
5612
|
project: str | None = None,
|
|
5745
5613
|
triggers: list[str] | None = None,
|
|
5746
|
-
cwd: Path | None = None, *, facet: str
|
|
5614
|
+
cwd: Path | None = None, *, facet: str, to: str | None = None) -> dict[str, Any]:
|
|
5747
5615
|
"""Decline an item — never scheduled, remembered with the why-not (a
|
|
5748
5616
|
decline without the why-not is refused: the rationale IS the payload)."""
|
|
5749
|
-
return await self.designs.
|
|
5617
|
+
return await self.designs.graph_decline(
|
|
5750
5618
|
self.resolve_project(project, cwd), ref, why, triggers, facet=facet, to=to
|
|
5751
5619
|
)
|
|
5752
5620
|
|
|
5753
|
-
async def
|
|
5754
|
-
self, project: str | None = None, cwd: Path | None = None, *, facet: str
|
|
5621
|
+
async def graph_review(
|
|
5622
|
+
self, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5755
5623
|
"""The review EVIDENCE PACK: the consolidated export + per-item evidence
|
|
5756
5624
|
(age, deps, overlap probes vs open AND done/declined items) + the review
|
|
5757
5625
|
contract. Runs no model, writes nothing — the session LLM judges, then
|
|
5758
5626
|
`plan_review_apply` applies the batch."""
|
|
5759
|
-
return await self.designs.
|
|
5627
|
+
return await self.designs.graph_review(
|
|
5760
5628
|
self.resolve_project(project, cwd),
|
|
5761
5629
|
probe=lambda p, text, exclude: self._similar(p, exclude, facets.by_noun(facet).store),
|
|
5762
5630
|
facet=facet,
|
|
5763
5631
|
)
|
|
5764
5632
|
|
|
5765
|
-
async def
|
|
5633
|
+
async def graph_review_apply(
|
|
5766
5634
|
self,
|
|
5767
5635
|
project: str | None = None,
|
|
5768
5636
|
batch: list[dict] | None = None,
|
|
5769
|
-
cwd: Path | None = None, *, facet: str
|
|
5637
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5770
5638
|
"""Apply a judged review batch, edge-aware, stamped `reviewed`."""
|
|
5771
|
-
return await self.designs.
|
|
5639
|
+
return await self.designs.graph_review_apply(
|
|
5772
5640
|
self.resolve_project(project, cwd), batch or [], facet=facet
|
|
5773
5641
|
)
|
|
5774
5642
|
|
|
5775
|
-
def plan_read(
|
|
5776
|
-
self, ref: str, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5777
|
-
"""A plan item's dossier: body, status, annotated edges, derived blocking
|
|
5778
|
-
+ taint — the plan-side design_read — and `suggested_deps` (see
|
|
5779
|
-
`design_read`)."""
|
|
5780
|
-
proj = self.resolve_project(project, cwd)
|
|
5781
|
-
out = self.designs.plan_read(proj, ref, facet=facet)
|
|
5782
|
-
return {**out, "suggested_deps": self._suggested_deps(proj, out, facets.by_noun(facet).store)}
|
|
5783
|
-
|
|
5784
5643
|
def _suggested_deps(self, proj: str, read: dict[str, Any],
|
|
5785
5644
|
store: str) -> list[dict[str, Any]]:
|
|
5786
5645
|
"""The `link` rows of `_similar` for a read item: live decisions it is
|
|
@@ -5791,87 +5650,22 @@ class Crib:
|
|
|
5791
5650
|
return [{k: r[k] for k in ("relpath", "title", "status", "score", "link")
|
|
5792
5651
|
if k in r} for r in self._similar(proj, rel, store) if "link" in r]
|
|
5793
5652
|
|
|
5794
|
-
async def
|
|
5795
|
-
self,
|
|
5796
|
-
ref: str,
|
|
5797
|
-
new_content: str,
|
|
5798
|
-
project: str | None = None,
|
|
5799
|
-
sources: list[Any] | None = None,
|
|
5800
|
-
cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5801
|
-
"""Rewrite a plan item's body through the facet; result names what it
|
|
5802
|
-
tainted. `sources`, when given, replaces its citations."""
|
|
5803
|
-
return await self.designs.plan_edit(
|
|
5804
|
-
self.resolve_project(project, cwd), ref, new_content, sources, facet=facet
|
|
5805
|
-
)
|
|
5806
|
-
|
|
5807
|
-
async def plan_append(
|
|
5808
|
-
self,
|
|
5809
|
-
ref: str,
|
|
5810
|
-
content: str,
|
|
5811
|
-
project: str | None = None,
|
|
5812
|
-
cwd: Path | None = None,
|
|
5813
|
-
sources: list[Any] | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5814
|
-
"""Extend a plan item's body through the facet; result names what it
|
|
5815
|
-
tainted. `sources` ADDS citations, never replaces."""
|
|
5816
|
-
return await self.designs.plan_append(
|
|
5817
|
-
self.resolve_project(project, cwd), ref, content, sources, facet=facet
|
|
5818
|
-
)
|
|
5819
|
-
|
|
5820
|
-
async def plan_dep_add(
|
|
5821
|
-
self,
|
|
5822
|
-
ref: str,
|
|
5823
|
-
dep_ref: str,
|
|
5824
|
-
project: str | None = None,
|
|
5825
|
-
cwd: Path | None = None,
|
|
5826
|
-
kind: str | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5827
|
-
"""Declare that a plan item depends on another (cycle-checked)."""
|
|
5828
|
-
return await self.designs.plan_dep_add(
|
|
5829
|
-
self.resolve_project(project, cwd), ref, dep_ref, kind, facet=facet
|
|
5830
|
-
)
|
|
5831
|
-
|
|
5832
|
-
async def plan_dep_remove(
|
|
5833
|
-
self,
|
|
5834
|
-
ref: str,
|
|
5835
|
-
dep_ref: str,
|
|
5836
|
-
project: str | None = None,
|
|
5837
|
-
cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5838
|
-
"""Drop a must-precede edge between plan items."""
|
|
5839
|
-
return await self.designs.plan_dep_remove(
|
|
5840
|
-
self.resolve_project(project, cwd), ref, dep_ref, facet=facet
|
|
5841
|
-
)
|
|
5842
|
-
|
|
5843
|
-
async def plan_forget(
|
|
5844
|
-
self,
|
|
5845
|
-
ref: str,
|
|
5846
|
-
force: bool = False,
|
|
5847
|
-
project: str | None = None,
|
|
5848
|
-
cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5849
|
-
"""Delete a plan item; blocks on dependents unless forced."""
|
|
5850
|
-
return await self.designs.plan_forget(
|
|
5851
|
-
self.resolve_project(project, cwd), ref, force, facet=facet
|
|
5852
|
-
)
|
|
5853
|
-
|
|
5854
|
-
async def plan_move(
|
|
5653
|
+
async def graph_move(
|
|
5855
5654
|
self,
|
|
5856
5655
|
ref: str,
|
|
5857
5656
|
after: str | None = None,
|
|
5858
5657
|
before: str | None = None,
|
|
5859
5658
|
project: str | None = None,
|
|
5860
|
-
cwd: Path | None = None, *, facet: str
|
|
5659
|
+
cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5861
5660
|
"""Re-rank a plan item (deps untouched)."""
|
|
5862
|
-
return await self.designs.
|
|
5661
|
+
return await self.designs.graph_move(
|
|
5863
5662
|
self.resolve_project(project, cwd), ref, after, before, facet=facet
|
|
5864
5663
|
)
|
|
5865
5664
|
|
|
5866
|
-
def
|
|
5867
|
-
self,
|
|
5868
|
-
"""The plan in topological, rank-tie-broken order."""
|
|
5869
|
-
return self.designs.plan_list(self.resolve_project(project, cwd), all, facet=facet)
|
|
5870
|
-
|
|
5871
|
-
def plan_next(
|
|
5872
|
-
self, k: int = 5, project: str | None = None, cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
5665
|
+
def graph_next(
|
|
5666
|
+
self, k: int = 5, project: str | None = None, cwd: Path | None = None, *, facet: str) -> dict[str, Any]:
|
|
5873
5667
|
"""The actionable plan items right now (todo, deps satisfied)."""
|
|
5874
|
-
return self.designs.
|
|
5668
|
+
return self.designs.graph_next(self.resolve_project(project, cwd), k, facet=facet)
|
|
5875
5669
|
|
|
5876
5670
|
def code_lookup(
|
|
5877
5671
|
self,
|
|
@@ -6755,6 +6549,126 @@ class Crib:
|
|
|
6755
6549
|
out.append(row)
|
|
6756
6550
|
return out
|
|
6757
6551
|
|
|
6552
|
+
# crib's own facets' names for the graph verbs: the graph_* operation with
|
|
6553
|
+
# the built-in facet filled in (read, list, add and append stay per-facet
|
|
6554
|
+
# until they are one operation each).
|
|
6555
|
+
design_dep_add = functools.partialmethod(graph_dep_add, facet="design")
|
|
6556
|
+
plan_dep_add = functools.partialmethod(graph_dep_add, facet="plan")
|
|
6557
|
+
design_dep_remove = functools.partialmethod(graph_dep_remove, facet="design")
|
|
6558
|
+
plan_dep_remove = functools.partialmethod(graph_dep_remove, facet="plan")
|
|
6559
|
+
design_edit = functools.partialmethod(graph_edit, facet="design")
|
|
6560
|
+
plan_edit = functools.partialmethod(graph_edit, facet="plan")
|
|
6561
|
+
design_export = functools.partialmethod(graph_export, facet="design")
|
|
6562
|
+
plan_export = functools.partialmethod(graph_export, facet="plan")
|
|
6563
|
+
design_forget = functools.partialmethod(graph_forget, facet="design")
|
|
6564
|
+
plan_forget = functools.partialmethod(graph_forget, facet="plan")
|
|
6565
|
+
design_graph = functools.partialmethod(graph_graph, facet="design")
|
|
6566
|
+
plan_graph = functools.partialmethod(graph_graph, facet="plan")
|
|
6567
|
+
design_import = functools.partialmethod(graph_import, facet="design")
|
|
6568
|
+
plan_import = functools.partialmethod(graph_import, facet="plan")
|
|
6569
|
+
design_lookup = functools.partialmethod(graph_lookup, facet="design")
|
|
6570
|
+
plan_lookup = functools.partialmethod(graph_lookup, facet="plan")
|
|
6571
|
+
design_reaffirm = functools.partialmethod(graph_reaffirm, facet="design")
|
|
6572
|
+
plan_reaffirm = functools.partialmethod(graph_reaffirm, facet="plan")
|
|
6573
|
+
design_check = functools.partialmethod(graph_check, facet="design")
|
|
6574
|
+
design_tree = functools.partialmethod(graph_tree, facet="design")
|
|
6575
|
+
design_supersede = functools.partialmethod(graph_supersede, facet="design")
|
|
6576
|
+
design_promote = functools.partialmethod(graph_promote, facet="design")
|
|
6577
|
+
plan_decline = functools.partialmethod(graph_decline, facet="plan")
|
|
6578
|
+
plan_move = functools.partialmethod(graph_move, facet="plan")
|
|
6579
|
+
plan_next = functools.partialmethod(graph_next, facet="plan")
|
|
6580
|
+
plan_park = functools.partialmethod(graph_park, facet="plan")
|
|
6581
|
+
plan_review = functools.partialmethod(graph_review, facet="plan")
|
|
6582
|
+
plan_review_apply = functools.partialmethod(graph_review_apply, facet="plan")
|
|
6583
|
+
plan_status = functools.partialmethod(graph_status, facet="plan")
|
|
6584
|
+
|
|
6585
|
+
# ── read, list, add, append: one operation each (the engine branches on
|
|
6586
|
+
# the facet's trait); crib's own names call them with their facet ────────
|
|
6587
|
+
|
|
6588
|
+
def graph_read(self, ref: str, project: str | None = None, cwd: Path | None = None,
|
|
6589
|
+
*, facet: str) -> dict[str, Any]:
|
|
6590
|
+
"""An item's dossier (Designs.graph_read), plus `suggested_deps`: live
|
|
6591
|
+
items it is close to but doesn't depend on (see `_similar`)."""
|
|
6592
|
+
proj = self.resolve_project(project, cwd)
|
|
6593
|
+
out = self.designs.graph_read(proj, ref, facet=facet)
|
|
6594
|
+
return {**out, "suggested_deps": self._suggested_deps(proj, out, facets.by_noun(facet).store)}
|
|
6595
|
+
|
|
6596
|
+
def graph_list(self, project: str | None = None, cwd: Path | None = None, *,
|
|
6597
|
+
facet: str, tainted: bool = False, all: bool = False) -> dict[str, Any]:
|
|
6598
|
+
"""The facet's items as a working set or an inventory (Designs.graph_list)."""
|
|
6599
|
+
return self.designs.graph_list(self.resolve_project(project, cwd), facet=facet,
|
|
6600
|
+
tainted=tainted, all=all)
|
|
6601
|
+
|
|
6602
|
+
async def graph_add(
|
|
6603
|
+
self, title: str | None = None, content: str = "", deps: list[str] | None = None,
|
|
6604
|
+
project: str | None = None, sources: list[Any] | None = None, cwd: Path | None = None,
|
|
6605
|
+
follows: list[str] | None = None, rests_on: list[str] | None = None,
|
|
6606
|
+
informed_by: list[str] | None = None, *, facet: str, proposed: bool = False,
|
|
6607
|
+
after: str | None = None, before: str | None = None,
|
|
6608
|
+
items: list[dict[str, Any]] | None = None,
|
|
6609
|
+
) -> dict[str, Any]:
|
|
6610
|
+
"""Add one item (or a batch, for an ordered facet), deps validated and
|
|
6611
|
+
`checked` seeded; one item answers with `similar` (see `_similar`). A
|
|
6612
|
+
near-duplicate graph item is worse than a near-duplicate note: it forks
|
|
6613
|
+
the graph, each copy collecting its own dependents."""
|
|
6614
|
+
proj = self.resolve_project(project, cwd)
|
|
6615
|
+
out = await self.designs.graph_add(
|
|
6616
|
+
proj, title, content, deps, facet=facet, sources=sources, proposed=proposed,
|
|
6617
|
+
kinded=_kinded(follows, rests_on, informed_by), after=after, before=before,
|
|
6618
|
+
items=items)
|
|
6619
|
+
if not items and out.get("relpath"):
|
|
6620
|
+
out["similar"] = await asyncio.to_thread(
|
|
6621
|
+
self._similar, proj, out["relpath"], facets.by_noun(facet).store)
|
|
6622
|
+
return out
|
|
6623
|
+
|
|
6624
|
+
async def graph_append(self, ref: str, content: str, project: str | None = None,
|
|
6625
|
+
cwd: Path | None = None, sources: list[Any] | None = None,
|
|
6626
|
+
*, facet: str) -> dict[str, Any]:
|
|
6627
|
+
"""Extend an item through the facet; result names what it tainted.
|
|
6628
|
+
`sources` ADDS citations (post-hoc doc wiring), never replaces."""
|
|
6629
|
+
return await self.designs.graph_append(
|
|
6630
|
+
self.resolve_project(project, cwd), ref, content, sources, facet=facet)
|
|
6631
|
+
|
|
6632
|
+
design_read = functools.partialmethod(graph_read, facet="design")
|
|
6633
|
+
plan_read = functools.partialmethod(graph_read, facet="plan")
|
|
6634
|
+
design_append = functools.partialmethod(graph_append, facet="design")
|
|
6635
|
+
plan_append = functools.partialmethod(graph_append, facet="plan")
|
|
6636
|
+
|
|
6637
|
+
def design_list(self, tainted: bool = False, project: str | None = None,
|
|
6638
|
+
cwd: Path | None = None, *, facet: str = "design") -> dict[str, Any]:
|
|
6639
|
+
"""Every decision as a flat table (`tainted` filters to the stale ones)."""
|
|
6640
|
+
return self.graph_list(project, cwd, facet=facet, tainted=tainted)
|
|
6641
|
+
|
|
6642
|
+
def plan_list(self, all: bool = False, project: str | None = None,
|
|
6643
|
+
cwd: Path | None = None, *, facet: str = "plan") -> dict[str, Any]:
|
|
6644
|
+
"""The plan in topological, rank-tie-broken order."""
|
|
6645
|
+
return self.graph_list(project, cwd, facet=facet, all=all)
|
|
6646
|
+
|
|
6647
|
+
async def design_add(
|
|
6648
|
+
self, title: str, content: str, deps: list[str] | None = None,
|
|
6649
|
+
project: str | None = None, sources: list[Any] | None = None,
|
|
6650
|
+
proposed: bool = False, cwd: Path | None = None,
|
|
6651
|
+
follows: list[str] | None = None, rests_on: list[str] | None = None,
|
|
6652
|
+
informed_by: list[str] | None = None, *, facet: str = "design",
|
|
6653
|
+
) -> dict[str, Any]:
|
|
6654
|
+
"""Record a design decision (see graph_add)."""
|
|
6655
|
+
return await self.graph_add(title, content, deps, project, sources, cwd, follows,
|
|
6656
|
+
rests_on, informed_by, facet=facet, proposed=proposed)
|
|
6657
|
+
|
|
6658
|
+
async def plan_add(
|
|
6659
|
+
self, title: str | None = None, content: str = "", deps: list[str] | None = None,
|
|
6660
|
+
after: str | None = None, before: str | None = None,
|
|
6661
|
+
items: list[dict[str, Any]] | None = None, project: str | None = None,
|
|
6662
|
+
sources: list[Any] | None = None, cwd: Path | None = None,
|
|
6663
|
+
follows: list[str] | None = None, rests_on: list[str] | None = None,
|
|
6664
|
+
informed_by: list[str] | None = None, *, facet: str = "plan",
|
|
6665
|
+
) -> dict[str, Any]:
|
|
6666
|
+
"""Add one plan item, or a whole batch (`items`), ranked at the end unless
|
|
6667
|
+
after/before place them (see graph_add)."""
|
|
6668
|
+
return await self.graph_add(title, content, deps, project, sources, cwd, follows,
|
|
6669
|
+
rests_on, informed_by, facet=facet, after=after,
|
|
6670
|
+
before=before, items=items)
|
|
6671
|
+
|
|
6758
6672
|
|
|
6759
6673
|
def _build_store(
|
|
6760
6674
|
paths: Paths, config: Config
|