Expand description
ocserve-core: session domain — event bus, IDs, permission rendezvous, sync prompt runner with the tool loop.
Wire-invisible internals adopt v2 engineering where the plan says so (PLAN §11): durable event seq, bounded ring, crash-recoverable claims land with M3 milestones.
Re-exports§
pub use event::EventBus;pub use permission::PermissionGate;
Modules§
- compact
- Compaction-lite (W3): port of v1
buildPrompt+serializefrompackages/core/src/session/compaction.ts+session/compaction.ts(source-derived; no live-mutation probe needed for prompt text). - compaction
- M6 compaction engine (COMPACTION.md §2.3/§2.4):
create+process. - event
- Event bus: byte- AND count-bounded ring with cursor receivers.
- ids
- Upstream-shaped resource IDs:
<prefix>_<26 chars>where the first 10 hex chars encode ms-timestamp LE (matches observedmsg_0fa1e3f770014jHIfQNh0Lhiu3). - loop_
guard - Loop intelligence (DIFFERENTIATION.md D1 / P1b).
- permission
- Permission rendezvous: ask → permission.asked event → await reply via POST /permission/{id}/reply (oc-remote contract: reply = once|always|reject). Bounded wait (300s) → deny (fail-closed, never hang a session).
- prompt
- Sync prompt runner: POST /session/{id}/message semantics (captured live, testdata/m2/session_fixture.json + prompt_response.json + tool_fixture).
- question
- Question rendezvous — port of upstream
Questionservice (opencode/src/question/index.ts): pending map,question.asked/replied/ rejectedevents, reply/reject resolution. Bounded: wait cap replaces upstream’s infinite Deferred await (AGENTS §2.3 — divergence documented in the runner: timeout resolves as a reject). - revert
- Session revert / unrevert engine (SNAPSHOT.md §2, upstream
session/revert.ts+session/summary.ts@ v1.18.31). - sift_
boundary - Sift at the provider boundary (DIFFERENTIATION.md §4 / P1c).
- snapshot
- Snapshot engine (SNAPSHOT.md §2) — a faithful port of upstream’s shadow-git
mechanism (
packages/opencode/src/snapshot/index.ts@ v1.18.31). - spec
- The frozen OpenAPI contract, embedded at compile time.
- system_
prompt - Model-facing system-prompt composition (v1 parity, K-CAPDIFF).
- wire
- Typed wire requests for the prompt family — the field-contract layer.
- zen
- Zen free-tier request shaping (bench/zen-probe/FINDINGS: P5/P6/P7/P8).