feat(studio): coordinate integrated AI activity and internal language services
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

Start project-owned language and authenticated MCP services when opening a
project, reusing the embedded LSP backend without a desktop TCP listener.
Keep editor overlays separate from saved-file MCP queries.

Reserve conflicting editing before ACP prompt delivery and retain protection
through native/tool termination, runtime cleanup and document refresh. Preserve
drafts on rejected admission, provide cleanup/preparation recovery, distinguish
terminal outcomes and redact permission previews.

Add lifecycle, language parity, activity, composition and UI regressions and
update the canonical Studio contracts. Keep distribution update alignment as
the separate WRK-002A follow-up.

Validation: complete make -C tooling verify PASSED in
20261127T035822Z-ec5d9266 (1172 unit, 131 compiler fixture, 31 headless tests).
Opt-in real-model and native AI-view qualification are outside that gate.

Work: WRK-0029; decision: DEC-0001.
This commit is contained in:
2026-11-27 09:58:57 +00:00
parent 802a13a6aa
commit e6542df56e
46 changed files with 1485 additions and 180 deletions
@@ -23,7 +23,7 @@ initialization exchange negotiates that supported revision; no compatibility
with other revisions or deprecated HTTP+SSE transport is claimed. An offered
unsupported revision receives the supported revision in `InitializeResult`.
Each desktop start generates a new instance identity. Each human project grant
Each desktop start generates a new instance identity. Each successful project opening
publishes a fresh 256-bit bearer credential scoped to that canonical project root.
Every HTTP request MUST include `Authorization: Bearer <credential>`; missing,
wrong or revoked credentials return 401. Initialized HTTP sessions MUST be bound
@@ -113,7 +113,7 @@ file/permissions, stale credentials/instance, catalog incompatibility and transp
reconnection. Calls cannot wait indefinitely for a grant. No reconnect path may
resubmit a tool call. An uncertain response MUST retain available clientRequestId
correlation and instruct receipt lookup within the same authorized task. A new
desktop/task has no old receipt registry and requires a fresh human grant.
desktop/task has no old receipt registry and requires a fresh integrated activity or explicit legacy external grant.
Connector-generated uncertain-outcome errors carry that correlation in
`error.details.clientRequestId`, within the advertised output schema; the text
content block MUST serialize the identical structured envelope.
@@ -180,9 +180,9 @@ prove authorization.
The authority levels in the packaged catalog are:
- `authenticated`: connection authentication only; project/context/reference reads
need no acquired task. HTTP access still requires the project credential published by human grant. Offline catalog discovery returns no task token.
- `granted`: acquisition validates the prior human grant and atomically creates
the sole task identity. The transport session ID is not that identity.
need no acquired task. HTTP access still requires the credential published for the open project. Offline catalog discovery returns no task token.
- `granted`: acquisition returns the existing admitted integrated task, or validates
a prior human external grant and atomically creates the sole external task identity. The transport session ID is not that identity.
- `task`: `projectRoot` and `taskId` must identify the current acquired task.
Revalidate before admission, lookup and deduplication, including read-only LSP.
@@ -241,8 +241,11 @@ SDK/library scope. No query applies filesystem edits.
### 3.1 Language Query Operations
`studio_language_query` uses the existing project's LSP server via a real client,
not a parallel language implementation or a direct call into compiler semantics.
`studio_language_query` uses the project-owned internal language workspace and
existing embedded LSP implementation. It MUST NOT require a TCP endpoint,
`.studio/lsp.json`, JSON-RPC launcher or parallel compiler implementation in the
integrated desktop. Editor clients consume a neutral typed language port; LSP4j
and compiler classes remain application/provider details.
Its successful value is `{operation, result, limitations}`. `result` is the JSON
projection of the existing LSP response (including null or an empty list when
appropriate); LSP union wrappers are unwrapped. Provider classes remain inside
@@ -306,26 +309,29 @@ with `prepareCallHierarchy(uri, position)`, then use a returned opaque `itemId`
`incomingCalls` or `outgoingCalls`. Returned hierarchy items may supply new `itemId`
values for further traversal. Item IDs cannot be invented from symbol names or URIs.
The application lifecycle supplies each open project's bound loopback LSP
endpoint. Studio uses OS-assigned ports so different open projects do not compete
for one fixed port. The public LSP configuration default remains unchanged for
other hosts. A manifest language change requires reopening that project's server;
the adapter MUST NOT send queries to a server bound to another language/root.
Opening any desktop project, including the Play shell, MUST start its internal
language workspace; close MUST stop it. A manifest language change requires
reopening; root/language and generation MUST be checked before dispatch and
publication. Closing/reopening or switching projects MUST fence late results and
expire task/source/hierarchy handles. A standalone TCP host MAY retain its own
transport; it is not part of the integrated composition.
Each query uses a short-lived client connection. For physical document requests, the
adapter opens exactly the saved UTF-8 text and waits for that connection's
published diagnostics before issuing the semantic query. Other dependency files
are read from disk by the existing compiler bridge. A fresh connection prevents
reuse of stale overlays from previous requests or the human editor. Unsaved or
concurrent external writes remain the developer's responsibility.
Each MCP request uses the saved UTF-8 document and dependencies. Editor queries
use a separate snapshot of open versioned overlays, including imported documents;
MCP task release MUST NOT clear editor buffers. Conflicting/obsolete versions and
results from superseded editor snapshots MUST be rejected. Refactoring returns
proposals without applying edits. Saved primary-file revision changes during a
query MUST invalidate its result. No long-lived compiler cache is required;
assets, dependency/configuration and saved-file changes are read by fresh analysis.
Queries require the current task, share the project's work admission/cancellation
and DEV operation observation, and do not silently queue behind conflicting work.
Return/reclaim invalidates the task immediately, waits for worker termination,
then clears task-local hierarchy items before manual control is restored. Item
IDs from another task or project cannot be used. Client sockets/listeners close
on success, failure, timeout or cancellation; project-server shutdown closes its
accepted sockets and executor. A lost client does not independently grant control.
Queries require the current task, share the project's admission/cancellation and
operation observation, and do not silently queue behind conflicting task work.
Internal compiler execution MUST run outside FX, serialize per project and use
bounded queues, execution and cleanup response budgets. A timeout/cancel response
MUST NOT be interpreted as worker termination. Return waits for actual termination,
then clears task-local hierarchy/source handles. Project close cancels requests,
rejects queued work and retains incomplete cleanup for retry. Editor and saved
views MUST NOT share mutable document maps or task authority.
The adapter bounds connect time to 2 seconds within the shared 10-second admission-relative execution budget, followed by a 2-second cleanup response window;
Core bounds the request worker wait to 12 seconds. Documents are limited to 4 MiB
@@ -424,7 +430,10 @@ the registry, replays an advance or recovers authorization.
`TaskTools` is the neutral service surface; MCP only validates schemas and projects
its results. The Core implementation admits work through `AutomationSession.submit`
and the existing operation executor, sharing DEV's busy state and cancellation.
Acquisition requires the prior human grant. Release reports `MANUAL` only after
Integrated acquisition returns the coordinator-admitted task; external acquisition
requires the prior human DEV grant. Integrated release does not independently
unlock editing; the activity coordinator owns finalization. Legacy release reports
`MANUAL` only after
managed cleanup and document refresh succeed; cleanup failures remain explicit.
Admission and request registration are atomic per project. Deduplication uses the
@@ -549,7 +558,7 @@ reference provider, not a Studio-maintained language specification.
`studio_project_context` resolves an exact, canonical root registered by an open
project session. It does not use the focused window, accept a source-directory
path as a project root, acquire a manual lease, or acquire task authority. The HTTP boundary separately requires the grant-published project credential. A session
path as a project root, acquire a manual lease, or acquire task authority. The HTTP boundary separately requires the open-project credential. A session
is discoverable only after successful opening and until closure begins.
Unregistered/closed roots return `PROJECT_NOT_OPEN`.
@@ -620,7 +629,7 @@ IDs or hashes when created, modified or removed. Regeneration MUST remove
previously copied transient resources. The installed example MUST remain
compilable and packable outside the source checkout without a preexisting cache.
`studio_reference_read` is authenticated but does not require an acquired task; the transport still requires a grant-published project credential. It resolves the explicit open root and its current saved manifest selection
`studio_reference_read` is authenticated but does not require an acquired task; the transport still requires a open-project credential. It resolves the explicit open root and its current saved manifest selection
on every read. Changing SDK/target can invalidate previously advertised IDs.
Only IDs in that project's installed index can be read, including when other
languages/providers are installed globally. SDK and external-library texts remain
@@ -739,7 +748,9 @@ port as scaffold and DEV retry. Desktop composition MUST start the shared loopba
server before project sessions become available; no external command or separate
per-project desktop Run is required. Explicitly disabled integration MUST remain
disabled. Preparation failure MUST remain visible in DEV readiness without blocking
project use. Opening MUST NOT publish credentials or grant/acquire agent control.
project use. Opening MUST publish project-scoped MCP access independently of task authority.
It MUST NOT reserve assets or start an AI task. Preparation/connection failure MUST
remain observable and retryable without claiming ACP login implies tool readiness.
The coding client continues to own its configured stdio process and initial trust.