Skip to content

feat(acp): support Lody startup settings and scoped provider routes - #2009

Merged
yyhhyyyyyy merged 12 commits into
mainfrom
dimagent/2008-lody-acp-parity
Nov 23, 2026
Merged

yyhhyyyyyy merged 12 commits into
mainfrom
dimagent/2008-lody-acp-parity

Conversation

@zerob13

@zerob13 zerob13 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2008. Fixes #1968.

Summary

  • Apply Lody startup effort alongside the requested model and mode during native creation. Checked load, resume and fork compare provider-default with the supported declaration at their pinned configuration cutoff. Saved Provider preferences do not override that check.
  • Serve providers/list, providers/set and providers/disable through the protected-local Provider management contribution. Advertise the capability when all three operations are available. Keep temporary bindings and credentials in Provider memory, scoped to the Gateway's native connection.
  • Check route ownership for submission, branch creation and Session establishment. Attach checks its original cutoff under admission. Attach and model update restore the prior model under the same admission if they cannot retain the temporary binding. After a restart, ACP can explicitly select a shared catalog model through session/set_config_option before loading or resuming an expired Session. The native update checks expiry under the local Session admission boundary.
  • Fork preserves the configuration at its source cutoff. If the logical Provider is disabled for the caller, or the caller's override differs from the route inherited at that cutoff, the native method refuses before writing a child. To fork under a replacement, first adopt it and select a cutoff that inherits it. The ACP Gateway orders same-connection route writes around new and fork establishment so the native operation and the initial attachment see the same route settings.
  • Keep the ACP model selector on the catalog Provider identity while routing requests under the adopted temporary binding. An applied or still-pending route mutation prevents fallback after a native disconnect. A no-op disable preserves reconnect behavior. Provider list reads a snapshot and can be called after the mutation reply to observe its result.

Design rule checklist

  • The Gateway uses the existing Provider management face. Provider owns validation, routing and cleanup. The Session owns configuration adoption and the fork cutoff.
  • Existing Sessions adopt routes under the Session use gate after every branch has published and dispatched its committed events and has no running turn. Adoption uses the existing configuration path. An in-flight model exchange can settle using the connection it already resolved.
  • The public projection adds an optional catalog Provider ID. Credentials remain in the Provider owner. No Timeline event kind, storage schema, context path or loader row is added.

Verification

  • acp_stdio_lody_config_round_trips_with_the_product_daemon passed with a declared default of medium and a saved preference of low.
  • acp_provider_routes_are_isolated_between_processes_sharing_a_daemon passed. The daemon flow verifies actual loopback requests, model options, route replacement and disable, refusal before child creation, explicit recovery of an expired Session, the unchanged shared Provider record, and a fork whose native reply is held while a route disable is submitted. The test asserts initial attach reaches the daemon first and the SQLite Session count increases by exactly one.
  • temporary_route_adoption_requires_inputs_to_finish_dispatching passed. Native attach refuses route adoption while accepted input is waiting for dispatch and succeeds when the branch is idle.
  • routed_model_update_restores_the_previous_model_on_disconnect passed. An interrupted scoped update restores the shared model before a different connection attaches.
  • acp_stdio_reconnects_after_an_unchanged_provider_disable passed. The Gateway reconnects and can list Sessions after native transport loss following a no-op disable.
  • cargo fmt --all -- --check, git diff --check and the ADR freeze check passed. The PR merge tree applies cleanly to main.

@zerob13 zerob13 changed the title docs(acp): propose Lody startup and extension parity fix(acp): honor Lody startup effort and matching session config Nov 22, 2026
@zerob13 zerob13 changed the title fix(acp): honor Lody startup effort and matching session config feat(acp): support Lody startup settings and scoped provider routes Nov 22, 2026
@zerob13
zerob13 marked this pull request as ready for review November 22, 2026 13:45

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The native creation path is the right place to apply startup preferences, and the two-process routing fixture is useful. Two lifecycle cases still need fixes:

  1. [P2] Make provider-default round-trip through checked attachment. dim-acp/src/lody.rs:87–95 parses the value as Clear. Creation skips the saved effort but still materializes the model's declared default (dim-app-server/src/provider/preferences.rs:11–24). agents/configuration.rs:54–62 then compares that real effort with Clear.value() (None). The same request that created a Session can therefore fail load, resume or fork with session_config_mismatch. Compare the same effective default at the checked cut (or preserve its selection intent) and test a model with a nonempty declared default and a different saved effort.

  2. [P2] Resolve the effective route before creating the fork. The native AgentIndex::fork checks ownership of inherited metadata but creates the child before the ACP gateway prepares its attachment. For an unscoped source whose provider is now disabled, attachment can reject after the child has already persisted (agents.rs:1927–1974, connection/subscription.rs:506–521, gateway.rs:1136–1152). For an already scoped source, scoped_routes.rs:214–246 looks up the rewritten provider ID rather than its logical ID, so later establishment can instead inherit the old route. Define fork routing at the native creation boundary from the inherited logical provider and apply disable/replacement consistently before writing a child. Cover both source states and assert a rejected fork leaves no Session.

Static review only. Exact CI had macOS green, the dependency job red, and Linux still running.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Scope: this adds Lody startup effort and configuration checks plus connection-scoped temporary Provider routes, exposed through ACP providers/list, providers/set and providers/disable. The direction matches the design and the new ACP flows pass, but the route lifecycle has blocking defects.

Verdict: REQUEST_CHANGES.

  1. P1. A routed Session becomes permanently unusable after its connection closes. The Session's adopted configuration stores the route UUID. Connection close removes the route settings and bindings (scoped_routes.rs:165-175). Every operation that could replace the configuration checks ownership of the current one first: attach (subscription.rs:506), session.model.update (connection.rs:1678-1680), fork (agents.rs:1926-1933) and modelFromSession (connection.rs:1927). With the binding gone, scoped_connection_owner returns provider_route_unavailable (scoped_routes.rs:201-204), so attach fails, a model switch fails before its target is considered, and fork fails. Re-running providers/set does not help because scoped_model looks up the route by the logical provider id while the stored model names the old UUID. Failure: an ACP client creates or first loads a Session under a route, the client quits, and the user later opens that Session from the TUI or a restarted ACP client. The Session is listed but cannot be opened, switched or forked; only delete works. This makes the documented explicit-switch recovery at docs/design/acp-gateway-implementation.md:653 unreachable. Fix: let an explicit non-route target, attach or fork replace an expired route, or add an explicit route reset; add an ACP flow that restarts the client and recovers the Session.

  2. P2. Attach can strand a healthy Session when the connection closes during adoption. Attach writes the scoped model with session.configure before it retains the binding (subscription.rs:511-523). retain_startup fails if the close cleanup removed the binding (startup.rs:559-565), and the error is returned without rolling back the configuration fact. session.create already rolls back on this path (connection.rs:1997-2016); attach does not. Failure: an ACP client starts session/load of a shared Session with a route set and disconnects during the configure round trip. The Session is left pointing at an unbound route and cannot be attached again, although the client never saw a successful attach.

  3. P2. Route ownership is not enforced on session.branch.create and is only a counter read for concurrent work. The submit path checks scoped_connection_owner (tree.rs:47-53), but create_branch (tree.rs:703) starts a turn from the inherited configuration without the check, and ProductResolver resolves any startup source from Provider memory without a scope check (provider.rs:3065-3080). Failure: client A sets a route with a private Authorization header and uses it on a Session. Client B calls session.branch.create on that Session with a prompt; the prompt is sent to A's endpoint with A's header and B can read the reply through session.history. No secret value is returned, but the route is not isolated. A concurrent submit accepted just before attach's configure commits can likewise run its turn on the new route because scoped_route_admission only compares the use counter (connection.rs:319-337).

  4. P2. Routed Sessions lose the standard ACP model option. Route adoption replaces model.provider_id with a fresh route UUID (scoped_routes.rs:240-246). The attach reply carries that provider id, and Config::options only advertises the model option when provider.models.query returned the same provider id (config.rs:223-227), which never happens for the UUID. Every routed Session therefore omits the model selector from session/new, load, resume, set_config_option and config_option_update responses, even though the model remains selectable and setting it directly works. Fix: project the logical provider id into the ACP Configuration (the scopedRouteProvider extension already records it) or match the option by model id.

  5. P3. provider_routes_used is set before a mutation succeeds. Any providers/set, including one rejected for invalid params, marks the connection (gateway.rs:703). A later native loss then ends the ACP connection instead of reconnecting (gateway.rs:3144), although no route existed. Set the flag after a successful set or disable.

Verification: the three ACP flows acp_provider_routes_are_isolated_between_processes_sharing_a_daemon, acp_stdio_lody_config_round_trips_with_the_product_daemon and acp_stdio_lody_startup_config_is_applied_before_creation_without_shared_writes pass with the pinned toolchain and an isolated home. cargo run -p xtask -- check passes. Test gaps: no restart/recovery case for a routed Session, no configOptions assertion for a routed Session, no concurrent attach/submit or branch-create isolation case.

CI at this head: verify (linux), macos-native, windows-cli, web and scripts pass. dependencies fails on RUSTSEC-2026-0592 in url 2.5.8, unrelated to this diff, which leaves Cargo.lock unchanged. static-checks and acp-registry are skipped.

Conflicts: origin/main is mergeable at this head. #1911 rewrites the same retain_startup and restore_startup loops in provider/startup.rs and replaces PromptSnapshot reads in agents/configuration.rs; #1909 retires TreeCommands and also touches agents/configuration.rs, agents.rs and connection/tree.rs. This PR's check_configuration and scoped startup filters need integration after either lands. #1916 and #1908 overlap provider.rs, provider-management.md, connection.rs and transport.rs lightly.

Unverified: the app-server integration suites were not run; the restart and branch-create scenarios come from code-path analysis; a Provider row reload also resolves caller.closed and may drop routes without a Native::Lost, which is worth a follow-up check.

Comment thread crates/dim-acp/src/gateway.rs Resolved

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The checked provider-default path now uses the supported declaration at the inherited cutoff, and the native fork rejects sequential disabled/replaced-route cases before persisting a child. The new flow covers those cases.

[P2] Make the fork's route decision survive ACP establishment. The native check in agents.rs:1923–1939 snapshots the connection's current route, then child creation persists independently (:1965–1979). ACP applies provider mutations as independent work (gateway.rs:698–730) and only attaches the child in Work::Created (:1599–1621). If a route is disabled while an ordinary shared-provider fork is in progress, after the native check but before that attach, subscription.rs:506–509 can reject the attach under the new rule. The gateway returns an error without removing the child it just wrote. A retry can leave two children even though only one fork succeeded from the client's perspective. Keep one admitted route decision across the native fork and its initial attach, or remove the just-created child on that failure. Please cover the overlapping mutation in a deterministic lifecycle test and check the durable child count, not just the RPC error.

Static re-review; I did not run the race. Exact hosted checks had Linux, Windows, Web and dependencies green when checked.

@zerob13
zerob13 requested a review from eric8810 November 23, 2026 03:42

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at head 543235a.

The scoped-route design holds up on the parts a security review turns on. A temporary binding is keyed by the caller's connection id and lives only in Provider memory, with a task spawned on first insert that drops every route and connection for that scope when the caller's connection closes or the Provider stops — so a binding cannot outlive the connection that set it, and nothing reaches storage. Admission refuses what it should: Bedrock because a signed provider would bypass the point, a base URL that is not HTTP(S), carries user info, a query or a fragment, control bytes or surrounding whitespace, both an API key and an auth token at once, and any credential with an empty or non-header value. configurable also refuses providers whose credential authority is not Static, so a scoped route cannot repoint a provider whose credential belongs to the managed plan — that is the boundary I would have looked for first. Nothing on these paths logs headers or credentials, and the request types are deny_unknown_fields.

Fork and attach are the subtler half, and the shape the body describes is the right one: check the original cutoff under admission, refuse before writing a child, and restore the prior model if the temporary binding cannot be retained.

Blocking: none.

Checks are green at this head. I read scoped_routes.rs in full, provider/startup.rs's admission and URL normalisation, the ACP providers.rs contribution, and the call sites in connection.rs; I did not read the 263 lines of gateway.rs, the fork/cutoff logic in agents/fork.rs, lody.rs/config.rs, connection/subscription.rs, or the tests, and ran nothing.

Non-blocking:

  • crates/dim-app-server/src/provider/scoped_routes.rs:138 — disable_scoped_route removes the binding only when routing_target still returns a row, so a provider that has since become unconfigurable (disabled in the catalog, or its credential authority changed) keeps its scoped route in memory until the connection closes. Harmless today because nothing reads it, but it is the one path where "disable" can leave a binding behind, and the cleanup task that would have removed it only runs at close.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at head 0706a2e.

The one commit since the head I approved at 543235a1 closes the point I raised there. disable_scoped_route used to remove a binding only when routing_target still returned a row, so a provider that had since become unconfigurable kept its scoped route until the connection closed. It now asks the caller's own bindings first — has_override — and removes the route when one exists there even if the catalog no longer offers the provider, before falling back to the old condition. That is the right order: the binding belongs to the caller, so its presence is what decides whether there is something to remove, and the catalog only answers whether there is something to remove for a caller that never overrode it. The CLI flow case and the provider-management sentence added alongside it keep the behaviour pinned and documented.

The rest of my earlier review stands unchanged: bindings are keyed by the caller's connection and dropped when it closes or the Provider stops, credentials stay in memory and reach no store or log, and admission refuses Bedrock, malformed base URLs, contradictory credentials, and providers whose credential authority is not Static.

Blocking: none.

Checks are green at this head. I read the delta against 543235a1 — the disable_scoped_route hunk, the new flow test's name and the doc line — and relied on the reading recorded at the previous head for the rest; I did not read the flow test body, and ran nothing.

Non-blocking: none.

@zerob13
zerob13 requested a review from eric8810 November 23, 2026 04:36

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at head 133eee1.

The one commit since the head I approved at 0706a2ee tightens the scoped-route admission in the direction that matters: instead of asking only whether a branch is running, it now requires that the branch's input has actually been dispatched — no recorded dispatch failure, no pending publication, dispatched.sequence >= publication.sequence(), and not running. A route adopted while the caller's own input was still queued could have redirected a request the caller had already made, so the barrier belongs where the work starts, not only where it is in flight. Turning the three returns into a single conflict() closure keeps the four conditions telling the same story.

The rest of my earlier review stands: bindings are keyed by the caller's connection and dropped when it closes or the Provider stops, nothing is persisted or logged, admission refuses Bedrock, malformed base URLs, contradictory credentials and providers whose credential authority is not Static, and disable_scoped_route now removes a caller's own override even when the catalog no longer offers the provider.

Blocking: none.

Checks are green at this head. I read the delta against 0706a2ee — the connection.rs admission hunk, the new flow test's presence and the doc line — and relied on the reading recorded at the earlier heads for the rest; I did not read the 57 lines of the new flow test, and ran nothing.

Non-blocking: none.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Scope: round 3 at 133eee1. The net diff against current origin/main is 33 files, and the changes since 93597b4 are the merge of main at 7d92937 plus six commits: 8e8e145 (branch input ownership), cc5d566 (attach rollback), dc7f784 (checked defaults and route lifecycle), 133eee1 (dispatched input before adoption), 0706a2e (disable when the catalog target is unavailable) and 543235a (hold route decisions through initial attachment). The route lifecycle is materially better and three of the five prior findings are fixed, but one prior finding remains open for ACP clients and one route adoption path is still non-atomic.

Verdict: REQUEST_CHANGES.

Prior findings

  1. P1 (expired route recovery): narrowed, still open. scoped_connection_owner now takes recover_shared and returns Ok(true) when the scoped binding is gone (crates/dim-app-server/src/provider/scoped_routes.rs:188-214), and session.model.update uses it for an explicit catalog target while skipping route re-adoption (crates/dim-app-server/src/connection.rs:1687-1699 and 1796-1805). The new test shows a native session.model.update replacing the expired selection with the shared provider, after which an ACP session/resume succeeds (crates/dimcode/tests/cli_flow/acp.rs:4056-4075). Attach still passes false (crates/dim-app-server/src/connection/subscription.rs:506) and fork still passes false (crates/dim-app-server/src/provider/scoped_routes.rs:222), so both still return provider_route_unavailable after expiry. ACP cannot issue session.model.update before a Session is Ready: session/set_config_option requires Slot::Ready (crates/dim-acp/src/gateway.rs:1375), and session/load is the call that fails. The test uses a separate native socket, not an ACP restart. Plain TUI resume also fails; the CLI can recover only with both --provider and --model (crates/dim-cli/src/session_host.rs:797 and 5042). The documentation now states the native-only recovery (docs/design/appserver/provider-management.md:184, docs/design/acp-gateway-implementation.md:653), but the original user scenario, opening a routed Session from a restarted ACP client, still has no path.

  2. P2 (attach atomicity): fixed in code. attach now reconfigures the previous model inside the same admission guard when retain_startup fails (crates/dim-app-server/src/connection/subscription.rs:527-539), mirroring create's delete-on-failure rollback (crates/dim-app-server/src/connection.rs:2020-2039). The sequence re-check before configure (subscription.rs:511-516) and the held gate keep a concurrent writer out. Residual: if the unload token drops the attach future between configure and retain, no rollback runs, but that is daemon unload, where every route expires anyway. There is no test for the retain-failure path.

  3. P2 (branch ownership and admission): fixed. submit now checks ownership even when the branch has no adopted configuration, falling back to session.config().model (crates/dim-app-server/src/connection/tree.rs:47-56); create_branch resolves the inherited configuration at the create cut and checks it (tree.rs:734-744); fork checks the inherited cut (crates/dim-app-server/src/agents.rs:1929-1939). Admission is serialized: SessionUse::admission holds the per-Session gate (agents.rs:198-205), acquire increments the use count while holding that gate (agents.rs:904-980), so adoption either sees another call or blocks it, and scoped_route_admission additionally requires every branch to have published and dispatched its committed events, with no pending input, no failed dispatch and no running turn (connection.rs:319-345). The proxy test proves providers/disable waits for fork plus first attach (crates/dimcode/tests/cli_flow/acp.rs:3945-4035), and the transport test proves that a pending dispatch blocks adoption (crates/dim-app-server/tests/transport_flow/sessions.rs:2277). Gaps: no test calls branch.create or submits a first input from a foreign connection on a routed Session, and ProductResolver still resolves a startup source without a scope check (crates/dim-app-server/src/provider.rs:3122-3138); the boundary checks are now the only guard, which is acceptable for external clients but worth stating.

  4. P2 (ACP model option): fixed. Attach computes catalogProviderId from the scopedRouteProvider extension (crates/dim-app-server/src/protocol.rs:1341, connection/subscription.rs:637-677), the configuration event serializer adds catalog_provider_id (crates/dim-app-server/src/tree_protocol.rs:187-191), and Config::options matches the current model by that logical id (crates/dim-acp/src/config.rs:223-231); set_config_option records the logical id when the reply names a route UUID (config.rs:358-365). Tests assert the model option on session/new (acp.rs:3781) and after recovery through session/resume (acp.rs:4061).

  5. P3 (provider_routes_used timing): narrowed. The flag is now set only after a successful result (crates/dim-acp/src/gateway.rs:1603) and in-flight mutations are counted (gateway.rs:3201), so a rejected providers/set no longer marks the connection. The no-op disable case remains: provider.routes.disable returns Ok for an unknown Provider or a Provider with no override (crates/dim-app-server/src/provider/scoped_routes.rs:137-152), the ACP side sees success and sets provider_routes_used, and a later native loss still ends the ACP connection although no route existed. The test exercises the successful unknown disable (acp.rs:3862) but never a later reconnect.

New findings

  1. P2: session.model.update route adoption is still non-atomic. scoped_model inserts the binding and session.configure commits the route model (crates/dim-app-server/src/connection.rs:1796-1831), then retain_startup runs at line 1837. If the connection closes during the configure await, the close cleanup removes the scope's bindings, retain_startup fails, and the error is returned without restoring the previous model. Unlike attach (rollback) and create (delete on failure), this leaves the Session pointing at an unbound route. Scenario: a client selects a model of a Provider it has routed while the Session is unattached, then disconnects during the configure round trip; the Session is later unopenable although the client never saw a successful update. Fix: mirror the attach rollback in the same admission guard and add a test that closes the connection between configure and retain.

  2. P3: providers/list bypasses route admission and can overtake a pending providers/set or providers/disable on the same connection, because the mutations take the write side of provider_route_admission (gateway.rs:716-724) while list takes no lock and is answered from a separate task. A client that pipelines set then list without waiting can therefore read the old route. If ordering is intended for every provider call, list should take the read side too, or the operations should be answered in request order.

  3. Low: scoped_route_admission now propagates state, publication and dispatch_watch errors with ? (connection.rs:333-343), where the previous version ignored a failed state read. Listed branches are live and ready, so this is low risk, but an error now surfaces as an internal failure instead of a route conflict.

Assessment of the new commits

  • 8e8e145 is correct: it closes the first-turn hole where a branch inherited a route without a configuration snapshot, and it covers create_branch at the inherited cut.
  • cc5d566 is correct for the retain-failure path; the missing test is the main gap.
  • dc7f784 is correct: the catalog provider identity fix is complete across attach, events and set, the native reset works, the checked-default effort semantics match the runtime, and the fork guard refuses a replaced or disabled route before creating a child. The fork guard is intentionally conservative for non-routed Sessions whose Provider has an override; the tests encode that.
  • 133eee1 is correct: requiring no pending publication, no lagging dispatch, no dispatch failure and no running turn closes the acceptance race, and the gate plus use counter serializes new calls.
  • 0706a2e is correct: disabling an existing override no longer depends on the catalog target being available.
  • 543235a is correct: the read guard is held from before native create or fork through the first attach and is dropped on every path, the write side releases before the reply, no lock inversion with the Provider startup mutex was found, and Native::Lost with a pending mutation fails the connection as intended. The stale-generation arm does not decrement pending_provider_routes, but it is unreachable for mutations because that same guard fails the connection first.

Verification

With the pinned Rust 1.100.0 toolchain and an isolated HOME, the targeted suites pass: transport_flow sessions::temporary_route_adoption_requires_inputs_to_finish_dispatching, acp_provider_routes_are_isolated_between_processes_sharing_a_daemon, acp_stdio_lody_config_round_trips_with_the_product_daemon and acp_stdio_lody_startup_config_is_applied_before_creation_without_shared_writes. cargo run -p xtask -- check passes all static checks. The first xtask attempt failed only because a mise cargo wrapper on PATH read a user-level mise config; rerunning with the toolchain bin first passed.

CI at this head: changes, dependencies, windows-cli, web, scripts, verify (linux), macos-native and ci-ok pass; static-checks and acp-registry are skipped. The PR is mergeable and has merged main at 2514b59.

Test gaps

  • No test for attach rollback when retain_startup fails.
  • No test for a foreign branch.create or first submit on a routed Session.
  • No ACP restart flow: the recovery test relies on a native socket.
  • No reconnect test for provider_routes_used, including the successful no-op disable.
  • No configOptions assertion for session/load (resume is covered).
  • No test for the session.model.update retain-failure rollback once it is added.

Merge notes

origin/main merges cleanly. The earlier overlap warnings still apply if #1911 (retain and restore startup loops in provider/startup.rs) or #1909 (TreeCommands retirement, also touching agents/configuration.rs, agents.rs and connection/tree.rs) lands: this PR's check_configuration and scoped startup filters will need integration.

Comment thread crates/dim-app-server/src/connection.rs Resolved
Comment thread crates/dim-acp/src/gateway.rs Resolved

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed 8521f3cd. The fork keeps the route admission through initial native attach, and the earlier checked provider-default and published-but-undispatched input cases remain covered. The latest delta keeps an unchanged disable from falsely making the ACP connection route-dependent, reverts the adopted model if retaining the temporary route fails, and limits ACP recovery to explicitly selecting a shared catalog model for an expired route.

Exact required CI is green. Linux logs show the Lody configuration round trip, two-process route isolation, unchanged-disable reconnect, disconnect rollback, and pending-dispatch admission tests passed. I did not run them locally.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Scope: round 4 at 8521f3c. The net diff against base 2514b59 is 33 files, +2573/-315. Since 133eee1 the change is 13 files, +363/-63: an ACP pre-load model recovery, a rollback for session.model.update route adoption, a state-change signal for provider.routes.disable, and matching docs. All prior blocking findings are fixed. No new blocking defect was found.

Verdict: APPROVE.

Prior findings

  1. P1, expired route recovery: fixed. A restarted ACP client can now repair a routed Session before establishing it. session/set_config_option with configId: "model" for a Session this gateway does not hold enters Config::recover_model (crates/dim-acp/src/gateway.rs:1378-1395), which sends session.model.update with requireExpiredRoute and then reads the adopted configuration back with session.model.get (crates/dim-acp/src/config.rs:291-324). The native gate requires the protected local entry, an explicit provider and model, no startup input, an expired binding, and exclusive idle admission; otherwise it answers provider_route_not_expired or provider_route_conflict (crates/dim-app-server/src/connection.rs:1687-1717, crates/dim-app-server/src/protocol.rs:418-419). The feature is advertised only for the protected local product entry (crates/dim-app-server/src/transport.rs:851-852). The isolation test now restarts the ACP peer rather than using a native socket: it observes provider_route_unavailable from resume, gets provider_route_not_expired for a shared Session, recovers the routed Session through session/set_config_option, and resumes it with the model option (crates/dimcode/tests/cli_flow/acp.rs:4088-4153). Attach and fork still pass recover_shared = false (crates/dim-app-server/src/connection/subscription.rs:506, crates/dim-app-server/src/provider/scoped_routes.rs:224); the pre-load selection is now the documented ACP path (docs/design/acp-gateway-implementation.md:653, docs/design/appserver/provider-management.md:184, docs/design/model-configuration.md:145). Residual: recovery needs the catalog model id, which session/list does not carry (crates/dim-acp/src/gateway.rs:2471-2487), so the client must keep the options it saw before the restart. A plain load or resume without the pre-step still fails, as documented.

  2. P2, non-atomic session.model.update route adoption (thread 4662005876): fixed. When the current route is expired the update takes scoped_route_admission before resolving or configuring the model (connection.rs:1713-1717). If retain_startup fails, or the connection closed during the configure round trip, it configures the previous model back under the same admission and then returns the error (connection.rs:1850-1889). The previous selection is the branch snapshot read before the update, with session.config().model as the fallback. This mirrors the attach rollback and the new contract (docs/design/appserver/provider-management.md:182). The test pauses the configure commit behind a database write lock, closes the routed connection, and asserts that a later attach sees the previous provider and that the branch recorded the route model and then the rollback (crates/dim-app-server/tests/transport_flow/sessions.rs:2334-2417). With the rollback removed locally, the test fails with provider_route_unavailable on attach.

  3. P3, no-op disable marked the connection (thread 4662005881): fixed. provider.routes.disable returns whether it changed the caller's routing state (crates/dim-app-server/src/provider/scoped_routes.rs:132-154, 156-188); an unknown Provider and an already disabled override return false, while a known Provider with no override stores a disabled marker and returns true. The ACP call reads that boolean (crates/dim-acp/src/providers.rs:88-102), and provider_routes_used is set only for a state change (crates/dim-acp/src/gateway.rs:1622-1629). The new test replies false to disable, drops the native connection, and proves the gateway reconnects and serves session/list (crates/dimcode/tests/cli_flow/acp.rs:1269-1315). Setting the flag on any successful mutation makes that test fail with daemon_unavailable.

  4. P3, providers/list ordering: resolved by contract, withdrawn. List still takes no mutation lock, and the design now states that list answers from the routing snapshot at call time and that a client which must confirm a change waits for the set or disable reply (docs/design/acp-gateway-implementation.md:649). That is a documented limitation, not a silent race.

  5. Low, scoped_route_admission error propagation: unchanged and optional. state, publication and dispatch_watch errors still propagate with ? (crates/dim-app-server/src/connection.rs:335-340). The branches are live and ready, so the mapping stays acceptable; no action requested.

Optional notes

  • The recovery flow is tested through resume only; load uses the same attach path and has no recovery assertion. A load with _meta.lody.sessionConfig after recovery would also check the model id, which recovery preserves, but that is not covered.
  • No test exercises session/set_config_option recovery against a Session whose live route belongs to another connection. Native scoped_connection_owner returns provider_route_conflict for it (crates/dim-app-server/src/provider/scoped_routes.rs:190-216), and the resume conflict is covered, but the new ACP entry is not.
  • The rollback restores the previous model read before the admission guard. A concurrent non-route configuration during the failed update would be overwritten by the rollback. The window is narrow and the gateway serializes configuration per Session; no change requested.

Verification

The targeted tests pass with the pinned Rust 1.100.0 toolchain and an isolated HOME: sessions::routed_model_update_restores_the_previous_model_on_disconnect, sessions::temporary_route_adoption_requires_inputs_to_finish_dispatching, acp::acp_stdio_reconnects_after_an_unchanged_provider_disable, acp::acp_provider_routes_are_isolated_between_processes_sharing_a_daemon, acp::acp_stdio_lody_config_round_trips_with_the_product_daemon and acp::acp_stdio_lody_startup_config_is_applied_before_creation_without_shared_writes. Three temporary local reversions confirm the tests guard the fixes: removing the rollback fails the disconnect test with provider_route_unavailable; setting provider_routes_used on every successful mutation fails the reconnect test with daemon_unavailable; removing the ACP recovery block fails the isolation test with Resource not found. cargo run -p xtask -- check passes every static check. The worktree was restored and is clean, and no test process remained.

CI at this head: changes, dependencies, windows-cli, web, scripts, verify (linux), macos-native and ci-ok pass; static-checks and acp-registry are skipped. The PR is mergeable; base is 2514b59 and origin/main is cecf65f.

Merge notes

The prior overlap warnings remain if #1911 (provider/startup.rs) or #1909 (agents.rs, agents/configuration.rs, connection/tree.rs) lands: the checked configuration and scoped startup filters will need integration.

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.

bug(acp): Lody startup metadata rejects the effort option the gateway advertises

3 participants