@theaileverage/marionette 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ # Effect v4 compatibility acceptance guide
2
+
3
+ This is baseline acceptance analysis for the integrated reviewer, not a verdict on the ongoing rewrite. Source and test references below refer to committed baseline `88c1034d0d65d77b8a1fdf5f6a2d76bf38f15fd6`, inspected using `git show HEAD:<path>` and `git grep ... HEAD`. Existing tests were read, not executed in this review. Proposed checks below are additional acceptance work, not passing evidence.
4
+
5
+ The reviewed local skill is `.agents/skills/effect/SKILL.md`, with `SERVICES_LAYERS`, `TESTING`, `SCHEDULING`, `STREAMS`, `SCHEMA`, and `CONFIG` references. The installed and working-package Effect version was `4.0.0-rc.112`. Acceptance requires genuine Effect composition plus preserved durable, transport, SDK, and package behavior.
6
+
7
+ ## SQLite and authoritative state
8
+
9
+ `src/store.ts:Store.transaction` executes `BEGIN IMMEDIATE`, nested savepoints, commit/release, and rollback synchronously. `Store` uses WAL, `synchronous=FULL`, a 5000 ms busy timeout, schema version 2, and refuses newer databases. Preserve persisted records, events, ordering, and restart compatibility.
10
+
11
+ Keep each complete transaction inside one synchronous effect boundary. A callback returning a Promise or lazy Effect lets this baseline transaction commit before that work executes; do not yield, await, fork, or perform provider I/O inside it. `src/service.ts:submitAssignment`, `controlTask`, `report`, and `src/orchestration.ts:invoke` couple records, idempotency results, and events. Those writes must commit together or leave no partial state. Fibers and in-memory locks cannot replace persisted authority.
12
+
13
+ Existing evidence: `tests/core.test.ts`, “submission is nonblocking, idempotent and rejects reused keys with different intent” and “SQLite restart recovers running tasks and credentials without redispatch”; `tests/orchestration.test.ts`, “cancellation is atomic and cascades to all descendants”. These do not directly inject mid-transaction failure. **Proposed:** throw after a record write but before its event/idempotency write; reopen SQLite and verify rollback. Exercise nested rollback caught by the outer callback, uncaught nested failure, and rejection/prevention of asynchronous transaction callbacks.
14
+
15
+ ## Lease, task, and revision fencing
16
+
17
+ `src/service.ts:guard` compares the persisted lead owner, epoch, and token hash. `workerGuard`/`report` bind credentials to the current task run and reject obsolete revisions; `updateTask` merges onto the current row so stale I/O snapshots cannot erase newer controls or receipts. Preserve rechecks after external awaits, including reconciliation in `Service.invoke`, profile validation in `src/orchestration.ts:invoke`, and `src/cleanup.ts:release`. `src/supervisor.ts:verify` rereads the revision and pending operations after command execution before accepting results.
18
+
19
+ Existing tests in `tests/core.test.ts`: “handover persists a briefing, fences the old lead, and rejects simultaneous takeover”, “redirect rejects stale reports and waits for the previous turn to settle”, and “late output snapshots cannot roll back a concurrent redirect or receipt”. Retain path/symlink and artifact-ownership tests: changing schemas must not broaden task authority or expose tokens.
20
+
21
+ ## Ambiguous external effects must not replay
22
+
23
+ `src/supervisor.ts:recover` treats persisted `creating`, `prompting`, and control `sending` phases as ambiguous; scheduling reservations before side effects are recoverable separately. Dispatch persists run/creation intent before mutation. `src/continuation.ts:process` and `recover` preserve lead-delivery uncertainty; `src/cleanup.ts:release` persists `closing` before pane/tab closure, and `recover` converts interrupted closure to `uncertain`. A timeout, cancellation, or disconnected acknowledgement cannot prove the external action did not happen. Preserve identity-pinned explicit reconciliation and prohibit automatic mutation retry.
24
+
25
+ Existing evidence: `tests/core.test.ts`, “ambiguous prompt delivery is never retried automatically, including restart” and “lost split acknowledgement persists intent and reconciles without replaying or prompting”; `tests/orchestration.test.ts`, “ambiguous lead delivery survives restart without replay and stale ownership cannot resume”; `tests/cleanup.test.ts`, “lost pane-close acknowledgement remains uncertain and reconciles with sibling still present”. Schedule-based polling may retry safe observations; it must not wrap an entire dispatch/close/send operation in generic retries.
26
+
27
+ ## Completion includes descendants and current evidence
28
+
29
+ `Service.report` records a completion receipt; `Supervisor.verify` independently checks artifacts/commands and `Orchestration.unmetTask`. `src/orchestration.ts:unmet`, `taskEvidenceCurrent`, and `refreshEvidence` require current required descendants and criterion assessments, and reopen stale completed work. Preserve scope/depth/budget limits, yielding ownership/capacity, parent revision changes, and independent parent integration checks.
30
+
31
+ Existing `tests/orchestration.test.ts` cases include “recursive completion rejects failed, blocked, cancelled and unresolved descendants”, “completed parents require their own integration checks after all children pass”, “a new required child fences an in-flight parent verification result”, and “changed verified artifacts reopen the task, ancestors and outcome without invalidating unrelated work”. A successful child fiber or receipt alone cannot complete the parent outcome.
32
+
33
+ ## Resource acquisition, drain, and interruption
34
+
35
+ `src/server.ts:serve/shutdown` rejects new action calls while stopping, drains `Supervisor.stop`, closes HTTP connections, closes SQLite, then removes its owned lock. `Supervisor.stop` stops scheduling and waits for continuation, cleanup, and busy tasks. `src/continuation.ts:stop` and `src/cleanup.ts:stop` drain active work. External Herdr workers remain alive. Preserve this graceful-drain contract; scope interruption must not silently replace it with task cancellation or terminal closure.
36
+
37
+ Critical **proposed checks**, using readiness gates rather than arbitrary sleeps:
38
+
39
+ - Inject failure after lock acquisition, during Store/Service construction, during listener binding, and after background startup. Assert acquired resources finalize exactly once, SQLite closes, listeners/timers disappear, and retry succeeds. Baseline `serve` constructs Store/Service before its listen-error cleanup; this acquisition window is not covered by the integration happy path.
40
+ - Hold a Herdr send/close or verification command active, request shutdown, and assert no new scheduling, no database close before draining writes, and no duplicate external call. Separately interrupt the owning operation and assert durable uncertainty where delivery is ambiguous, with no writes after database disposal.
41
+ - Test simultaneous startup, stale PID recovery, malformed lock data, and lock replacement between acquisition and failure/shutdown. Remove only the lock this acquisition owns. Baseline normal shutdown checks `lockId`, but listen-error cleanup unlinks unconditionally. `tests/integration.test.ts` covers duplicate startup and normal lock removal; `tests/setup.test.ts` covers a concurrent AGY lock, not this full matrix. Also fault `src/agy-trust.ts:trustAgyWorkspace` cleanup without deleting another owner's replacement lock.
42
+
43
+ ## Process and SDK cancellation
44
+
45
+ `src/files.ts:command` uses argument-array spawning, strips `MARIONETTE_`/`HERDR_` variables, bounds output, and kills the POSIX process group on timeout. Preserve these properties. The existing “verification timeouts stop their process group and capture failure” in `tests/core.test.ts` only launches one process and checks timeout/nonzero exit. **Proposed:** spawn a descendant, interrupt the owning fiber, verify both processes exit and pipes/timers settle; test spawn failure and platform-specific behavior.
46
+
47
+ `src/herdr-transport.ts:socketRequest`/`JsonConnection` close sockets and detach abort listeners; preserve SDK Promise/async-iterator contracts, explicit targeting, deadlines, correlated replies, overflow errors, and no reconnect/replay. `tests/herdr-streams.test.ts` already covers cancellation, reader wakeup, overflow/EOF, and lost graphics ACKs. Add cancellation through the application Effect adapter, not merely direct `AbortController` calls.
48
+
49
+ Audit every `Effect.runPromise` inside an Effect program. In installed `node_modules/effect/src/internal/effect.ts`, `runPromiseWith` reaches `runForkWith`, which creates a new fiber; interruption is connected only when explicitly supplied a signal. Wrapping a nested runner in `tryPromise` without forwarding cancellation detaches work. Prefer `yield*` composition and scoped fibers internally; allow runners at deliberate Promise-facing ingress boundaries with owned lifetime. Prove parent interruption reaches the actual SDK socket/command and waits for finalization. Source search alone cannot establish propagation.
50
+
51
+ ## Integrated review steps
52
+
53
+ 1. Review the final diff against the pinned baseline and trace acquisition/finalization, transaction callbacks, retries, runners, and authority rechecks. Run the proposed fault/cancellation checks alongside retained tests.
54
+ 2. Run final `npm run check`, `npm test`, `npm run build`, configured lint/Effect diagnostics, and package smoke checks. Record exact revision, commands, results, and skipped platform cases.
55
+ 3. Retain `tests/integration.test.ts` HTTP/MCP/CLI parity: loopback/Host/Origin/auth enforcement, worker-token separation, error envelopes/statuses, 47 baseline MCP tools, durable shared state, and CLI JSON. Schema errors must still map to `invalid_input`/400 rather than internal failures.
56
+ 4. Verify `package.json`'s Node `>=22.13`, executable CLI/MCP bundles, public dashboard assets, `./herdr-sdk` export and declarations, plus isolated packed-package imports without workspace dependencies. Retain `tests/herdr-api.test.ts` protocol-22 routing and `tests/setup.test.ts` durable runtime/MCP argument tests. Passing source tests alone does not establish packed-artifact compatibility.
@@ -0,0 +1,73 @@
1
+ # Effect runtime
2
+
3
+ Marionette runs on Bun and uses Effect v4 for application workflows and resource lifetimes. The
4
+ installed version is pinned because the v4 API is still a release candidate.
5
+ See [CONTRIBUTING.md](../CONTRIBUTING.md) for compiler diagnostics, lint rules,
6
+ and the installed Effect skill.
7
+
8
+ ## Application lifetime
9
+
10
+ `src/application.ts` composes configuration, the supervisor lock, SQLite storage,
11
+ and the application service through `Context.Service` and `Layer`. Resources use
12
+ `Effect.acquireRelease`, so failure during later acquisition unwinds earlier
13
+ resources. A failed database constructor closes its database handle before
14
+ throwing. Lock cleanup checks its acquisition ID before removing the file.
15
+
16
+ `src/server.ts` owns this graph through `ManagedRuntime`. HTTP listening and
17
+ signal handlers belong to the same lifetime. The Promise returned by `shutdown`
18
+ is shared between callers, so every caller waits for disposal to finish.
19
+
20
+ The supervisor stops its scheduled poll before draining finite background jobs.
21
+ Continuation and cleanup work also drain before SQLite is closed. Shutdown
22
+ preserves external Herdr workers. Explicit fiber interruption is a separate
23
+ operation; it must not silently substitute for graceful shutdown.
24
+
25
+ ## Workflow and transport boundaries
26
+
27
+ Application operations use named `Effect.fn` functions and compose through
28
+ `yield*`. `AppError` and `BoundaryError` are tagged schema errors: application
29
+ errors retain their HTTP status and code, while infrastructure errors retain
30
+ their operation and original cause. Effect Schema decodes application inputs;
31
+ Zod remains at the MCP SDK boundary to satisfy that SDK's registration contract.
32
+
33
+ Promise runners belong at ingress points such as HTTP, MCP, CLI, or compatibility
34
+ methods used by existing callers. New internal code should call the Effect
35
+ operation directly. A nested `Effect.runPromise` starts another fiber and needs
36
+ explicit cancellation wiring; wrapping it in `tryPromise` alone does not provide
37
+ that wiring.
38
+
39
+ The published Herdr SDK keeps its Promise and async-iterator interfaces and has
40
+ no Effect dependency. The application's Herdr adapter passes Effect's abort
41
+ signal into the SDK socket request. `src/process.ts` scopes subprocess groups,
42
+ bounds captured output, and waits for stdio closure after termination. Loopback
43
+ HTTP uses Effect's HTTP client. Retry schedules are for safe readiness
44
+ observations, not potentially delivered mutations.
45
+
46
+ ## Durable authority
47
+
48
+ SQLite records remain authoritative for leases, revisions, ownership,
49
+ idempotency, and uncertain delivery. A fiber is an execution mechanism, not a
50
+ replacement for persisted state. Persist intent before an external mutation and
51
+ recheck current authority after external I/O. A lost acknowledgement must not
52
+ cause automatic send or close replay.
53
+
54
+ Persistence currently uses `bun:sqlite` directly. Effect owns its lifetime and wraps application operations; queries do not use `@effect/sql-sqlite-bun`.
55
+
56
+ Store transactions remain synchronous. Keep all writes in a transaction inside
57
+ one synchronous boundary; never return a Promise or lazy Effect from a
58
+ transaction callback. This preserves atomic records, events, and idempotency
59
+ updates without committing before deferred work executes.
60
+
61
+ ## Verification
62
+
63
+ `bun run check` includes patched TypeScript diagnostics and anti-slop lint.
64
+ `bun run tooling:check` proves the rules reject deliberate failures after
65
+ installation. `bun run runtime:check` exercises failed resource acquisition,
66
+ duplicate startup, concurrent shutdown, and signal cleanup. `bun run test` covers
67
+ durable orchestration and protocol behavior. `bun pm pack` runs checks and builds;
68
+ `bun scripts/release.mjs smoke PATH_TO_TARBALL` checks the isolated CLI and SDK,
69
+ including declaration use without a workspace Effect dependency.
70
+
71
+ The [compatibility acceptance guide](effect-compatibility.md) records the
72
+ pre-migration invariants and additional review cases. It is a review checklist,
73
+ not a test result or a claim of integrated acceptance.
package/package.json CHANGED
@@ -1,41 +1,51 @@
1
1
  {
2
2
  "name": "@theaileverage/marionette",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "engines": {
6
- "node": ">=22.13"
6
+ "bun": ">=1.3.14"
7
7
  },
8
8
  "scripts": {
9
- "dev": "node --import tsx src/cli.ts serve",
10
- "start": "node dist/cli.js serve",
11
- "build": "tsc && vite build && node scripts/bundle.mjs",
12
- "check": "tsc --noEmit && tsc -p tsconfig.web.json && tsc -p tsconfig.tests.json",
13
- "test": "node --import tsx --test tests/*.test.ts",
14
- "cli": "node --import tsx src/cli.ts",
15
- "mcp": "node --import tsx src/mcp.ts",
16
- "format": "prettier --write src web skills .github tests scripts *.json *.ts *.md",
17
- "format:check": "prettier --check src web skills .github tests scripts *.json *.ts *.md",
18
- "prepack": "npm run check && npm test && npm run build",
19
- "release:prepare": "node scripts/release.mjs prepare",
20
- "release:check": "node scripts/release.mjs check",
21
- "sdk:generate": "node scripts/generate-herdr-sdk.mjs"
9
+ "dev": "bun src/cli.ts serve",
10
+ "start": "bun dist/cli.js serve",
11
+ "build": "bun --bun tsc && bun --bun vite build && bun scripts/bundle.mjs",
12
+ "check": "bun --bun tsc --noEmit && bun --bun tsc -p tsconfig.web.json && bun --bun tsc -p tsconfig.tests.json && bun run lint",
13
+ "test": "bun test ./tests --timeout 120000",
14
+ "cli": "bun src/cli.ts",
15
+ "mcp": "bun src/mcp.ts",
16
+ "format": "bun --bun prettier --write src web documentation skills .github tests scripts .oxlintrc.json .vscode *.json *.ts *.md",
17
+ "format:check": "bun --bun prettier --check src web documentation skills .github tests scripts .oxlintrc.json .vscode *.json *.ts *.md",
18
+ "prepack": "bun run check && bun run test && bun run runtime:check && bun run build",
19
+ "release:prepare": "bun scripts/release.mjs prepare",
20
+ "release:check": "bun scripts/release.mjs check",
21
+ "sdk:generate": "bun scripts/generate-herdr-sdk.mjs",
22
+ "prepare": "bun --bun effect-tsgo patch --typescript --oxlint",
23
+ "lint": "bun --bun oxlint src web tests scripts vite.config.ts",
24
+ "effect:diagnostics": "bun --bun effect-tsgo diagnostics --project tsconfig.json",
25
+ "tooling:check": "bun scripts/check-quality-tooling.mjs",
26
+ "runtime:check": "bun scripts/check-runtime-lifecycle.mjs"
22
27
  },
23
28
  "devDependencies": {
29
+ "@effect/tsgo": "0.43.0",
30
+ "@modelcontextprotocol/sdk": "^1.27.1",
31
+ "@oxlint/plugins": "1.82.0",
24
32
  "@types/express": "^5.0.0",
25
33
  "@types/node": "^22.15.0",
26
34
  "@types/react": "^19.1.0",
27
35
  "@types/react-dom": "^19.1.0",
36
+ "effect": "4.0.0-rc.112",
28
37
  "esbuild": "^0.28.2",
29
- "prettier": "^3.9.6",
30
- "tsx": "^4.20.0",
31
- "typescript": "^5.8.3",
32
- "vite": "^6.3.5",
33
- "@modelcontextprotocol/sdk": "^1.27.1",
34
38
  "express": "^5.1.0",
35
39
  "lucide-react": "^0.468.0",
40
+ "oxlint": "1.82.0",
41
+ "prettier": "^3.9.6",
36
42
  "react": "^19.1.0",
37
43
  "react-dom": "^19.1.0",
38
- "zod": "^3.25.0"
44
+ "typescript": "7.0.2",
45
+ "vite": "^6.3.5",
46
+ "zod": "^3.25.0",
47
+ "oxlint-tsgolint": "7.0.2001",
48
+ "@types/bun": "1.3.14"
39
49
  },
40
50
  "description": "Persistent multi-agent orchestration for Herdr, with a named lead, MCP tools, and a local dashboard.",
41
51
  "bin": {
@@ -63,7 +73,9 @@
63
73
  "dist/herdr-streams.d.ts",
64
74
  "dist/herdr-transport.js",
65
75
  "dist/herdr-transport.d.ts",
66
- "vendor/herdr-0.9.0/LICENSE"
76
+ "vendor/herdr-0.9.0/LICENSE",
77
+ "documentation/effect-runtime.md",
78
+ "documentation/effect-compatibility.md"
67
79
  ],
68
80
  "publishConfig": {
69
81
  "access": "public"
@@ -82,5 +94,6 @@
82
94
  "types": "./dist/herdr-sdk.d.ts",
83
95
  "import": "./dist/herdr-sdk.js"
84
96
  }
85
- }
97
+ },
98
+ "packageManager": "bun@1.3.14"
86
99
  }