Skip to content

fix(systems): bare-naming edge cases: key rule, naming-aware membership, declared-only reports (#4131) - #4150

Merged
vybe merged 14 commits into
devfrom
feature/4131-bare-naming-edges
Nov 1, 2026
Merged

vybe merged 14 commits into
devfrom
feature/4131-bare-naming-edges

Conversation

@vybe

@vybe vybe commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #4131. Three naming: bare edge cases in the systems service: a manifest key accepts what the platform's own name producers write; membership is naming-aware, so a declared bare name is adopted whatever its shape and a prefix lookalike of a bare system is never restarted, read or exported as a member; and apply reports a deploy: false member whose live agent restart or teardown would reach. Stacked on #4146 — base is feature/4129-systems-list-bare; the stack merges together in order. Draft until validated.

What

Rulings carried (plan file)

  • Key rule: the create route's charset. Adopt a declared bare name regardless of shape (the requirements sentence that pinned the refusal was a default, not a ruling). Report plus docs for case 3. Option D for membership (infer bare from the tags as export does); the residual (a doubly hand-edited system under-restarts one member) is accepted and documented. Both modes for the key rule.

Review + security

/review (report-only): MERGEABLE, 0 critical. Fixed in 00db2598f: the prefixed-mode declared-only honesty gap (new report code), the undocumented other-direction residual (warning clause and flow-doc sentence), the missing shared-agent test. /cso --diff: 0 findings. Fix mutation: 25 of the new tests red with the service reverted.

Tests

Targeted: 305 passed across the new file and seven guard suites; after the fix 106 passed on the three touched suites. MCP suite 1,113 pass. Not run here: the full unit island (CI runs it once the stack is retargeted to dev).

Before merge

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

Handoffs

#4130 (apply and deploy result truth) stacks on this branch; #4134 owns the service refactor.

🤖 Generated with Claude Code

Trinity Agent (trinity) and others added 11 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]>
…-only out of the evidence gate (#4131)

Case 1: a manifest key accepts the create route's charset ([a-z0-9_.-],
chained `_N` suffixes included) in both naming modes, so an exported
`writer_2` / `acme-writer_2` member parses again; every other bad key keeps
the named 400. The drift note recognises chained copies.

Case 2: `system_membership(naming=)`. Apply passes the manifest's naming;
under `bare` membership is the tag (the tag read still runs, so an outage
still refuses). With no naming (restart, get, export) bare is inferred as
export infers it: tags readable and every tagged member unprefixed. A
prefixed system keeps the #2373 union. A declared untagged bare name is
adopted whatever its shape; an undeclared untagged `<system>-x` is neither
member, drift nor blocker.

`deploy: false` names are excluded from the evidence gate in both modes.

test_2373: the renamed-member case now carries a tagged prefixed member
(the union property), and the accepted residual is pinned beside it.

Mutation: with the service change reverted, 21 tests in
test_4131_bare_naming_edges.py / test_2373 go red; restored, all green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t, restart route tests, docs (#4131)

Case 3: `deploy: false` governs apply only. When a declared-only name is a
roster member by tag, apply adds the report `declared_only_member_tagged`
naming restart and teardown and the hand untag remedy; nothing is written.

The adoption warning names the explicit `?naming=bare` export when an
adopted name starts with `<system>-` (a default export infers prefixed).

Restart and get route tests run the real routes over the real db facade:
a bare member is handled, an untagged prefix lookalike and another
system's tagged member are not; a prefixed system still restarts its
untagged member; the tagged declared-only member is restarted, as the
report says.

Docs: the requirements sentence that pinned the refusal now states the
adopt rule; declared-only and the tag; flow-doc paragraphs with the one
accepted residual; user doc; MCP restart/export text for the inferred-bare
rule.

Mutation: with this checkpoint's service change reverted, the case-3
report test and the warning test go red; restored, all green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…agent test (#4131)

- In a prefixed system an untagged `<system>-x` declared-only member is a
  member by name, so restart and teardown reach it. Apply now says so with
  the report `declared_only_member_prefixed` (no write). Mutation: with the
  new branch disabled, TestPrefixedDeclaredOnlyUntagged goes red.
- The adoption warning names the other-direction residual: a bare system
  with a prefix-shaped tagged member is read as prefixed by restart,
  teardown, get and export, so an untagged lookalike is reached by name.
  The flow doc says the same.
- Plan test 13: a tagged declared-only agent that is only shared with the
  caller gets no apply report, and restart still reaches it.

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: #4150 - fix(systems): bare-naming edge cases: key rule, naming-aware membership, declared-only reports (#4131)
Author: vybe
Branch: feature/4131-bare-naming-edges → feature/4129-systems-list-bare (stacked on #4146)
Files Changed: 7 (+622/-15) · validated at 00db2598f against the stacked base 25598647f, not against dev
Lane: B (backend service + MCP tool text; tests/ carries deletions — one #2373 guard re-rostered), no schema flag

Summary

Category Status Notes
Commit Messages ✅ 3 conventional fix(systems): … commits, each names what and why
Base Branch ✅ stacked on #4146 by design; the stack retargets to dev in order (#4145 → #4146 → this)
PR Size ✅ 7 files
Status Auto-Promotion ✅ Fixes #4131 in the body
Roadmap ✅ #4131 open, priority-p3 / type-bug; carries status-ready rather than status-in-progress (cosmetic)
Requirements ✅ requirements/roadmap.md — Bare adoption and Declared-only entries updated for the new behaviour and reports
Architecture ➖ no endpoint, schema or topology change
Feature Flows ✅ feature-flows/system-manifest.md gets a "Naming-aware membership and the bare edge cases" section, both residuals included
Feature Flow Format ➖ section added to an existing flow
Security Check ✅ §4.1–4.3, 4.5 clean; the only @ hit is @pytest.fixture
Infrastructure ➖ none
Build Packaging ➖ no new top-level backend directory
Config Packaging ➖ no new env read
File Modes / Host Paths ✅ no mode flip, no symlink, no host path
Structural Review ✅ author's /review (MERGEABLE, 0 critical, findings fixed in 00db2598f) and /cso --diff (0 findings) are recorded in the PR body
Merge Gate ⚠️ see Warnings: the backend pytest (head) + regression diff contexts do not run on a stacked base
Test Adequacy ✅ named regression file test_4131_bare_naming_edges.py over the real routes; every fix point mutation-tested red (below)
Code Quality ✅ focused; one membership predicate kept, naming kwarg is apply-only and AST-pinned
Requirements Trace ✅ each change maps to one of the three cases in #4131
Product Fit ✅ rulings (key charset, adopt a declared bare name whatever its shape, option D membership, report + docs for declared-only members) carried as the operator's; OSS core
Product Bar 7–11 ✅ MCP restart_system / get_system_manifest text updated beside the route (every door); user doc + flow + requirements updated; remedy in the new notes names a real route (DELETE /api/agents/{name}/tags/{tag}) and a real tool (untag_agent)

Documentation Checklist

  • Commit messages are descriptive
  • Roadmap (issue linked with closing keyword)
  • Requirements updated
  • Architecture updated (not applicable)
  • Feature flow updated
  • Feature flows index (not applicable, no new flow)

Security Checklist

  • No API keys or tokens
  • No real email addresses
  • No IP addresses
  • No .env files
  • No hardcoded secrets
  • No credential files
  • Infrastructure changes justified (none)

Execution coverage (§5.4)

Run here: the new file + test_2373_system_endpoints.py → 85 passed; every system / manifest / ent1030 / 4129 / 2373 unit suite (29 files) → 775 passed.

changed symbol / test file executed by live consumer verdict
MANIFEST_KEY_RE TestCase1SuffixedKeysReparse (export → parse round trip, both modes; producer output; named refusal kept) system_service.py:348 validate_manifest ✅
system_membership(naming=…) + bare inference TestMembershipNaming, TestRestartAndGetOverABareSystem, property test, updated #2373 tests routers/systems.py:357/508/575 via system_member_names; apply system_service.py:2959 ✅
apply passes manifest.naming TestCase2BareAdoptsWhateverTheShape (dry run + real run) read_apply_snapshot ✅ — wiring also pinned by test_only_the_apply_snapshot_passes_a_naming (AST guard: the caller set is the thing pinned)
declared-only excluded from evidence gate TestDeclaredOnlyOutOfTheEvidenceGate read_apply_snapshot gate loop ✅
declared_only_member_tagged / _prefixed TestCase3DeclaredOnlyTagged (incl. the shared-agent case), TestPrefixedDeclaredOnlyUntagged _plan_declared_only ← resolve_apply_plan:3919 ✅
chained _N drift note test_the_drift_note_still_names_a_chained_copy resolve_apply_plan drift ✅
adopted-warning export hint TestAdoptedWarningNamesTheBareExport resolve_apply_plan warnings ✅

Fix PR mutation — each fix point reverted on its own in the PR worktree, suite = new file + #2373:

mutation result
key regex back to [a-z0-9-] 4 failed
bare inference removed 5 failed
apply stops passing naming 4 failed
declared-only gate exclusion removed 3 failed
_tagged report disabled 1 failed
_prefixed report disabled 1 failed
drift regex back to single _\d+ 1 failed
adopted export hint removed 1 failed

Worktree restored clean after each.

Product fit (Step 6.6)

check verdict evidence
Approved (not incubating) ✅ #4131 type-bug, priority-p3, no status-incubating
Scope ↔ issue ✅ no new route, tool, setting or env key. Two new report codes (declared_only_member_tagged, declared_only_member_prefixed) cover case 3 ("report plus docs"); key rule covers case 1; adoption + naming-aware membership cover case 2
Open-core tier ✅ OSS core, the same tier as the manifest engine it amends
Doctrine ✅ none: reports only, no new write path, no prompt-only permission
Bar 7–11 ✅ —

Issues Found

Critical (Block Merge)

  • None.

Warnings (Review Required)

  • Tier 1 is incomplete while the PR is stacked. The backend pytest (head, seed 12345) and regression diff contexts (and the CodeQL Analyze contexts) did not run against the feature/4129-systems-list-bare base. Every context that did run is green (schema-parity, verify-non-root, prod-image-smoke, MCP build + unit, gitleaks, guards). The 775-test system slice is green locally, but the full unit island is not. Before merge: once #4145 and #4146 land and this retargets to dev, wait for Tier 1 to go green, regression diff included. dev-ci on dev is currently success.
  • Accepted residual, documented, not a defect. Under option D a hand-edited system can be misread in either direction: a prefixed system whose tagged members all lost the prefix while another lost its tag under-restarts that one member, and a bare system with a prefix-shaped adopted member reads as prefixed outside apply. Both directions are in the flow doc, the #2373 residual test and the adoption warning.

Suggestions (Optional)

  • #4131 still carries status-ready. Moving it to status-in-progress keeps the on-merge promotion consistent.

Recommendation

APPROVE

The diff matches #4131 and the rulings carried on it. Each fix point is executed by a named test that goes red when that fix is reverted. Membership still has one predicate, with the apply-only naming caller set pinned. Docs, requirements and MCP text move with the code. The only open gate is the backend Tier 1 run, which is structural to the stack and must be green after the retarget to dev, before merge.

@vybe
vybe changed the base branch from feature/4129-systems-list-bare to dev November 1, 2026 21:25
@vybe
vybe merged commit e82a188 into dev Nov 1, 2026
28 checks passed
@vybe
vybe deleted the feature/4131-bare-naming-edges branch November 1, 2026 21:44
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