← Back to Pull requests

fix(acp): persist model catalogs and scope discovery per agent #6197

Closed
unknown closed this pull request without merging on Oct 23, 2026 09:44 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 12:08 UTC
Author

Summary

Opening a new draft after more than 60 seconds or a Host/application restart previously launched another ACP discovery process. Successful neutral-discovery catalogs now persist across drafts and restarts.

  • Keep public catalogs separate from conversation-specific models, selections, and modes. Project A cannot overwrite project B's public choices; real sessions validate their own configuration.

  • Bind snapshots to configuration and executable/helper metadata. Version 2 rejects potentially session-contaminated version 1 snapshots. Every successful neutral probe saves current metadata, including when the model list is unchanged.

  • Scope discovery, loading, invalidation, and retry per agent. Transient refresh failures retain previous choices; cold failures have a 60-second retry cooldown. Explicit refresh and setup/login invalidation discover changes without a periodic timer.

  • Preserve serialized probes, invalidation fencing, writes, and cleanup ownership while removing redundant bookkeeping and persistence caches.

  • Synchronize the Astryx surface inventory for the model picker's Spinner.
  • Performance benefits and trade-offs

    This change primarily improves model-picker readiness and reduces discovery subprocess churn. It does not accelerate model inference, and real conversation initialization still validates its own model and mode.

    | Optimization | Benefit | Trade-off / current limitation |
    | --- | --- | --- |
    | Reuse successful catalogs without a 60-second TTL, including across Host restarts | Reopening a draft can use memory or a persisted snapshot instead of launching and disposing another ACP process. Warm memory reads do no storage I/O. | Catalog freshness becomes event/manual driven. Remote model changes and account switches performed outside Maka can leave stale choices until refresh or invalidation. Executable/helper metadata is checked on snapshot load and successful probe persistence, not on every memory hit; an in-place installation change is not detected immediately by a running cached executor. |
    | Load and refresh catalogs per Agent | A fast Agent can become selectable before a slow Agent finishes. Targeted retries and setup invalidation avoid re-probing unrelated Agents. | A draft now requests an inventory followed by one request per Agent: roughly N + 1 requests instead of one batched request. This can cost more when every catalog is warm, especially over a remote Host connection. Discovery still shares a two-probe FIFO budget, so cold Agents can still queue; this does not increase probe concurrency. |
    | Preserve the last good catalog on transient refresh failure; cool down cold failures | Existing choices remain usable during temporary discovery failures, and repeated draft reads do not continually restart a failing Agent. | Cached choices are advisory and may later fail real Session validation. A cold failure can delay an automatic retry for up to 60 seconds; expiry only permits a later read to retry, with no scheduled retry. If a good catalog was retained after a failed refresh, ordinary reads keep returning it with refreshFailed; another explicit refresh or invalidation is needed to re-probe. Explicit retry bypasses the cooldown. |
    | Keep neutral catalogs separate from real Session capabilities | Project-specific models, defaults and modes cannot overwrite the public choices shown in other drafts. | A real Session may expose different choices and require reselection. Even if a task has already initialized successfully, the first uncached draft still needs its own neutral probe. Draft discovery does not warm or replace the real conversation process. |
    | Persist versioned snapshots bound to configuration and executable/helper metadata | Compatible restarts reuse validated snapshots; missing, corrupt or incompatible records fall back to discovery. | The first load adds a storage read and metadata checks, and successful probes add persistence work. Derived labels/groups/defaults depend on a manually maintained CATALOG_SNAPSHOT_VERSION; adapter or normalization changes require a version bump. Binary/configuration fingerprints do not automatically detect those code-only changes. |
    | Revalidate ready Session pickers silently | Periodic inspection and Session events no longer flash the loading indicator for an already usable picker. | The existing 3-second Session polling remains. This improves presentation stability, not polling traffic or inference latency. |

    A controlled local comparison of ff74d21c8 and 0bcb095a used the repository's real stdio test Agent, ACP SDK and subprocess lifecycle on an Apple M4 Pro with Node 24.18.1 (3 warmup rounds, 30 measured rounds). Median catalog reads after the old TTL elapsed changed from 97.98 ms to 0.006 ms; executor recreation with a valid file-backed snapshot changed from 98.61 ms to 0.52 ms. Both scenarios went from 30 probe process starts to zero across the measured rounds. First uncached discovery and forced refresh remained about 98 ms.

    These are discovery-layer measurements, not end-to-end application speedups: the TTL boundary was simulated by advancing the clock, restart was executor recreation rather than a full Host/app restart, and persistence used a JSON file rather than the Host database. Electron IPC/UI and authenticated official Agents were not measured. The remote-Host cost of the additional per-Agent requests remains unquantified.

    Verification

  • Synced with main (f7fd46469) and advanced the protocol epoch to 228, preserving main's epoch-227 ShellRun event-wait changes.

  • Passed the protocol epoch guard against current main and all 17 guard regression tests.

  • Passed full build:test, full workspace typecheck, repository-wide lint and formatting checks, and the staged ASF header check.

  • Passed 260 focused catalog, persistence, executor, protocol, goal-protocol, Desktop IPC, selection, and model-picker regression tests.

  • Passed Astryx surface inventory and Windows test inventory checks (including 3 inventory tests).

  • The earlier Storybook assertion fixes passed CI on 0bcb095a; the synchronized head triggers a fresh CI run.

  • Full workspace suites and official-binary acceptance were not rerun locally. An earlier full ACP attempt stalled at a real stdio checkpoint test and was stopped. Historical official Antigravity inference returned a location-eligibility HTTP 403, so full question/answer execution remains unverified.
  • Compatibility

    Runtime Host compatibility epoch increases from 227 to 228 for executor inventory/filter queries; update Desktop and Host together. Missing, corrupt, or incompatible snapshots fall back to neutral discovery.

    AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • OpenAI Codex implemented the changes, regression tests, documentation, and local verification. Follow-up commits include a Generated-by: Codex trailer.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and affected tests pass within the verification scope above
  • Does this PR entail a change in behavior?

  • Yes — described above

  • No
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: me2seeks Review duration: 4176m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6197"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository