Skip to content

fix(systems): list systems by their tag with an evidence rule, never by a name split (#4129) - #4146

Merged
vybe merged 9 commits into
devfrom
feature/4129-systems-list-bare
Nov 1, 2026
Merged

vybe merged 9 commits into
devfrom
feature/4129-systems-list-bare

Conversation

@vybe

@vybe vybe commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #4129. GET /api/systems lists systems by the tag the deploy and apply paths store on every member, with an evidence rule, never by splitting agent names on a hyphen. Stacked on #4145 — base is feature/4128-system-detail-export; the stack merges together in order. Draft until validated.

What

  • routers/systems.py list_systems: one batched tag read over the caller's accessible agents; a tag is listed as a system when a member is named <tag>-*, the auto-created system view exists for it, or a system_apply audit row names it. Members are the roster agents carrying the tag; a system never appears to a caller who cannot open any member. The tag read and the evidence reads each fail to a named 503 (except HTTPException: raise keeps the outer handler from turning it into a 500). created_at is the earliest member's created, newest first, name order on a tie.
  • MCP list_systems description corrected (it claimed a "first hyphen" rule the code never had) and the teardown_system warning reworded: take a system name from a deploy or apply result, or confirm it with the detail route.
  • tests/unit/test_4129_systems_list_bare.py: nine tests over the real route and the real database facade; the bare system in test 1 comes from a real apply, so its audit row is real evidence. Flow doc rewritten for the list endpoint, including the accepted gap and the retention note.

Rulings carried (plan file)

Review + security

/review (report-only): MERGEABLE, 0 critical. Fixed in 000b979c6 and 25598647f: the flow doc section that still described the prefix split, a test for the evidence-read 503, a stale assertion message. Noted: one audit query per plain tag (#4143); audit retention can prune a bare system's only evidence (stated in the flow doc). /cso --diff: partial without Docker, 0 findings. Mutation: 7 of 8 tests red with the old route; the plain-tag test red without the evidence filter.

Tests

Targeted backend: 59 passed (with the #4128 and #2373 suites); earlier combined run 102 passed. MCP suite: 1,113 pass. Not run here: the full unit island (CI).

Before merge

Merge #4145 first. No migration, no image rebuild.

Handoffs

#4131 (bare-naming edges in restart, teardown and membership) stacks on this branch; #4143 is the durable deploy record.

🤖 Generated with Claude Code

Trinity Agent (trinity) and others added 8 commits November 1, 2026 01:15
…rough real facade methods (#4128)

GET /api/systems/{name} called db.get_agent_permissions and
db.get_agent_folder_config, neither of which exists on DatabaseManager,
inside one try: permissions, folders AND schedules were absent for every
member. The exporter's folder read had the same missing name and
subscripted the pydantic row as a dict, so `folders` was never exported;
its permission block probed agents[0] only, so a system whose first
member had no outgoing edge exported no edges.

- get_system: one try per key; edges via get_permitted_agents narrowed
  to the caller's accessible roster (what the direct permissions route
  shows); folders via get_shared_folder_config by attribute.
- export_manifest: folders via get_shared_folder_config, a failed read
  named in `# unobserved:`; permission block computed in one pass over
  every member, filtered to members, full-mesh only over >= 2 keyed
  members (tag-only members are outside the universe).
- KNOWN_FACADE_GAPS loses get_agent_folder_config and
  get_agent_permissions; the 2373 raising=False stub and the 1759
  MagicMock stub that supplied the missing method now name the real one.

Mutation: with routers/systems.py and services/system_service.py
reverted to the base, 11 of 13 tests in test_4128_system_detail_export.py
and test_every_db_call_resolves_on_databasemanager go red; restored
byte-identical (sha256 checked).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GET /api/systems split every accessible agent's name at its last hyphen
and called the left part a system: a naming: bare member was dropped,
content-writer invented a `content` system, and acme-api-worker landed
in `acme-api`. The list now reads the system tag deploy and apply write
(one batched get_tags_for_agents read over the caller's roster), lists
the roster agents that carry it, and lists a tag only with evidence it
is a system: the auto-created system view for it, a system_apply audit
row naming it, or a carrier named `<tag>-*`. A plain tag is not listed.
Unreadable tags (or evidence) are a named 503, kept a 503 past the outer
handler. created_at is filled from the roster's `created` field, so the
newest-first sort works.

Mutation: with list_systems reverted, tests 1-6 and 8 of
test_4129_systems_list_bare.py go red (7 is a ruling pin, green on the
old code); dropping `except HTTPException: raise` reds test 6; listing
every tag reds test 7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…4129)

The MCP list_systems description stated the removed rule (group by the
part before a hyphen); it now says the list names systems deployed or
applied from a manifest, by their tag, and that a plain tag is not one.
The teardown_system warning is kept and reworded to match. The flow doc's
GET /api/systems line and the teardown-panel sentence follow, and name the
accepted gap: a bare-named system created by POST /deploy with no
system_view and never applied leaves no evidence, so it is not listed
until deploy records that its tag is a system.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e allowlist entry (#4128)

The GET /api/systems/{system_name} section of the system-manifest flow
still named db.get_agent_permissions/get_agent_folder_config/
get_agent_schedules, none of which the handler calls; it now names
get_permitted_agents (narrowed to the caller's accessible set),
get_shared_folder_config, list_agent_schedules and the per-key try.
get_agent_schedules has no caller left, so it leaves KNOWN_FACADE_GAPS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The flow doc's detailed GET /api/systems section and its System Grouping
section still described the old last-hyphen split; both now state the tag
evidence rule (roster tag read, three evidence kinds, members from the
roster, the two named 503s, created_at). The gap sentence also names audit
retention pruning a bare system's only evidence.

Test 9 makes the system-view read and the audit read raise and asserts the
named 503. Red with the inner 503 replaced by a bare re-raise (both cases
fell through to the outer 500); green with the route restored byte-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The assertion message still said GET /api/systems groups by the last hyphen.
Message text only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@trinity-ability trinity-ability left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Validation Report

PR: #4146 - fix(systems): list systems by their tag with an evidence rule, never by a name split (#4129)
Author: vybe
Branch: feature/4129-systems-list-bare (2559864) → feature/4128-system-detail-export (a9f3b66, stacked on #4145)
Files Changed: 5 (+349/-80), validated against the stacked base, not dev
Lane: B (src/backend/routers/systems.py, src/mcp-server/src/tools/systems.ts), no schema flag, no deleted lines in tests/

Summary

Category Status Notes
Commit Messages ✅ 5 commits, conventional fix(systems): + one stack merge
Base Branch ✅ Stacked on #4145's branch on purpose; retarget to dev once #4145 lands
PR Size ✅ 5 files
Status Auto-Promotion ✅ Fixes #4129 in the body (same repo)
Roadmap ✅ #4129: P2, type-bug, status-ready
Requirements ➖ Bug fix
Architecture ➖ Response shape unchanged, no new endpoint
Feature Flows ✅ system-manifest.md: list endpoint, Entry Points, Not built note and System Grouping rewritten. The accepted gap (#4143) and the retention caveat are stated
Feature Flow Format ✅ Existing flow, required sections present
Security Check ✅ §4.1–4.10 clean (the two @ hits are @pytest.fixture). Enterprise-docs guard pattern: no hit
Infrastructure ➖
Build Packaging ➖ No new top-level backend directory
Config Packaging ➖ No new env reads
File Modes / Host Paths ✅ None
Structural Review ✅ /review ran on the branch (report-only, MERGEABLE, 0 critical); its three fixes are in 000b979c6 and 25598647f. It was summarised in the PR body, not posted as a review
Merge Gate ⚠️ See Warnings: Tier 1 pytest (head), regression diff and CodeQL have not run, because the base is not dev
Test Adequacy ✅ Named regression file test_4129_*; non-happy paths covered (both 503s, plain tag, roster scoping)
Code Quality ✅ Focused; matches the existing system-view marker check in system_service
Requirements Trace ✅ Each acceptance criterion maps to a test (below)
Product Fit ✅ Operator ruling on the evidence rule; tier is OSS core; #4143 is the accepted gap
Product Bar 7–11 ✅ MCP list_systems / teardown_system text updated in the same PR; plain-word 503s; flow doc

Execution coverage (§5.4)

changed symbol / test file executed by live consumer verdict
routers/systems.py::list_systems test_4129_systems_list_bare.py tests 1–9 (real route via TestClient over the real db facade; a real POST /apply writes the audit evidence in test 1). Only the Docker roster is seamed GET /api/systems, src/mcp-server/src/tools/systems.ts:342 ✅
systems.ts description text systems.teardown.test.ts (CI Build (typecheck) + unit green) MCP tool registry ✅ (guard)

Fix PR mutation (run locally against the head, 10 tests):

mutation result
old route restored from base 9 failed
evidence filter dropped (every tag listed) 1 failed (test 7)
system_apply audit evidence dropped 2 failed
system-view description check dropped 1 failed (test 7)
except HTTPException: raise removed 3 failed (503 → 500)

Run in the PR worktree: the 10 new tests pass, and 79 pass with the #4128, #2373 and resilient-deploy suites added.

Product fit (Step 6.6)

check verdict evidence
Approved (not incubating) ✅ #4129 status-ready, type-bug
Scope ↔ issue ✅ No new route, tool or setting. AC1: a bare system lists under its own name with its real members → test 1. AC2: prefixed systems still list → test 3. AC3: a bare member with a - → test 1 (content-writer), and test 3 covers the hyphenated short name
Open-core tier ✅ OSS core, by operator ruling
Doctrine ✅ None broken. Members ⊆ the caller's roster, so the global view and audit reads can promote a tag but never add a name
Bar 7–11 ✅

Issues Found

Critical (Block Merge)

  • None

Warnings (Review Required)

  • Tier 1 has not run on this PR. Because the base is a feature branch, the dev-filtered workflows did not trigger: pytest (head), regression diff and Analyze. What did run is green: typecheck + MCP unit, gitleaks, guards, schema-parity, verify-non-root, prod-image-smoke. After #4145 merges and this PR retargets to dev, Tier 1 must be green before merging. dev-ci is currently success.
  • Known cost: each tag that has no <tag>-* carrier and no system view costs one audit query per call. This is accepted until #4143.

Suggestions (Optional)

  • src/frontend/src/components/systems/SystemTeardownPanel.vue:182 (outside this diff) still says GET /api/systems "groups agents by their last hyphen". That is now stale. The guidance to type the name or confirm it still holds, but the reason given is wrong. A one-line comment fix can go here or in #4131.

Recommendation

APPROVE. The route now lists systems by their tag under the evidence rule. Every branch of the rule, both 503s and the HTTPException pass-through are pinned by tests that go red under mutation, and the MCP text matches the new behaviour. Merge after #4145, once Tier 1 is green against dev.

@vybe
vybe merged commit 7571f30 into dev Nov 1, 2026
27 checks passed
@vybe
vybe deleted the feature/4129-systems-list-bare branch November 1, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants