Repository navigation
fix(platform): fix MCP live runs and prune dead agent and skill paths - #3256
Merged
Merged
Conversation
`run_deployed` and `run_automation {mode: "live"}` on the MCP endpoint and
the chat capability lane enabled live execution (`allowLive: true`) but the
engine has no in-process live path: `lib/connectors/registry.ts` attaches
only a `mock` body to every engine connector and no host ever supplied a
`connectorHost`, so `execute()` always ran the deterministic mocks — and
`recordRun` then persisted the outcome as a mode='live' success with a
provenance audit row, for any membership-only key (no developer gate).
`DispatchContext` now carries `connectorHost`; without one a live
`run_deployed` is handed to the store's durable runner (`startRun`, the
same lane `start_run` uses — the stepper authorizes the actor as developer,
executes connectors live and records the run) and waits a bounded 30 s for
the finished result, answering with the run handle when the run outlives
the wait. `run_automation {mode: "live"}` — an unsaved document, which no
durable runner can take — is refused as data and pointed at run_deployed.
Tool descriptions, the agent guide and the en/de/fr MCP endpoint docs say
so; the integration lane proves run_deployed live settles through the
stepper and a member key is refused before any run row is born.
Finding: builder-skills-agents-1 (= automations-domain-5, lib-engine-1).
The builder session host (`runSessionWithStore`) never forwarded the lib's `isCancelled` seam, so the `cancelled` outcome its type advertises was unreachable in production: a reload, a closed tab or a dropped connection left the server looping model calls (and possibly saving versions nobody would read) until the 7-minute deadline or the turn cap. `BuilderSessionArgs` gains `isCancelled`, forwarded to `runBuilderSession`; POST /automations/builder/sessions passes the request's abort signal, so the session ends `cancelled` at its next turn boundary once the caller is gone. Finding: builder-skills-agents-2.
`GET /api/app/agents/:slug/resolved`, `GET /:slug/history` and `POST /:slug/restore` had no caller from any door a user or integrator can reach: the app hooks that named them (`useAgents`/`useAgent`/ `useAgentHistory`/`useCapabilityCatalog` in `app/features/agents/hooks/ queries.ts`) were imported by nothing — MIGRATION.md inc 123 already recorded the file as importer-less — the REST v1 family exposes only list/get/put/delete, and `lib/agents/resolve.ts` (the tools/skills allowlist predicates) was consumed by no chat, task or automation host. Only the integration check exercised them, so the documented "restore" rule described a feature nobody could use. Removed: the three routes and their `*ForCaller` functions, the resolve module and its test, the history readers (`listAgentHistoryEntries`, `readAgentHistoryText`, `AgentHistoryEntry`), `ResolvedAgentView`, the `AGENT_HISTORY_ENTRY_NOT_FOUND` status row, the dead hooks file, the `agents/actions:listAgentHistory` and `chat/capabilities_action: listCapabilities` contract rows with their adapter, and `configKeys. history`. The on-disk history trail every save writes is untouched; the en/de/fr admin docs now say an operator reaches it on disk and that the API offers no restore. The integration lane proves save/list/edit/delete. Finding: builder-skills-agents-3.
larryro
force-pushed
the
fix/skills-agents-builder-hardening
branch
from
September 5, 2026 22:19
86f30ab to
50d0717
Compare
Four exports survived their last consumer and misled readers about behaviour that no longer exists: - `lib/shared/constants/agents.ts` carried seven retired Auto-router constants (`AUTO_AGENT_SLUG`, `ROUTER_AGENT_SLUG`, `RESERVED_AGENT_SLUGS`, `PROTECTED_AGENT_NAMES`, `DEFAULT_CHAT_AGENT_SLUG`, the conversation starter caps) whose comments promised a reserved-slug check `saveAgent` never performs; only `SUPPORTED_AGENT_LOCALES` has consumers and stays. - `handler_names.ts` declared `skills.upload_mutations.deleteSkillUploadIntent` with no shim handler and no caller — a call would have thrown as un-shimmed; the reachability gate only checks referenced names. - `lib/skills/visibility.ts#filterVisibleSkills` and `core/agent_secrets/constants.ts#hasInteriorWhitespace` (whose docstring described an editor warning no code delivers) were used only by their own tests. Knip is blind to all four because `backend/**` entries keep the modules reachable; the type-check is the guard. Findings: builder-skills-agents-4, -5, -6, -7.
`upsertAgentSecret` was check-then-act inside its transaction: SELECT the row (no lock), then UPDATE or count-and-INSERT. Two concurrent first saves of one name — a double submit, a retry, two admins — both passed the SELECT, the loser hit UNIQUE (org_id, name) and its PostgresError 23505 fell through `handleError` to the global handler as a reported 500; two creates at cap-1 both passed the count, so the per-org cap was soft. The write is now ONE `INSERT … ON CONFLICT (org_id, name) DO UPDATE … RETURNING (xmax = 0) AS created`, so racing saves converge on one row and the caller learns which outcome landed; the cap check runs under a per-org advisory xact lock and counts only the OTHER names, so a full org can still rotate a secret it already holds. The audit action follows the row that landed. Finding: builder-skills-agents-9.
The bundle-upload lane read the existing skill, computed `bundleExists`, checked edit rights and derived the owner BEFORE taking the per-(org, slug) writer lock, and only the final write ran inside it — unlike the editor's save, whose checks run under the same lock. Two members uploading the same new slug both observed "no bundle": neither got `needs_confirm`, the second write replaced the first and rewrote its owner — exactly the silent replacement the needs_confirm/force protocol exists to prevent. The whole decision now runs inside `withSkillWriterLock` (the lock is held for a directory read and a rename, so a refusal holds it for nothing); the staged blob is released in a `finally` on every path, and only the write itself is still mapped to WRITE_FAILED. The regression test runs two concurrent uploads of one new slug through a serializing `begin` and expects one write and one `needs_confirm`. Finding: builder-skills-agents-10.
…need With the seven retired Auto-router constants gone, every remaining export of `lib/shared/constants/agents.ts` has a consumer, and knip reports the ignore entry as obsolete. Removing it lets knip watch the file again. Finding: builder-skills-agents-4 (sweep).
larryro
marked this pull request as ready for review
September 5, 2026 22:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes for the
builder-skills-agentstheme of the backend fix campaign (Automations builder, skills, agents). Seven commits onfix/skills-agents-builder-hardening; no migration.Findings fixed
run_deployed/run_automation {mode:"live"}ran the deterministic mocks yet persisted a mode='live' success + audit row for any membership-only key; a liverun_deployednow goes through the durable runner (startRun, developer-authorized, bounded 30 s wait, run handle when it outlives the wait),run_automation {mode:"live"}is refused as data; tool descriptions + en/de/fr MCP docs updated; itest lane extended (6bc72587d).isCancelled; POST /automations/builder/sessions now passes the request abort signal so an abandoned request endscancelledat its next turn boundary (5eb465874).GET /:slug/resolved,GET /:slug/history,POST /:slug/restore+lib/agents/resolve.ts, history readers,ResolvedAgentView, the importer-lessapp/features/agents/hooks/queries.ts, theagents/actions:listAgentHistory+chat/capabilities_action:listCapabilitiescontract rows/adapter,configKeys.history; docs en/de/fr History bullet reworded (trail stays on disk, no restore door); itest lane trimmed to save/list/edit/delete (50d07178e).SUPPORTED_AGENT_LOCALESkept; the now-obsolete knip ignore entry dropped (000aa1369,2c138bd39).skills.upload_mutations.deleteSkillUploadIntenthandler-name declaration with no shim handler removed (000aa1369).filterVisibleSkillsremoved (000aa1369).hasInteriorWhitespaceremoved (000aa1369).upsertAgentSecretis oneINSERT … ON CONFLICT (org_id, name) DO UPDATE … RETURNING (xmax = 0) AS createdunder a per-org advisory xact lock; the cap counts only the other names (a full org can still rotate); regression test with a scriptedsql(a9e783321).withSkillWriterLock, blob cleanup infinally; regression test runs two concurrent uploads of one new slug through a serializingbeginand expects one write + oneneeds_confirm(fc18f5901).Skipped
(none)
Tests & gates observed
bunx tsc --noEmit→ exit 0bunx oxlint --type-aware→ exit 0 (no output)bun run check(worktree root) →Tasks: 40 successful, 40 total—@tale/platform:lint: Found 0 warnings and 0 errors.;@tale/platform:test:ui: Test Files 456 passed (456) / Tests 3512 passed (3512);@tale/shared:test: Test Files 22 passed (22)bun run knip:check→ exit 0 (remaining hintcron-parser … Remove from ignoreDependenciesis pre-existing on main)backend/core/agents backend/domains/agents lib/agents→ 4 files / 61 tests passed;backend/domains/agent_secrets backend/domains/skills backend/core/skills→ 7 files / 90 tests passedrun-itest.sh):[itest] 475/476 checks passed across 134/134 lanes— the one FAIL iswebdav re-home (protocol + tree + locks + visibility on pg), the pre-existing red lane on main (webdav theme). Theme lanes:PASS agents file layer (save/list/edit/delete),PASS blob-ref authority: skill upload consumes its own intent…,PASS platform MCP endpoint (/api/v1/mcp) — … runDeployed=live/success/row=true, memberLive=refused/noRun=true …,PASS automation builder session (scripted model, pg store).Notes for the reviewer
git push --force-with-leaseof my own just-pushed tip, minutes after the first push; no other history rewrite.agents/actions:listAgents/getAgentcontract rows and the/api/app/agentslist/get/put/delete routes: they are the app door the itest and REST v1 parity rely on; only the doors with no reachable caller were removed. The on-disk.history/trail every save writes is untouched.RETURNING (xmax = 0) AS createdis the standard insert-vs-update tell forON CONFLICT DO UPDATE; the fake-sqltest pins the statement shape, the real-Postgres itest exercises the door.origin/main(3997f6a) pergit merge-tree.