diff --git a/frontend/src/api/systems.ts b/frontend/src/api/systems.ts
index 38977203..7e5718f4 100644
--- a/frontend/src/api/systems.ts
+++ b/frontend/src/api/systems.ts
@@ -21,6 +21,12 @@ export interface System {
* everything under it. Empty means the area has not named its files.
*/
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;
/**
* How often this area's rulings were shown to a session because its files
diff --git a/frontend/src/components/SystemsSection.vue b/frontend/src/components/SystemsSection.vue
index 7e4f82f1..655ab197 100644
--- a/frontend/src/components/SystemsSection.vue
+++ b/frontend/src/components/SystemsSection.vue
@@ -80,6 +80,11 @@ function rulingsShown(system: System): number {
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 {
const u = system.usage;
if (!u) return "";
@@ -498,6 +503,12 @@ async function confirmDelete() {
>rulings shown {{ rulingsShown(system) }}×
{{ system.description }}
+
+ rulings not delivered
+ {{ 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.
+
+
{{ pattern }}
@@ -700,6 +711,12 @@ async function confirmDelete() {
.system-form-actions { display: flex; gap: 0.4rem; }
.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
character for character; small because they qualify the card, not lead it. */
.system-paths {
diff --git a/src/grimoire/mcp/tools/projects.py b/src/grimoire/mcp/tools/projects.py
index 2156c458..c95bf817 100644
--- a/src/grimoire/mcp/tools/projects.py
+++ b/src/grimoire/mcp/tools/projects.py
@@ -128,6 +128,12 @@ async def enter_project(project_id: int) -> dict:
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.
+ `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
— Android app, container image, Go, … — each with how it is known
(`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,
"systems": [{"id": s.id, "name": s.name} for s in systems],
+ **_rulings_undelivered(systems),
"platforms": platforms,
"design_system": design_system,
"milestone_summary": milestone_summary,
@@ -366,6 +373,25 @@ async def get_project(project_id: int) -> dict:
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:
"""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
diff --git a/src/grimoire/routes/systems.py b/src/grimoire/routes/systems.py
index 08a0d8f9..6273fcfa 100644
--- a/src/grimoire/routes/systems.py
+++ b/src/grimoire/routes/systems.py
@@ -11,6 +11,7 @@ from grimoire.services import systems as systems_svc
from grimoire.services.access import can_write_project
from grimoire.services.projects import get_project_for_user
from grimoire.services import system_usage as system_usage_svc
+from grimoire.services import system_rulings
logger = logging.getLogger(__name__)
@@ -52,6 +53,9 @@ async def list_systems_route(project_id: int):
d = s.to_dict()
d["open_issue_count"] = counts.get(s.id, 0)
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)
return jsonify({"systems": out})
diff --git a/src/grimoire/services/system_rulings.py b/src/grimoire/services/system_rulings.py
index 9c8a7298..d3c108c6 100644
--- a/src/grimoire/services/system_rulings.py
+++ b/src/grimoire/services/system_rulings.py
@@ -74,6 +74,25 @@ def parse_rulings(description: str | None) -> list[str]:
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:
"""`token` as a repo-relative path, or "" when it is not one."""
if token.startswith("/"):
diff --git a/tests/test_system_rulings.py b/tests/test_system_rulings.py
index 9fe4c76b..4972fbac 100644
--- a/tests/test_system_rulings.py
+++ b/tests/test_system_rulings.py
@@ -239,3 +239,35 @@ async def test_a_write_with_no_prior_art_still_carries_its_areas_rulings():
args, kwargs = rulings.call_args
assert args[2] == ["src/a.py"]
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/**"])]) == {}