Skip to content

spike: isolate cordis plugin runtime - #7450

Closed
t3-code[bot] wants to merge 7 commits into
mainfrom
spike/plugin-runtime-cordis
Closed

t3-code[bot] wants to merge 7 commits into
mainfrom
spike/plugin-runtime-cordis

Conversation

@t3-code

@t3-code t3-code Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

what changed

  • isolates the direct cordis implementation from spike: compare plugin runtime models #7448 into a standalone poc
  • uses real cordis contexts, fibers, injection, providers, effects, and isolation
  • keeps the shared manifest and runtime contract
  • adds a single-variant demo for activation, replacement, cleanup, and a 250-plugin chain

why

this lets reviewers evaluate cordis without the effect-scope or framework-free implementations in the same diff. the branch preserves the adapter and its measured tradeoffs, including the extra runtime dependency and structural type shim.

validation

  • 31 tests passed with node 24.13.1
  • package typecheck passed
  • lint with warnings denied passed
  • formatting and frozen lockfile install passed
  • demo completed successfully

limits

this is an isolated runtime poc. it does not load packages, add a sandbox, expose plugin rpc, or wire product ui.

checklist

  • this pr is focused on one implementation
  • i explained what changed and why
  • no ui changes

request provenance


Note

Low Risk
New private POC package with no product wiring; changes are additive and test-heavy, with no auth, data, or UI surface.

Overview
Adds a standalone @t3tools/plugin-runtime-cordis-poc package that pulls the Cordis-backed plugin runtime out of the broader three-way experiment so reviewers can evaluate it alone.

The POC implements createCordisRuntime against a shared PluginRuntime contract: dependency ordering and blocking, cycle detection, differential reconcile (reuse unchanged fibers), staged isolate labels for transactional provider overlap, frozen contribution snapshots, queued exclusive operations with reentrancy guards via AsyncLocalStorage, and rollback/retire cleanup with aggregated errors. A structural shim works around Cordis rc.8 declaration issues under this repo’s ESM setup.

Shared contract tests (defineRuntimeContract, 31 cases) and Effect Schema manifest validation (semver, path escape, mobile declarative) ship with the package; a demo script benchmarks activation, noop reconcile, and a 250-plugin chain. cordis is added to the lockfile. Scope is explicitly POC-only—no package loading, sandbox, RPC, or product UI.

Reviewed by Cursor Bugbot for commit 50112cd. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Cordis-backed plugin runtime POC with transactional reconciliation

  • Introduces a new @t3tools/plugin-runtime-cordis-poc package implementing a plugin runtime backed by Cordis, with full lifecycle management in cordisRuntime.ts.
  • reconcile() performs dependency analysis (cycle detection, topological ordering, duplicate id/capability rejection), restarts only changed plugins and their dependents, rolls back staged plugins on failure, and returns deeply frozen snapshots.
  • A reusable contract test suite in runtimeContract.ts validates behaviors including dependency-ordered activation, reentrancy rejection, rollback correctness, lifecycle event ordering, and cleanup error aggregation.
  • An Effect Schema-based manifest validator in manifest.ts enforces namespaced ids, semver, capability ids, and entrypoint path constraints.
  • A demo.ts benchmarks a 250-plugin dependency chain and exercises activation, upgrade, and teardown flows.

Macroscope summarized 50112cd.

Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Aug 18, 2026
@t3-code t3-code Bot mentioned this pull request Aug 18, 2026
2 of 3 tasks
Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts Outdated
Comment thread packages/plugin-runtime-poc/src/contract.ts Outdated
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 12.6 KiB 12.6 KiB −21 B (−0.2%) 15.1 KiB ✅
Codex Thread snapshot wire 6.3 KiB 6.3 KiB −1 B (−0.0%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.3 KiB 6.3 KiB −20 B (−0.3%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 51.8 KiB 51.8 KiB 0 B (0.0%) 66.4 KiB ✅
Codex Live turn messages 16 16 0 (0.0%) 21 ✅
Claude Total thread wire 12.6 KiB 12.6 KiB −20 B (−0.2%) 15.1 KiB ✅
Claude Thread snapshot wire 6.3 KiB 6.3 KiB −8 B (−0.1%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.3 KiB 6.3 KiB −12 B (−0.2%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 52.7 KiB 52.7 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 16 16 0 (0.0%) 21 ✅

Baseline: bcfd485 · PR result: 50112cd · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 99.9 KiB
  • Claude decoded thread snapshot: 100.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts
Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a substantial new plugin runtime POC (~1500 lines of new code) with complex dependency management, reconciliation logic, and lifecycle handling. While isolated from production code, the scope and complexity of this new capability warrants human review to validate the design approach.

You can add or adjust custom eligibility rules. Learn more.

Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@t3-code

t3-code Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

addressed the review findings in 0b502a819:

  • staged cordis fibers emit lifecycle events only after the composition commits
  • rollback preserves the activation error while cleanup failures go to onCleanupError
  • retirement cleanup failures are reported without rejecting an already committed snapshot
  • definition equality is order-insensitive and includes activation callback identity
  • entrypoints reject .. escape segments, semver validation is strict, and snapshot maps are typed as sparse records

22 tests pass with node 24.13.1, plus typecheck, lint, formatting, frozen install, and the demo.

Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@t3-code

t3-code Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

addressed the latest findings in fb81809c5:

  • plugin activation and finalizers run in an async callback context
  • reentrant reconcile or dispose calls now fail immediately instead of deadlocking the serialized queue
  • lifecycle observer failures are isolated and reported without interrupting commit or cleanup

25 tests, typecheck, lint with warnings denied, formatting, and frozen install pass on node 24.13.1.

Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fb81809. Configure here.

Comment thread packages/plugin-runtime-poc/src/cordisRuntime.ts
t3-code Bot and others added 2 commits August 19, 2026 00:42
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@t3-code

t3-code Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

addressed the latest review findings in e3039b23d:

  • synchronous callback microtasks can use the runtime after the callback returns
  • direct reentrant calls from active callbacks still reject immediately
  • late activation-context calls now reject
  • reconcile snapshots its input before queueing

29 tests, typecheck, lint with warnings denied, formatting, frozen install, and the demo pass on node 24.13.1.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 19, 2026
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 19, 2026 01:19

Dismissing prior approval to re-evaluate c42beab

@t3-code

t3-code Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

synced the plain-function callback return regression test and fix in c42beabec. callback lifetime tracking now treats only thenables as asynchronous.

30 tests and the full local validation pass on node 24.13.1.

Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
@t3-code

t3-code Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Consolidated into #8007 as one PR targeting main.

@t3-code t3-code Bot closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants