Move the built web bundle into an embedded fabro-spa crate so Cargo and release builds no longer depend on Bun at build time, and preserve the local dev override path for fast UI iteration. At the same time, rename interview and agent-level aborted flows to interrupted, keep cancelled for run-level shutdown, and stop reporting skipped answers as interruptions in the run event stream.
21 KiB
| title | type | status | date |
|---|---|---|---|
| feat: unify interview handling around projected questions, worker stdin, and server-owned Slack | feat | active | 2026-04-07 |
feat: unify interview handling around projected questions, worker stdin, and server-owned Slack
Overview
Replace the current split interview architecture with one canonical model:
- pending interviews live in the durable run projection
- answers enter through the server
- active runs receive accepted answers through a live control sink
- Slack becomes a server-owned delivery surface, not a special in-memory interviewer path
This refactor removes FileInterviewer and WebInterviewer, keeps the existing HTTP question and answer routes as the canonical external contract, and uses worker stdin JSONL for server-to-worker answer delivery.
Problem Frame
Interview handling is currently split across two transport-specific implementations:
- subprocess runs use
FileInterviewer, withinterview_request.jsonandinterview_response.jsonscratch files - the in-process server override path uses
WebInterviewer, with pending questions and answer waiters held only in memory
That split leaks into the server:
GET /runs/{id}/questionsbranches betweenWebInterviewer.pending_questions()and the request scratch filePOST /runs/{id}/questions/{qid}/answerbranches betweenWebInterviewer.submit_answer()and the response scratch file- Slack is built on the same special
WebInterviewerpath instead of the canonical server question API
The result is one feature implemented twice, with two incompatible sources of truth for pending questions and two different answer delivery mechanisms.
The desired architecture is simpler:
- the durable run event stream and run projection are authoritative for pending interviews
- the server owns answer validation and first-answer-wins behavior
- subprocess workers receive accepted answers over
stdin, which also establishes the future control plane for steering - Slack is just another server-owned client of the canonical answer path
Scope Boundaries
In scope:
- add stable question ids and persist pending interviews in the run projection
- replace scratch-file answer transport with worker
stdinJSONL - replace
WebInterviewerwith the same brokered answer model used by subprocess runs - move Slack onto a single global Socket Mode listener inside
fabro-server - keep the existing HTTP question and answer routes as the canonical external API
- expand the question API payload to expose the information needed by CLI and Slack
Out of scope:
- worker-side steering behavior beyond reserving the
stdinprotocol shape for it - server restart rehydration of Slack delivery state
- a separate Slack bridge process
- signed Slack tokens or tamper-evident action payloads
- any new public answer route or worker-side HTTP contract
Requirements Trace
- R1. Pending interview state must be derived from durable run events and exposed from the run projection, not from scratch files or live interviewer objects.
- R2. Every interview question must have a stable
question_idthat survives through events, HTTP APIs, Slack payloads, and worker answer delivery. - R3.
GET /runs/{id}/questionsmust read only from canonical projected pending interview state. - R4.
POST /runs/{id}/questions/{qid}/answermust remain the canonical answer ingress for web, CLI, and Slack. - R5. For subprocess runs, the server must deliver accepted answers to the worker over
stdinas versioned JSONL. - R6. For the in-process
registry_factory_overridepath, the server must still support interview-driven tests withoutWebInterviewer. - R7.
FileInterviewerandWebInterviewermust be removed from production use and then deleted. - R8. Slack must be owned by
fabro-serveras a single global Socket Mode listener, not by per-run workers and not by a separate bridge process. - R9. Slack delivery state may be memory-only. After server restart, stale Slack prompts may be ignored and resumed runs may post fresh prompts under the new server config.
- R10. Slack payloads must carry
run_idandqid, and Slack answers must route through the same canonical server answer handler as HTTP. - R11. Multiple-choice and multi-select answers must remain structured end-to-end and must not be flattened to text in the Slack path.
- R12. Accepted answers must use first-answer-wins semantics across concurrent HTTP and Slack submissions.
Key Decisions
-
Questiongains a first-classid: String.- Generate it in the human handler as a ULID string.
- Do not hide it in
metadata. - Do not add a new
QuestionIdwrapper type in this pass.
-
interview.startedbecomes the authoritative pending-question event.- Keep
questionas the human-readable text field. - Add
question_id,stage,question_type,options,allow_freeform,timeout_seconds, andcontext_display.
- Keep
-
interview.completedandinterview.timeoutgainquestion_id. -
Add
interview.interrupted.- Carry
question_id,question,stage,reason, andduration_ms. - Use it when the interviewer returns
Interrupted, whileSkippedflows throughinterview.completed, so pending interview cleanup stays event-driven.
- Carry
-
RunProjectionbecomes the only source of truth for pending interviews.- Add
pending_interviews: BTreeMap<String, PendingInterviewRecord>. - Insert on
interview.started. - Remove on
interview.completed,interview.timeout,interview.interrupted,run.rewound, and terminal run events.
- Add
-
Keep the existing answer route contract.
GET /runs/{id}/questionsandPOST /runs/{id}/questions/{qid}/answerremain the public surface.SubmitAnswerRequestalready supports freeform, single-select, and multi-select and does not need to change.- Expand
ApiQuestionwithstage,timeout_seconds, andcontext_display.
-
Server-to-worker answer delivery uses
stdinJSONL, versioned from day one.- Use one JSON object per line.
- Implement only
interview.answerin this pass. - Reserve the envelope for future steering, but do not implement steering behavior yet.
-
Use a broker-backed interviewer abstraction for both runtime paths.
- Replace
FileInterviewerandWebInterviewerwith an internalInterviewBrokerplusControlInterviewer. - For subprocess runs, the broker is fed by parsed
stdincontrol messages. - For the in-process override path, the broker is fed directly by the server’s canonical answer submission service.
- Replace
-
Slack is a server-owned delivery surface, not a worker concern.
- Start one Socket Mode listener inside
fabro-serverwhen both Slack tokens andslack.default_channelare configured. - Have that service consume the server's existing global run-event broadcast, the same fanout fed by
forward_run_events_to_global(...)for both subprocess and in-process runs. - Do not read from SSE endpoints or introduce a second event source.
- Keep Slack message metadata and thread routing in server memory only.
- Do not replay or restore Slack posts after restart.
- Start one Socket Mode listener inside
-
Slack action payloads use plain JSON in
value.- Carry at least
run_id,qid, and answer metadata. - Keep
action_idstructural rather than encoding identifiers into it. - Validate all incoming Slack answers against the current projected pending interview before accepting them.
- Carry at least
-
ControlIntervieweris the runtimeInterviewerimplementation.inform()remains a no-op.ask_multiple()continues to use the trait default, so multiple concurrentask()calls must work correctly when keyed byqid.
-
InterviewBrokerowns only live waiter state.- It does not own canonical pending-question state;
RunProjection.pending_interviewsdoes. - Its server/transport injection surface is
submit(qid, answer) -> Result<(), SubmitError>. - Unknown, already-resolved, or duplicate
qids are rejected by the broker.
- It does not own canonical pending-question state;
-
Event replay must stay backward compatible.
- New interview event fields must deserialize with defaults so old
progress.jsonlentries still replay. - Historical
interview.startedevents that lackquestion_idmust not populatepending_interviews. - Historical runs continue to replay normally, but projection-backed pending interview reconstruction is only guaranteed for runs created after this change.
- New interview event fields must deserialize with defaults so old
-
The old file-claim reattach window is intentionally removed.
- Client detach and reattach no longer matter because the pending question is durable in the projection and can be fetched again later.
- Only loss of the live server-worker control channel is treated as fatal for the waiting interview.
-
First-answer-wins is enforced in memory before transport delivery.
- Projection lookup proves the question is still pending.
- A per-run acceptance guard must then claim
qidexactly once before any answer is sent to the worker. - If transport delivery fails, that claim is released so a later submission can retry.
- If transport delivery succeeds, the claim stays until the interview lifecycle event clears the pending question.
Recommended Delivery Order
Recommended sequencing:
-
Phase A: steps 1 and 2 together
- lock the question id, event shape, replay compatibility, projection model, and API question shape first
-
Phase B: steps 3, 4, and 5 together
- implement
InterviewBroker,ControlInterviewer, canonical answer submission, subprocessstdintransport, in-process override migration, and CLI attach adjustments in one pass - steps 3 and 4 should land together because they both restructure the live answer transport in
server.rs
- implement
-
Phase C: step 6
- migrate Slack after the canonical pending-question model and answer submission path are stable
-
Phase D: step 7
- remove dead implementations, examples, and outdated docs only after the new path is covered by tests
Parallelizable work after Phase A is in place:
- worker-side
ControlInterviewerand JSONL parsing - CLI
ApiQuestionconversion updates - Slack payload and parsing refactor
Implementation Changes
1. Canonical question ids and interview events
Update the workflow and event model so the pending interview can be reconstructed without a live transport object.
-
Modify
lib/crates/fabro-interview/src/lib.rs:- add
Question.id - keep
metadataanddefaultas internal-only fields - export the new broker-backed interviewer implementation
- add
-
Modify
lib/crates/fabro-workflow/src/handler/human.rs:- generate
question.id - emit the richer
interview.started - emit
interview.interruptedforInterrupted - emit
interview.completedforSkipped - emit
question_idoninterview.completedandinterview.timeout
- generate
-
Modify
lib/crates/fabro-workflow/src/event.rsandlib/crates/fabro-types/src/run_event/misc.rs:- extend the interview event variants and payload props to carry the full pending-question surface
- keep event names stable except for adding
interview.interrupted
2. Run projection and API question surface
Update the store projection and public question API to surface the canonical pending interview state.
-
Modify
lib/crates/fabro-store/src/run_state.rs:- add
pending_interviews - add
PendingInterviewRecord - apply insert and cleanup rules for all interview lifecycle events
- add
-
Modify
docs/api-reference/fabro-api.yaml:- expand
ApiQuestionwithstage,timeout_seconds, andcontext_display - leave
SubmitAnswerRequestunchanged
- expand
-
Regenerate generated API clients:
- Rust via
cargo build -p fabro-api - TypeScript via
cd lib/packages/fabro-api-client && bun run generate
- Rust via
3. Replace file transport with worker stdin JSONL
Replace scratch-file answer delivery with a live control channel into the worker.
-
Add
InterviewBrokerandControlInterviewerinlib/crates/fabro-interview/src/lib.rsand supporting modules:ControlInterviewerimplementsInterviewerControlInterviewer::ask(question)registers a oneshot waiter underquestion.idand awaits broker deliveryInterviewBrokerowns only live waiter state, such asHashMap<qid, oneshot::Sender<Answer>>InterviewBroker::submit(qid, answer)resolves a waiter exactly once and returns a typed error for unknown or already-resolved questionsinform()remains a no-opask_multiple()continues to use the trait default and is supported by allowing concurrent per-qidwaiters
-
Modify
lib/crates/fabro-server/src/server.rs:- spawn workers with
stdin(Stdio::piped()) - store a per-run live answer transport instead of a
WebInterviewer - use a bounded per-run
mpsc::Sender<WorkerControl>feeding a dedicated JSONL pump into worker stdin - enqueue control messages with a short timeout; if enqueue times out or the channel is closed, clear any acceptance claim and return a transient server error rather than hanging the request
- run a JSONL pump that writes accepted answers into the worker stdin pipe
- replace the current
get_questionsandsubmit_answerbranches with one projection-backed question query plus one internal answer-submission service - implement canonical answer submission in this order:
- load the pending question from the projection
- validate and build the
Answer - acquire the per-run acceptance guard and claim
qidexactly once - submit the answer to the live transport
- release the claim on transport failure
- keep the claim until interview completion, timeout, or abort clears the pending question
- reject a second concurrent submission with
409once the acceptance guard says the question was already claimed
- spawn workers with
-
Modify
lib/crates/fabro-cli/src/commands/run/runner.rs:- replace
FileInterviewerwithControlInterviewer - start a
stdinreader task that parses versioned JSONLWorkerControlmessages - resolve broker waiters by
qid - treat unexpected control-channel closure as interviewer abort/failure rather than hanging forever
- keep a dedicated stdin reader task running for the life of the worker so answer messages do not block behind unrelated stage execution
- replace
-
Define a wire-specific answer payload.
- Do not serialize internal
Answerdirectly on the wire. - Use an explicit
kindshape such asyes,no,text,selected, andmulti_selected.
- Do not serialize internal
-
Remove scratch-file interview transport.
- delete the request and response file helpers from the server
- stop creating or reading
interview_request.jsonandinterview_response.jsonfor server-managed runs - intentionally remove the old claim-file reattach window because pending questions are now projection-backed and re-fetchable after client reconnect
4. Replace WebInterviewer in the in-process override path
Keep the test override path, but move it onto the same architecture as subprocess runs.
-
Modify
lib/crates/fabro-server/src/server.rs:- replace
ManagedRun.interviewerwith a live answer transport enum such as:- subprocess
stdincontrol sender - in-process broker handle
- subprocess
- keep
create_app_state_with_registry_factory(...)andexecute_run_in_process(...) - pass a broker-backed
Arc<dyn Interviewer>into the override registry instead ofWebInterviewer
- replace
-
Keep the external behavior unchanged for tests.
GET /runs/{id}/questionsstill lists pending questionsPOST /runs/{id}/questions/{qid}/answerstill satisfies waiting in-process interview gates- the difference is that both now go through the projection and canonical submission service
5. Keep CLI attach on the canonical server question path
Do not make attach parse the event payload into the prompt directly in this pass.
-
Keep
lib/crates/fabro-cli/src/commands/run/attach.rsevent-driven behavior:interview.startedremains the trigger- attach fetches pending questions from the server
- attach prompts locally with
ConsoleInterviewer - attach submits answers through the existing server client
-
Update CLI question conversion for any new
ApiQuestionfields that should be shown, especiallycontext_display.
6. Move Slack onto server-owned canonical answer handling
Replace the current WebInterviewer-centric Slack path with a server-owned integration.
-
Add server-side Slack wiring in
lib/crates/fabro-server/src/server.rs:- create a single Slack service on startup when both tokens and
slack.default_channelare configured - subscribe it to the existing
state.global_event_txbroadcast and filterinterview.started,interview.completed,interview.timeout, andinterview.interrupted - post a Slack message for each fresh pending interview
- use completion, timeout, and abort events for best-effort Slack message updates while the in-memory message metadata still exists
- create a single Slack service on startup when both tokens and
-
Refactor
lib/crates/fabro-slack:- remove
WebInterviewerdependencies from the Socket Mode connection path - change parsed interactions to carry
run_idandqid - use structural
action_idvalues and JSONvaluepayloads - preserve structured multiple-choice and multi-select answers
- change freeform thread routing from
thread_ts -> question_idtothread_ts -> (run_id, qid)
- remove
-
Keep Slack delivery state memory-only inside the server.
- store
(run_id, qid) -> posted message metadata - store
thread_ts -> (run_id, qid) - after restart, do not rehydrate these maps
- reject or ignore stale Slack interactions that no longer match a live pending interview
- store
-
Route Slack answers through the canonical internal answer-submission service.
- Slack must not call interviewer objects directly
- if the answer is accepted, update the original Slack message when metadata is still present
7. Remove obsolete interview implementations and docs
After replacement coverage is in place:
- delete
lib/crates/fabro-interview/src/file.rs - delete
lib/crates/fabro-interview/src/web.rs - remove their re-exports from
lib/crates/fabro-interview/src/lib.rs - delete or rewrite
lib/crates/fabro-slack/examples/slack_e2e.rs - update
docs/integrations/slack.mdxso it describes the new server-owned projected-question architecture instead of the old web interviewer model
Public Interface Changes
-
ApiQuestionadds:stagetimeout_secondscontext_display
-
SubmitAnswerRequestdoes not change. -
Run events change as follows:
interview.startedcarries the full pending-question payloadinterview.completedgainsquestion_idinterview.timeoutgainsquestion_idinterview.interruptedis new
-
Slack interactive payloads change from
question_id-only routing to explicitrun_id + qidrouting in the action value payload.
Test Plan
-
fabro-store- add projection tests for pending interview insert and cleanup
- cover
completed,timeout,interrupted, rewind, and terminal run cleanup
-
fabro-workflow- add handler tests that verify:
- generated
question.id - richer
interview.started interview.interruptedonInterruptedinterview.completedonSkipped- correlated
question_idon completion and timeout - old interview events without the new fields still deserialize and replay safely
- generated
- add handler tests that verify:
-
fabro-interview- add broker tests for:
- waiter registration by
qid - answer delivery
- unknown
qid - duplicate answer handling
- control-channel closure behavior
- waiter registration by
- add broker tests for:
-
fabro-server- add tests that verify:
GET /runs/{id}/questionsis projection-backed onlyPOST /runs/{id}/questions/{qid}/answerworks for both subprocess and in-process runs- first-answer-wins returns success once and
409thereafter - no interview scratch files are created for server-managed runs
registry_factory_overridestill supports interview-driven tests withoutWebInterviewer- a full-loop integration test covers:
- server starts a run with a human gate
- worker emits
interview.started - pending question appears in
GET /runs/{id}/questions POST /runs/{id}/questions/{qid}/answersucceeds- the server delivers the answer over worker
stdin - the workflow continues to terminal completion
- add tests that verify:
-
fabro-slack- add tests that verify:
- button payloads carry
run_idandqid - freeform thread routing uses
(run_id, qid) - multi-select remains structured
- stale interactions are rejected after the pending interview is gone
- Slack answers use the same canonical answer-submission service as HTTP
- button payloads carry
- add tests that verify:
Assumptions
Question.metadataandQuestion.defaultremain internal runtime fields and are not exposed inApiQuestion.context_displayis the only contextual prompt payload exposed externally in this pass.- Slack posts only when both Slack tokens and
slack.default_channelare configured. - Slack delivery metadata is intentionally ephemeral and may be lost on server restart.
stdinJSONL is the long-term worker control plane; this pass only implements interview answers, not steering behavior.