feat(8205): a System with rulings and no file patterns is flagged
CI & Build / TypeScript typecheck (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 0s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s

Its rulings reach no session: delivery is by path_patterns alone. enter_project
carries rulings_undelivered (absent when none) with the fix call, the Systems
list reads ruling_count, and the System card says so with a button to name
its files. A System without rulings is not flagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 17:49:24 -05:00
co-authored by Claude Opus 5.5
parent 98a959de4f
commit 3e87df6c84
6 changed files with 104 additions and 0 deletions
+6
View File
@@ -21,6 +21,12 @@ export interface System {
* everything under it. Empty means the area has not named its files. * everything under it. Empty means the area has not named its files.
*/ */
path_patterns: string[]; path_patterns: string[];
/**
* How many rulings the description carries. With no `path_patterns`,
* none of them is delivered: rulings reach a session when a command or
* edit touches the area's files. Present on the list read only.
*/
ruling_count?: number;
open_issue_count: number; open_issue_count: number;
/** /**
* How often this area's rulings were shown to a session because its files * How often this area's rulings were shown to a session because its files
@@ -80,6 +80,11 @@ function rulingsShown(system: System): number {
return system.usage?.surfaced_count ?? 0; return system.usage?.surfaced_count ?? 0;
} }
/** Rulings with no files to deliver them on: none reaches a session. */
function rulingsUndelivered(system: System): boolean {
return (system.ruling_count ?? 0) > 0 && system.path_patterns.length === 0;
}
function rulingsTitle(system: System): string { function rulingsTitle(system: System): string {
const u = system.usage; const u = system.usage;
if (!u) return ""; if (!u) return "";
@@ -498,6 +503,12 @@ async function confirmDelete() {
>rulings shown {{ rulingsShown(system) }}×</span> >rulings shown {{ rulingsShown(system) }}×</span>
</div> </div>
<p v-if="system.description" class="system-description">{{ system.description }}</p> <p v-if="system.description" class="system-description">{{ system.description }}</p>
<p v-if="rulingsUndelivered(system)" class="system-undelivered">
<span class="usage-tag usage-dead">rulings not delivered</span>
{{ system.ruling_count === 1 ? "Its ruling reaches" : `Its ${system.ruling_count} rulings reach` }}
no session: a ruling is shown when a session touches the area's files, and this area names none.
<button type="button" class="btn-text" @click="startEdit(system)">Name its files</button>
</p>
<ul v-if="system.path_patterns.length" class="system-paths" aria-label="Files"> <ul v-if="system.path_patterns.length" class="system-paths" aria-label="Files">
<li v-for="pattern in system.path_patterns" :key="pattern" class="system-path">{{ pattern }}</li> <li v-for="pattern in system.path_patterns" :key="pattern" class="system-path">{{ pattern }}</li>
</ul> </ul>
@@ -700,6 +711,12 @@ async function confirmDelete() {
.system-form-actions { display: flex; gap: 0.4rem; } .system-form-actions { display: flex; gap: 0.4rem; }
.system-paths-input { font-family: var(--fs-font-mono); font-size: 0.8rem; } .system-paths-input { font-family: var(--fs-font-mono); font-size: 0.8rem; }
.system-undelivered {
margin: var(--fs-space-2) 0 0;
font-size: var(--fs-size-body-sm);
color: var(--fs-text-secondary);
}
/* The area's files. Mono because they are paths to be read /* The area's files. Mono because they are paths to be read
character for character; small because they qualify the card, not lead it. */ character for character; small because they qualify the card, not lead it. */
.system-paths { .system-paths {
+26
View File
@@ -128,6 +128,12 @@ async def enter_project(project_id: int) -> dict:
create it with create_system rather than leaving the area unmodelled. Read create it with create_system rather than leaving the area unmodelled. Read
a subsystem's accumulated records with list_system_records. Each is id and name; get_system has the charter. a subsystem's accumulated records with list_system_records. Each is id and name; get_system has the charter.
`rulings_undelivered`, present only when it applies, lists Systems that
carry rulings but name no files. A ruling reaches a session when a
command or edit touches its System's files, so these rulings reach
nobody. Name each area's files with
`update_system(id, path_patterns=[...])`, globs from the repo root.
`platforms` is what the project is built on or ships as `platforms` is what the project is built on or ships as
— Android app, container image, Go, … — each with how it is known — Android app, container image, Go, … — each with how it is known
(`declared` by a person, `detected` from a bound repo). They decide which (`declared` by a person, `detected` from a bound repo). They decide which
@@ -281,6 +287,7 @@ async def enter_project(project_id: int) -> dict:
}, },
"pattern_coverage": coverage_svc.coverage_line(coverage) if coverage else None, "pattern_coverage": coverage_svc.coverage_line(coverage) if coverage else None,
"systems": [{"id": s.id, "name": s.name} for s in systems], "systems": [{"id": s.id, "name": s.name} for s in systems],
**_rulings_undelivered(systems),
"platforms": platforms, "platforms": platforms,
"design_system": design_system, "design_system": design_system,
"milestone_summary": milestone_summary, "milestone_summary": milestone_summary,
@@ -366,6 +373,25 @@ async def get_project(project_id: int) -> dict:
return data return data
def _rulings_undelivered(systems) -> dict:
"""`{"rulings_undelivered": {...}}` when some System's rulings reach no
session, else nothing: the key is absent, not empty, so its presence is
the signal."""
from grimoire.services import system_rulings
missing = system_rulings.undelivered(systems)
if not missing:
return {}
return {"rulings_undelivered": {
"systems": missing,
"why": (
"A System's rulings are shown when a command or edit touches its "
"files. These name no files, so their rulings reach no session."
),
"fix": "update_system(id, path_patterns=[...]) with the area's files as globs from the repo root",
}}
def _inception_choices(design_system_id, seed_systems, platforms=None) -> dict | None: def _inception_choices(design_system_id, seed_systems, platforms=None) -> dict | None:
"""The tool args → an inception choices object, or None when no inception """The tool args → an inception choices object, or None when no inception
arg was given at all (a bare create stays undecided and enter_project arg was given at all (a bare create stays undecided and enter_project
+4
View File
@@ -11,6 +11,7 @@ from grimoire.services import systems as systems_svc
from grimoire.services.access import can_write_project from grimoire.services.access import can_write_project
from grimoire.services.projects import get_project_for_user from grimoire.services.projects import get_project_for_user
from grimoire.services import system_usage as system_usage_svc from grimoire.services import system_usage as system_usage_svc
from grimoire.services import system_rulings
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -52,6 +53,9 @@ async def list_systems_route(project_id: int):
d = s.to_dict() d = s.to_dict()
d["open_issue_count"] = counts.get(s.id, 0) d["open_issue_count"] = counts.get(s.id, 0)
d["usage"] = usage.get(s.id, system_usage_svc.empty_system_usage()) d["usage"] = usage.get(s.id, system_usage_svc.empty_system_usage())
# Read beside the patterns: rulings and no files means none of them
# is ever delivered (`system_rulings.undelivered`).
d["ruling_count"] = len(system_rulings.parse_rulings(s.description))
out.append(d) out.append(d)
return jsonify({"systems": out}) return jsonify({"systems": out})
+19
View File
@@ -74,6 +74,25 @@ def parse_rulings(description: str | None) -> list[str]:
return out return out
def undelivered(systems) -> list[dict]:
"""The Systems whose rulings reach no session: they carry rulings and
name no files, so nothing a session touches falls under them.
Delivery is by `path_patterns` alone, so such a System's rulings are
never shown on an edit or a command, and nothing else says so. A System
without rulings has nothing to deliver and is not listed. One entry per
System: `{"id", "name", "rulings"}`, rulings being how many.
"""
out = []
for system in systems:
if system.path_patterns:
continue
count = len(parse_rulings(system.description))
if count:
out.append({"id": int(system.id), "name": system.name, "rulings": count})
return out
def _relative(token: str, root: str, cwd_rel: str) -> str: def _relative(token: str, root: str, cwd_rel: str) -> str:
"""`token` as a repo-relative path, or "" when it is not one.""" """`token` as a repo-relative path, or "" when it is not one."""
if token.startswith("/"): if token.startswith("/"):
+32
View File
@@ -239,3 +239,35 @@ async def test_a_write_with_no_prior_art_still_carries_its_areas_rulings():
args, kwargs = rulings.call_args args, kwargs = rulings.call_args
assert args[2] == ["src/a.py"] assert args[2] == ["src/a.py"]
assert kwargs["seen"] == [9] and kwargs["source"] == "rulings_write_path" assert kwargs["seen"] == [9] and kwargs["source"] == "rulings_write_path"
# ── a System whose rulings reach nobody ───────────────────────────────────
def _system(sid, *, description, patterns):
return SimpleNamespace(id=sid, name=f"Area {sid}", description=description,
path_patterns=patterns)
RULED = "What it does.\n\n## Rulings\n\n- **One decision** (operator, a date).\n- **Another.**\n"
def test_a_system_with_rulings_and_no_files_is_named_as_undelivered():
systems = [
_system(1, description=RULED, patterns=[]),
# Files named: its rulings are delivered on them.
_system(2, description=RULED, patterns=["src/area/**"]),
# No rulings: nothing to deliver, so nothing to flag.
_system(3, description="What it does.", patterns=[]),
]
assert sr.undelivered(systems) == [{"id": 1, "name": "Area 1", "rulings": 2}]
def test_enter_project_carries_the_flag_only_when_a_system_needs_it():
from grimoire.mcp.tools.projects import _rulings_undelivered
flagged = _rulings_undelivered([_system(1, description=RULED, patterns=[])])
assert flagged["rulings_undelivered"]["systems"] == [{"id": 1, "name": "Area 1", "rulings": 2}]
assert "update_system" in flagged["rulings_undelivered"]["fix"]
# Absent, not empty, when every ruled System names its files.
assert _rulings_undelivered([_system(2, description=RULED, patterns=["src/**"])]) == {}