Skip to content

bug: post-deploy system endpoints — schedules silently dropped (nonexistent DB method), ungated restart, export round-trip breakage, prefix-collision membership #2373

Closed

Description

@vybe

Summary

The four post-deploy system endpoints (GET /api/systems, GET /api/systems/{name}, POST /api/systems/{name}/restart, GET /api/systems/{name}/manifest) are essentially untouched since the original 2025 implementation, while every commit since ent#124 hardened the deploy half (ent#125/#126, #1884, ent#314, ent#89). A review pass found four verified defects on those endpoints plus two cheap preview hardenings that belong in the same PR.

Defects

1. GET /api/systems/{name} silently drops the schedules key — nonexistent DB method.
routers/systems.py:251 calls db.get_agent_schedules(agent['name']). DatabaseManager exposes list_agent_schedules and get_agent_schedules_summary — there is no get_agent_schedules and no __getattr__ fallback (database.py documents this deliberately). The AttributeError is swallowed by the except Exception a few lines below, so every response omits schedules for every agent and logs one warning per agent. tests/test_systems.py never asserts on the key, so CI is green. This is exactly the mocked-database-module failure mode the db facade's own comment warns about.

2. POST /api/systems/{name}/restart has no role gate.
The route is gated on bare get_current_user (routers/systems.py:274), while POST /deploy and even the read-only bundled-catalog routes are require_role("creator"). Any authenticated principal — including role: user, and agent-scoped MCP keys (which resolve to their owner carrying the owner's role) — can stop/start every container in any system whose agents it can see. Unlike POST /api/agents/{name}/start it also skips enforce_agent_spawn_scope. A mutating fleet-wide verb sitting below the gate of the read-only catalog is an oversight, not a decision. Fix: require_role("creator") (which now rejects agent principals per #1890) at minimum; confirm whether per-agent start/stop authorization should also apply per member.

3. export_manifest round-trip breakage (two related defects).

  • The non-full-mesh permissions branch in services/system_service.py slices target_agent[len(system_name)+1:] with no startswith(f"{system_name}-") filter — the sibling explicit-permissions branch has one. A permission edge pointing outside the system exports as a blind-sliced garbage short name, which then fails validate_manifest's "unknown agent in permissions" check on re-deploy → 400. Round-trip broken.
  • The export injects the instance-global trinity_prompt setting as the manifest's prompt:. Deploying that exported manifest on another instance overwrites that instance's platform-wide prompt. Nothing records whether the source system ever set a prompt, so the honest fix is to stop exporting the global prompt entirely.

4. Membership matching by name prefix collides across systems.
get_system, restart_system, and export_manifest all match agents via startswith(f"{system_name}-") — so operations on system acme also capture every agent of a system named acme-extra. list_systems' split-on-hyphen derivation means the bundled 11-agent vc-due-diligence manifest does not round-trip through its own list endpoint (it groups under vc-due-diligence-dd), hyphen-less agents are dropped entirely, and any hyphenated standalone agent becomes a phantom system (trinity-system → system "trinity"). Deploy already applies the system name as a tag on every member (configure_tags), so membership should prefer the system tag with the prefix as fallback for pre-tag deployments.

Hardenings (same PR)

5. Per-agent unknown-key warnings. parse_manifest reads five specific per-agent keys and silently drops everything else — agents.x.credentials:, agents.x.skills:, agents.x.display_label: all vanish with no warning, while top-level unknown keys already warn (ent#126). This is precisely the set of fields users try first. ~15-line fix.

6. Preview/deploy resource-default drift. _preflight_template validates against the admin-configurable settings_service.get_agent_default_resources() while deploy_manifest hardcodes {"cpu": "2", "memory": "4g"} when the manifest declares no resources. The one spot that escaped ent#126's pure-resolver no-drift pattern.

Acceptance Criteria

  • GET /api/systems/{name} returns real schedules for agents that have them, with a test asserting on the key (not just 200).
  • POST /api/systems/{name}/restart is require_role("creator")-gated; an agent-scoped key is rejected; test pins both.
  • Export → validate → re-deploy round-trips green with a cross-system permission edge present (edge dropped or scoped, never blind-sliced).
  • Exported manifests no longer embed the instance-global prompt.
  • get_system/restart_system/export_manifest key membership on the system tag with prefix fallback; operations on acme provably never touch an acme-extra agent.
  • Unknown per-agent manifest keys surface as preview warnings, mirroring the existing top-level behavior.
  • Preview and deploy resolve the identical resource default (single source).
  • docs/memory/feature-flows/system-manifest.md updated (its line references are also stale).

Technical Notes

  • All defects live in src/backend/routers/systems.py and src/backend/services/system_service.py; the deploy path itself (parse/validate/preview/deploy/seed) is healthy and out of scope here.
  • Fix fix: add missing logging_config.py to backend Dockerfile #4's tag-based membership is also the prerequisite for the upcoming system teardown verb (tracked separately), so the predicate should land as one shared helper, not per-endpoint copies.
  • list_systems' derivation defects are fully fixed only by persisting deployed systems (a larger, separate design); within this issue the goal is that tag-based membership makes get/restart/export correct, and list_systems at least stops mis-grouping tagged systems.

Activity

  1. added
    priority-p1
    type-bug
    theme-reliability
    complexity-medium
    status-ready
    on Aug 21, 2026
  2. dolho commented on Aug 27, 2026

    @dolho
    Contributor

    /claim

  3. added
    status-in-progress
    and removed
    status-ready
    on Aug 27, 2026
  4. github-actions commented on Aug 27, 2026

    @github-actions

    Claimed by @dolho. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/2373-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #2373
  5. 12 remaining items

  6. added a commit that references this issue on Sep 17, 2026
  7. removed
    status-in-dev
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-mediumpriority-p1theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions