Skip to content

Realize doxbench Phase B §11: OMP harness bridge, knowledge MCP server, thread wiring - #223

Merged
brettheap merged 23 commits into
mainfrom
change/doxbench-b-s11-harness-bridge
Aug 20, 2026
Merged

brettheap merged 23 commits into
mainfrom
change/doxbench-b-s11-harness-bridge

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Realizes §11 of add-doxbench-editing-phase-b — the third slice of wave 2, after #210 (§13 contract release) and #216 (§10 knowledge service).

What this adds

  • doxbench_bridge.py — a stdlib-only adapter translating the UNCHANGED three-member WorkbenchModelPort to a supervised local omp --mode rpc child (stdio JSONL). On-demand start, bounded restart, stderr to the serve log only, loopback-local, credential-free. One harness session per document thread (switch_session on selection change; fresh session per thread). memory.backend: off pinned via a --config overlay under a dedicated doxbench-bridge profile; /shake as layer-3 compression; artifact:// content dereferenced through the bridge's seam before any sidecar write.
  • doxbench_mcp.py — the stdio MCP server owed by task 10.2's note, fronting the same KnowledgeToolBoundary (search / get_source / promote_finding / reindex), with the xd://mcp__<server>_<tool> mount names pinned against a re-implementation of the harness's own name composition.
  • Thread wiring — every answered turn mirrors into the selected document's sidecar; Save commits dirty sidecars through the existing one-commit-per-gate-action path (task 9.2; commit_gate_action untouched); the thread route lands loopback-only, fail-closed on unresolved actor, absent on the hosted plane (task 9.5); the selector switch swaps the transcript (task 7.2's waiting half).
  • Obligations discharged: the §11.5 scaffold-reserve breach (rendered section bytes now charged against the packet budget, measured through the real route), the context_packet_bound_exceeded 409 arm proven at the HTTP route, and SIGNAL_THREAD_STATE verified firing. Task 11.7 stays honestly half-realized: its additive model-catalog release remains a recorded obligation; the closed catalog schema is untouched.

Review evidence

Full adversarial loop: Opus implementation → fresh-context adversarial review (FIX THEN RE-VERIFY: 7 P1 / 6 P2 / 10 P3, all fixed) → same-reviewer re-verify (LAND; every original reproduction re-run against a real omp v17.3.7 and watched to fail to reproduce) → pre-PR punch list applied (8 further findings closed or recorded). The hermetic test child is a frame-for-frame transcription of captured real RPC transcripts, and an 8-test live smoke runs against a real harness when one is discoverable (DOXBENCH_OMP_HOME) and skips cleanly otherwise — no gate depends on omp.

Gates (merged tree, origin/main @ c379a09)

  • pytest: tests/ideation-dashboard 3688 passed / 15 skipped; tests/ideation_dashboard 63; tests/doc-health 691; live smoke 8 passed with harness / 8 skipped without
  • openspec validate --all --strict: 64/64
  • validate-ideation-dashboard-contracts.py: 0 errors / 4 warnings (v1 deprecation, by design)
  • doc-health: zero new findings vs same-clock origin/main baseline
  • No contract schema, v1-lane, commit_gate_action, or port-member changes

🤖 Generated with Claude Code

brettheap and others added 18 commits August 19, 2026 15:47
…t budget

The flat PROMPT_SCAFFOLD_RESERVE_BYTES could only be right for one section
count. Fix option (a): extract the rendered preamble/declaration templates as
constants, derive PER_SOURCE_SCAFFOLD_BYTES from them, and charge per thread ref
and per evidence slot. Defaults reproduce the pre-§11 number exactly.

Co-Authored-By: Claude Fable 5 <[email protected]>
…MCP server

doxbench_bridge.py realizes tasks 11.1-11.6 as an ADAPTER for the unchanged
three-member WorkbenchModelPort; doxbench_mcp.py discharges task 10.2's owed
stdio MCP transport with a pinned xd:// mount name.

Co-Authored-By: Claude Fable 5 <[email protected]>
…lector

- serve.py reads each loaded document's sidecar into the packet, mirrors every
  answered turn back into the selected document's sidecar through the Save
  gate, binds the harness session per thread, and serves GET /workbench/thread
- branch_session/gate_routes: a dirty sidecar joins its document's Save commit
  through the injected thread_commit_paths seam (commit_gate_action untouched)
- the chat rail switches the transcript to the selected document's thread

Co-Authored-By: Claude Fable 5 <[email protected]>
The 409 arm, SIGNAL_THREAD_STATE, turn mirroring, the thread route's four
postures, the Save's one-commit rule against real git, and the re-measured
scaffold reserve.

Co-Authored-By: Claude Fable 5 <[email protected]>
24 loaded documents with threads plus the evidence slots spend 16,477 bytes of
rendered scaffolding against the old flat 16,384 — measured, not argued.

Co-Authored-By: Claude Fable 5 <[email protected]>
P1-7 first: fake_omp_child.py rebuilt from the ORIGINAL verification session's
raw captured stdout — ready frame, unsolicited noise frames, a prompt response
with NO data, message_update.assistantMessageEvent.text_delta, agent_end with
messages/isTerminal, command_output BEFORE the /shake response — and its
argparse now accepts only flags omp --help really declares.

P1-1 --setting is not an omp flag (live: 'unknown flag'); the memory pin moves
to a --config overlay written into the bridge's own session root, live-proven
by /memory diagnose answering 'Memory backend is off'.
P1-2 MOUNT_SEPARATOR is '_' per createMCPToolName; live-captured mounts match.
P1-3 the assistant text lives at assistantMessageEvent.delta, one level down.
P1-4 an omitted agentInvoked means await the session events to agent_end.
P1-5 the harness provider id is an install-side declaration, never the
catalog's governance provider_class (live: set_model now succeeds).
P1-6 the MCP registration is a path-based entrypoint that runs under env -i.
P2-8 leg 1 engages for a child that spawns then dies.
P3-16 bounded chunked read at the real 1 MiB v1 frame cap.
P3-20 render_prompt_message defers to PromptEnvelope.rendered().

Co-Authored-By: Claude Fable 5 <[email protected]>
Live-caught defect in the P1-4 fix itself: the omitted-agentInvoked rule was
applied to every command, so set_model/switch_session/get_state waited for an
agent_end that never comes. The set_model response arrived at 1.03s and the
reader sat on it for the full deadline. Gated on the REQUEST's own type.

LIVE: dispatch -> {'assistant_prose': 'MOCK_DONE'} in 1.40s.

Co-Authored-By: Claude Fable 5 <[email protected]>
…tocol

test_doxbench_bridge_live.py drives the REAL bridge against a REAL omp with a
keyless local provider, and SKIPS cleanly when neither is discoverable — no
gate requires it. 6 passed against v17.3.7; 6 skipped without it.

Bridge/MCP tests re-pinned: the overlay launch line, the install-side provider
id, assistantMessageEvent.text_delta, the omitted-agentInvoked await, the
single-underscore mounts (pinned against a re-implementation of the harness's
own createMCPToolName), and the registered command run under the harness's own
cwd and environment.

Co-Authored-By: Claude Fable 5 <[email protected]>
P2-9 a document switch while a turn is in flight is REFUSED (model returns the
identical state; the handler says so on the rail's note and renders back) — the
reviewer's own Node repro is now a pin, including the wire transcript.
P2-10 _session_worktree_for asks branch_session.live_session_branches, the
liveness authority the Save path trusts, instead of two registry fields
documented as advisory and 'never the reason a session fails'; four tests drive
the REAL method against a real git session, including the
bootstrap-reconstructed entry that used to lose records silently.
P2-11 every turn binds a conversation — a document by its path, an outline by
its tile — and the bridge refuses an unbound dispatch outright, so an outline
turn can no longer land in a document's harness session.

Co-Authored-By: Claude Fable 5 <[email protected]>
11.1/11.3/11.4/11.5/11.6 tick prose now matches post-fix reality, each with a
dated CORRECTED note naming what was untrue and why; 7.2 and 9.5 carry the
P2-9/P2-10 corrections; 10.2 pins the single-underscore mounts.
Judgment calls #15 and #16 join the flagged list (P2-13).
verification-findings.md §3.1 and §3.2 carry dated correction notes at the
source, so the separator and the launch flag are settled where they were
recorded rather than only downstream.
Recorded rather than fixed: P3-15 (2x over-charge), P3-17 (uncommitted-sidecar
tail, against §12.5 which will carry it), P3-18, P3-22, P3-23.
Applied: P3-14, P3-19, P3-21.

Co-Authored-By: Claude Fable 5 <[email protected]>
N-1 the shipped provider_id=None default refused every real turn (live:
'Model not found: undefined/<model>'). A provider-less set_model is never sent;
undeclared, the bridge asks which model the harness is already on and proceeds
only if it is the one this turn asked for, refusing rather than letting another
model answer under this turn's recorded model id. The fixture now refuses a
missing provider exactly like omp — the P1-7 pattern, closed.

N-2 run_command's safety claim was false: an unlisted slash command is not an
error, it is a real model turn bypassing the assembler, the bounds and the
sidecar (live-proven). Closed allowlist of builtin heads, a bound conversation
required, and an agent-invoked response raises. The fixture reproduces the
fall-through so the guard tests something real.

N-3 _known_dead pinned (child killed externally, no call since, catalog poll).
N-4 available() and catalog() can no longer disagree.
N-6 one spelling of the liveness question, shared from doxbench_scope.
N-7 the §3.1 addendum no longer swallows the paragraph after it.
N-8 the de-facto-surface test states what it cannot see.
N-5 JC-2 and JC-3 given their own flagged entries; JC-5 added for N-1's refusal.

Co-Authored-By: Claude Fable 5 <[email protected]>
… overclaim

The extracted is_live_session_ref is now pinned (normalised ref match, and
serve.py asks it rather than calling live_session_branches itself). The
docstring's first draft claimed normalize_ref strips refs/heads/ — it does not;
it trims whitespace and defaults None/empty. Corrected in both places and the
test asserts what the function really does.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 20, 2026 02:06

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request realizes doxbench Phase B §11 by adding the local OMP harness bridge, the stdio MCP server for the knowledge boundary, and wiring document-thread reads/writes so the selected document’s transcript is sourced from (and mirrored into) per-document sidecars.

Changes:

  • Add an stdlib-only omp --mode rpc bridge plus hermetic and optional live-smoke tests.
  • Add a stdio MCP server exposing the existing knowledge boundary (search/get_source/promote_finding/reindex) with pinned mount-name composition.
  • Wire thread read (GET /workbench/thread) and write/mirror-to-sidecar on answered turns; ensure thread sidecars commit with Save.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/ideation-dashboard/test_renderer.py Updates fetch-site pins to include the new thread GET transport.
tests/ideation-dashboard/test_doxbench_transport.py Pins the new THREAD_ROUTE constant and thread loader transport behavior.
tests/ideation-dashboard/test_doxbench_thread_switch.py Adds Node-driven tests pinning transcript switching semantics on selection changes.
tests/ideation-dashboard/test_doxbench_request_handling.py Extends the doxbench error-code catalog pins to include thread capability absence.
tests/ideation-dashboard/test_doxbench_mcp.py Adds protocol + mount-name + process-entrypoint tests for the MCP stdio server.
tests/ideation-dashboard/test_doxbench_knowledge_service.py Clarifies scaffold-reserve measurement scope vs the new “with threads” measurement.
tests/ideation-dashboard/test_doxbench_bridge.py Adds a large hermetic test suite for the OMP harness bridge over real pipes.
tests/ideation-dashboard/test_doxbench_bridge_live.py Adds optional live smoke tests against a real omp when discoverable.
tests/ideation-dashboard/fixtures/fake_omp_child.py Rebuilds the fake OMP child to match live-captured RPC frames/flags.
scripts/ideation_dashboard/web/views/staging-workbench.js Wires an optional loadThread seam into the workbench → chat rail.
scripts/ideation_dashboard/web/views/doxbench-chat.js Implements selection-driven thread transcript switching + in-flight refusal.
scripts/ideation_dashboard/web/views/doxbench-chat-model.js Adds adoptThreadTranscript() to adopt/evict thread transcripts safely.
scripts/ideation_dashboard/web/app.js Adds THREAD_ROUTE and the createDoxBenchThreadLoader() transport.
scripts/ideation_dashboard/serve.py Adds the /workbench/thread route and mirrors answered turns into sidecars.
scripts/ideation_dashboard/gate_routes.py Injects thread-sidecar commit paths into the existing Save/commit flow.
scripts/ideation_dashboard/doxbench_scope.py Extracts and shares is_live_session_ref() to avoid duplicated liveness checks.
scripts/ideation_dashboard/doxbench_packet.py Makes scaffold reserve measured per-section shape (threads + evidence) vs flat.
scripts/ideation_dashboard/doxbench_mcp.py Implements the stdio MCP server and its registration/manifest confinement.
scripts/ideation_dashboard/branch_session.py Extends Save commit declaration to include dirty thread sidecars when present.
openspec/changes/add-doxbench-editing-phase-b/verification-findings.md Records corrections from §11 live re-verification (flags, mount separator).
openspec/changes/add-doxbench-editing-phase-b/tasks.md Marks §11 tasks done and updates task narratives with the realized wiring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/ideation_dashboard/serve.py Outdated
Comment on lines +1406 to +1415
def _thread_capability_absence(self) -> str | None:
"""`None` where threads exist, else the DECLARED cause. Fail-closed on
an unresolved actor: a thread is a human's working memory on a session
branch, and a session with no identified human is not one."""
if not self.actor:
return doxbench_threads.NO_GATE_CAPABILITY_CAUSE
return doxbench_threads.thread_capability_absence(
plane=self._thread_plane(),
gate_capability=bool(
self.capabilities.get("actions", {}).get("session")))
Comment on lines +945 to +957
async function switchThread(documentKey) {
const load = options.loadThread;
if (typeof load !== "function") return;
let answer = null;
try {
answer = await load(documentKey);
} catch (error) {
answer = null;
}
if (destroyed) return;
const turns = answer && Array.isArray(answer.turns) ? answer.turns : [];
adopt(adoptThreadTranscript(state, turns));
}
Comment on lines +469 to +476
widest_section = max(
utf8_size(template.format(**filled))
for template in (SELECTED_THREAD_PREAMBLE, THREAD_STATE_PREAMBLE,
EVIDENCE_PREAMBLE))
widest_key = max(utf8_size(THREAD_STATE_SECTION_PREFIX),
utf8_size(EVIDENCE_SECTION_PREFIX))
return (widest_section + SECTION_SEPARATOR_BYTES + widest_key
+ utf8_size(DECLARATION_LINE.format(**filled)) + 1)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2db043088f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/ideation_dashboard/serve.py Outdated
Comment on lines +2701 to +2704
conversation_key = (
bound_buffer_key if bound_buffer_key in document_keys
else port.outline_conversation_key(key.tile_kind, key.tile_id)
if callable(getattr(port, "outline_conversation_key", None))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Include the scope in harness conversation keys

When two different tile scopes load the same repository-relative document path, both bind the shared per-serve bridge under the identical bound_buffer_key; OmpHarnessBridge._sessions is keyed only by this string, so the second tile reuses the first tile's native harness session and inherits its conversation context. Outline keys likewise omit repository/ref. Compose the conversation key from the full ScopeKey plus the buffer key so distinct sidecar threads cannot share a harness session.

Useful? React with 👍 / 👎.

Comment thread scripts/ideation_dashboard/serve.py Outdated
Comment on lines +2707 to +2709
if conversation_key is None:
raise RuntimeError("this adapter declares no outline key")
port.select_thread(conversation_key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make thread selection and dispatch atomic

With the inspected ThreadingHTTPServer, turns for different scope keys can run concurrently, and the shared bridge lock covers select_thread() and dispatch() separately rather than this pair: handler A can select A, handler B can select B, and then A's dispatch only checks that some conversation is selected and sends A's prompt into B's session. Bind the expected conversation as part of the dispatch operation, or otherwise hold one adapter transaction across selection and prompt submission.

Useful? React with 👍 / 👎.

Comment thread scripts/ideation_dashboard/serve.py Outdated
Comment on lines +2780 to +2784
if bound_buffer_key in document_keys:
self._mirror_turn_into_sidecar(
key, document=bound_buffer_key,
turn_id="assistant-" + digest[:56],
model_id=model_id, bound_buffer_key=bound_buffer_key,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive sidecar paths from the document path

For a restored Phase A state, the validator explicitly permits a path-backed buffer to remain under the reserved key document; a turn on that buffer therefore writes ideation/dashboard/session-threads/document.thread.md here. The Save transaction instead calls thread_commit_paths() with the normalized real document path, so it looks for a different sidecar and the conversation does not ride the document's commit; a later re-key also starts a second thread. Use the bound buffer's actual path when deriving the sidecar, while retaining the buffer key only in the turn metadata.

Useful? React with 👍 / 👎.

Comment on lines +949 to +956
try {
answer = await load(documentKey);
} catch (error) {
answer = null;
}
if (destroyed) return;
const turns = answer && Array.isArray(answer.turns) ? answer.turns : [];
adopt(adoptThreadTranscript(state, turns));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ignore stale thread-load responses

If the user selects document A and then B before A's thread GET completes, both asynchronous handlers remain live; when A's slower response arrives after B's, this unconditional adoption replaces B's transcript with A's turns even though the active buffer is still B. The next B turn then sends A's transcript on the wire. Associate each load with a generation/current-buffer check or cancel the preceding request before adopting its response.

Useful? React with 👍 / 👎.

brettheap and others added 4 commits August 19, 2026 22:21
C1 two scopes sharing a document path now get two sessions (key composed from
the whole ScopeKey, JSON-injective); C2 bind-and-dispatch is one critical
section behind a per-turn conversation view that is still exactly the
three-member port; C3 the sidecar comes from the document's PATH and the
reserved unbacked slot records none; C4 a stale thread-load answer is dropped
by generation (both arms pinned); CP1 an unresolved actor has its own cause and
every wire cause is a bare cause; CP3 the selected-thread section key joins the
widest-key derivation.

Co-Authored-By: Claude Fable 5 <[email protected]>
C1/C2 against 11.4 (JC-3 strengthened from a check to a structural property),
C3 and CP3 against 11.5 (judgement call #15 widened to every pathless buffer;
PER_SOURCE_SCAFFOLD_BYTES 313 -> 315, both recorded thresholds still cleared),
CP1 against 9.5 (noting it is the same class as this slice's own P3-19), C4
against 7.2. CP3's pin re-derived from the module constant so it bites.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 20, 2026 02:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/ideation_dashboard/serve.py:440

  • _sidecar_text() currently normalizes CRLF/CR to LF and calls .strip(), which silently removes leading/trailing whitespace from the human and assistant bodies before they’re validated and persisted. This changes the durable record (and can hide the fact that the original body would be refused by doxbench_threads._validated_body, which explicitly treats outer whitespace as non-round-trippable and refuses it). If the goal is only to make CRLF storable, normalize line endings but leave whitespace intact and let the thread format’s validation/refusal govern whether mirroring occurs.
# The sidecar format is LF-ONLY (`doxbench_threads._validated_body` refuses a
# carriage return), and the wire carries whatever the browser and the provider
# produced. Normalising HERE — at the one place a turn becomes a record — is
# what keeps a CRLF answer storable instead of refused, and it is a
# normalisation rather than an edit: the bytes the model returned still ride the
# response envelope unchanged.
def _sidecar_text(value: object) -> str:
    text = "" if value is None else str(value)
    return text.replace("\r\n", "\n").replace("\r", "\n").strip()

NP-1 11.2's declared-surface note now matches the test: the route reaches five
duck-typed names (conversation_key, outline_conversation_key, for_conversation,
mirror, dereference), and select_thread is no longer among them — it stays
public for the live smoke and for binding a builtin.
NP-2 drop the bare 'if True:' left over from splitting _select_thread_locked
out, and re-indent its body.
NP-4 _document_threads' docstring no longer claims the buffer key is always the
path: it is for every path-backed buffer, and the reserved unbacked slot has no
sidecar written for it at all, so its read is an honest absence.
NP-6 for_conversation states that injectivity lives in the composer; it checks
only that a key was supplied.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 20, 2026 05:43
@brettheap
brettheap merged commit 7312c25 into main Aug 20, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.

Suppressed comments (2)

scripts/ideation_dashboard/doxbench_scope.py:810

  • is_live_session_ref claims to normalize refs (including None/empty -> default) via snapshot_registry.normalize_ref, but the early guard or not ref returns False for an empty string before normalization runs. This makes the behavior contradict the docstring and normalize_ref’s documented contract, and it can incorrectly treat an otherwise-live default-ref scope as non-live when ref is empty.
    scope_kind = kinds.get(key.tile_kind)
    if scope_kind is None or not ref or registry is None:
        return False

scripts/ideation_dashboard/doxbench_mcp.py:524

  • MountManifest.profile_id is parsed, stored, and written into the manifest, but build_server() ignores it and always builds the SELF_HOSTED_LOCAL_EMBEDDED backend. That means a manifest can claim one profile while the server actually uses another, which is misleading and could mask misconfiguration. Either honor manifest.profile_id when selecting a backend or refuse manifests that declare an unsupported profile.
def build_server(manifest: MountManifest) -> KnowledgeMcpServer:
    backend = doxbench_knowledge.build_backend(
        doxbench_knowledge.SELF_HOSTED_LOCAL_EMBEDDED)
    boundary = doxbench_knowledge.KnowledgeToolBoundary(backend)
    boundary.reindex(manifest.indexed_sources())
    return KnowledgeMcpServer(boundary, confined_to=manifest.confined_refs(),
                              manifest=manifest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants