feat(studio): integrate project MCP setup and lifecycle
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
Test / Build skipped: 15, passed: 926
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

This commit is contained in:
2026-09-29 19:24:28 +01:00
parent 97cf5e1919
commit d0737df0ac
48 changed files with 2048 additions and 225 deletions
@@ -79,7 +79,7 @@ The main session-restoration store MUST NOT include:
- heavy operational output;
- recomputable results that do not represent session restoration state.
Under DEC-0060, automation grants, task/control identities, active runtime sessions and the task-local operation/deduplication registry MUST NOT be persisted or restored through `.studio/state.json` or `.studio/setup.json`. Reopening a project MUST start under manual control. Restoring DEV as the selected workspace is presentation restoration, not permission to resume work. MCP connection credentials MUST NOT be stored in versioned files; they are regenerated on Studio restart. See the [DEV and Automation Specification](10.%20DEV%20and%20Automation%20Specification.md).
Under DEC-0060, automation grants, task/control identities, active runtime sessions and the task-local operation/deduplication registry MUST NOT be persisted or restored through `.studio/state.json` or `.studio/setup.json`. Reopening a project MUST start under manual control. Restoring DEV as the selected workspace is presentation restoration, not permission to resume work. MCP connection credentials MUST NOT be stored in versioned files; they are regenerated for every project grant and never restored on restart. See the [DEV and Automation Specification](10.%20DEV%20and%20Automation%20Specification.md).
`Project-local activity` and project-local setup may still live under `.studio/`, but they are separate persistence concerns and not part of the main session-restoration store defined here.
@@ -105,3 +105,36 @@ This specification is complete enough when:
- accepted and excluded categories are explicit;
- load, restore, save, and fallback timing are explicit;
- and the ownership boundary with `StudioProjectSession` is normatively locked.
## Integrated MCP Discovery (DEC-0061)
`.studio/setup.json` MUST carry neutral `agentIntegration` intent with
`schemaVersion:1`, `enabled` and `clientProfile`. Preserve runtime and editor
fields. This intent is configuration, not readiness or authorization. Machine-local
resolved client configuration is a separate preparation output.
The transient descriptor is `.studio/mcp/connection.json`, limited to 16 KiB.
Schema v1 requires integral `schemaVersion:1` and nonempty string `instanceId`,
`projectRoot`, `endpoint`, `credential`, `catalogFingerprint`. Root MUST match the
connector's canonical root. Endpoint MUST be `http://127.0.0.1:<port>/mcp`, with
no userinfo, query, fragment or redirect. Grant/task IDs and receipts are forbidden.
On macOS `.studio/mcp` MUST be owned by the current user with mode 0700;
descriptor, lock and temporary files MUST be 0600 before secrets are written.
Reject symlinked/unsafe paths and tracked descriptor targets. Add precise ignore
rules idempotently without changing unrelated project permissions or files.
Ownership MUST use an OS-held lock on the stable `publication.lock` inode; do
not delete the lock file on ordinary cleanup. A second live publisher fails. A
crashed process releases its lock through the OS; a new owner may atomically
replace stale content. Write a protected same-directory temporary file and
atomically rename it. Cleanup checks both instance and publication generation
so an old callback cannot remove newer discovery data.
Publication is a required grant lifecycle participant, not a swallowed observer.
Prepare/publish occur outside the Core monitor; authority activation uses a
generation fence. Acquisition cannot succeed until publication and grant both
commit. Failure aborts credentials/files and reports a failed grant. Revoke/close
invalidate credentials before asynchronous work cleanup, then remove owned
publication and release ownership. File cleanup failure MUST NOT prevent runtime
cancellation. An already-admitted release response MUST remain deliverable.