Pluggable Frontends¶
IMPRESS-A has two independent frontend axes. Both plug into the same engine; neither requires changes below the layer it occupies. The substrate beneath them is not a third axis — nothing above it chooses it — but it is selected by name rather than hard-coded; see the end of this page.
┌──── INTERFACE FRONTEND ─────┐ who talks to the campaign
│ in-process · HTTP+SSE · MCP │
└──────────────┬───────────────┘
│ CampaignControlPlane (one protocol)
┌──────────────┴───────────────┐
│ DECISION FRONTEND │ who decides what runs next
│ A · B · C · D · your own │
└──────────────┬───────────────┘
│ Specifier + Planner (two protocols)
════════════════════════════════ everything below is shared
manager · compose · validate
tools · exec · rhapsody backends
1. The decision frontend — control models¶
Exactly one is active per campaign, fixed at launch (decision 0005): a campaign has one stated methodology and its results are attributable to it.
Four ship — A, B, C and D — plus null and replay outside the taxonomy. Three run
autonomously; model C is the headless mode (decision 0002), not an extra
option bolted onto the side. Model D is the one that is reproducible end to end, which is what
makes it the baseline the other three justify their cost against.
The roster itself is not duplicated here. It lives in policy/registry.MODELS, which
impress-a models prints and tests/test_reasoner_registry.py checks — a table in prose is a
claim nobody runs, and this page once described as "implemented" something nobody could run
(backlog C5). For each model's halves, call count and status, run impress-a models or see
control-models.md, which also covers what each model is shown, what it
may choose, how its reply is constrained, and which campaign fields reach a half. For the pipeline
all of them drive — caller inputs to specified targets to a programmed Stage — see
resolution.md.
Two contracts, and why not one¶
class Specifier(Protocol):
name: str
async def initial_spec(self, goal: Goal) -> Spec: ...
async def revise(self, spec: Spec, ev: SpecEvidence) -> SpecRevision: ...
async def satisfied(self, spec: Spec, ev: SpecEvidence) -> list[str]: ...
class Planner(Protocol):
name: str
async def plan(self, spec: Spec, ctx: PlanningContext) -> Stage | None: ...
async def replan(self, stage, rejection, spec, ctx) -> Stage | None: ...
There was one contract, decide(obs) -> Decision, and it was deleted in phase 11. It answered
"what should the campaign be trying to achieve" and "which tool should run next" in a single
call, so nothing in a transcript could say which half of a control model earned its cost — and
that is precisely what a four-arm comparison of control models has to be able to say.
A reasoner still emits abstract intent, never a concrete DAG: a Stage of TaskMappings,
which the composer turns into a typed graph. That is what keeps a reasoner out of
tool-invocation details and genuinely swappable, and tests/test_layering.py asserts the
import contract that enforces it — policy may import core and nothing else.
replan is the counterpart of the old mandatory on_rejected: validation can refuse a composed
graph, and every Planner needs a defined answer to "your proposed experiment is illegal, too
expensive, or type-incoherent". Returning None — "I have no better Stage" — is a valid answer
and ends the campaign with the gate that refused it named.
Writing your own¶
Implement the two protocols — or subclass BaseSpecifier/BasePlanner, whose defaults are a
fixed Spec and a planner that gives up loudly — then add a row to policy/registry.MODELS with
both builders. Nothing else changes.
from impress_a.core.goal import Goal
from impress_a.core.spec import Spec, Stage
from impress_a.policy import registry as reasoners # policy/__init__ re-exports nothing
from impress_a.policy.planner import BasePlanner, PlanningContext
from impress_a.policy.planners import ThresholdPlanner
from impress_a.policy.specifier import BaseSpecifier, SpecEvidence
class MySpecifier(BaseSpecifier):
name = "mine-spec"
async def initial_spec(self, goal: Goal) -> Spec:
... # Goal -> Spec; see policy/specifiers/explicit.py
# `revise` defaults to "nothing has changed my mind", which is the common case, and
# `satisfied` to the rule-driven answer off the data registry. Overriding the second
# means arguing a campaign's stop condition rather than computing it.
class MyPlanner(BasePlanner):
name = "mine-plan"
def __init__(self, stages: list[str] | None = None, base_replicas: int = 0) -> None:
# Type-driven chain resolution and typed port wiring are correctness, not
# strategy: compose them rather than reimplementing them, as models A, B and C do.
self._mechanics = ThresholdPlanner(
stages=stages, **({"base_replicas": base_replicas} if base_replicas else {}))
async def plan(self, spec: Spec, ctx: PlanningContext) -> Stage | None:
return await self._mechanics.plan(spec, ctx, lineages=2)
reasoners.MODELS["mine"] = reasoners.ReasonerModel(
letter="mine", name="my control model", mode="autonomous",
llm_calls=0, llm_shape="none", status="implemented",
specifier=lambda o: MySpecifier(),
planner=lambda o: MyPlanner(stages=o.stages, base_replicas=o.replicas),
note="what is true of this model that a reader would otherwise have to discover")
ReasonerOptions (o above) is the only configuration a builder sees, and cli.POLICIES is
derived from MODELS, so the letter becomes a valid --model with no second list to update. A
builder that needs something only CampaignSpec has wants another ReasonerOptions field, not an
import — policy may import core only.
Composable wrappers¶
A half is decorated rather than subclassed. impress_a.policy.wrappers provides:
StageGuard— an unconditional external guard on a Planner half, attached by the CLI unless--no-guardis passed. It carriesforbid_toolsand refuses rather than edits: dropping a forbidden tool would leave a hole where a producer was, and a Stage is wired by port, so removing a task leaves its consumers pointing at nothing. Two of its predecessor's three corrections moved somewhere they cannot be bypassed — the replica cap is applied by the executor against the campaign's ownreplicas, and a task serving no objective is refused by the Reviewer's coverage gate — because--no-guardcould switch both off and should never have been able to.forbid_toolsitself is a stopgap for phase 10's gate 6, which refuses a mock-toolkit node undertool_delivery: realand cannot be disabled at all.LoggingSpecifier/LoggingPlanner— provenance decorators, recording that a half authored a revision or a Stage. Not redundant with the executor's own records, which say what it applied: the four-arm comparison reads the second to tell a model that proposed nothing from one whose proposals were refused.NullSpecifier/NullPlanner— the no-op baseline. An empty Spec makescomplete()true, so the campaign ends through the designed path rather than aStopthe driver must recognise.
Degraded mode is declared, not improvised¶
Every model that depends on something outside the job has a defined answer when it does not
arrive, and the transition is an explicit logged state change — never a silent no-op that
leaves an allocation idling while the campaign quietly stops adapting. reasoning.degraded writes
one event name whatever degraded, so one query over transitions finds them all.
Which models, and what each one does, is in
control-models.md. Read it there
rather than here: this section used to say "Models B and C" and omit model A's rule cascade, and to
describe a fallback as what a caller timeout activates when on_timeout in fact defaults to
stop and ExternalPlanner refuses fallback unless one is declared
(policy/planners/external.py:56).
2. The interface frontend — control-plane adapters¶
One transport-agnostic protocol; adapters translate transport only (decision 0007). No adapter may add an operation absent from the core, or the semantics fork between consumers.
| Operation | Purpose |
|---|---|
submit / pause / resume / stop |
Lifecycle |
observe |
Returns the same CampaignObservation an in-process half is given |
events |
Append-only stream with a resumable cursor |
steer |
Inject a directive — this is model C's planning call, routed to a half by its role key |
artifacts / provenance |
Retrieve results and the audit trail |
ingest_measurement |
Out-of-band P8 arrival; accepted even after termination |
infer |
One prompt to the campaign's locally hosted reasoner, answered as text |
infer is in the core protocol, and therefore in every adapter, for the reason decision 0007 gives:
an operation that only one transport carries forks the semantics. It also makes a split that is easy
to miss — the model runs on the execution side, as a prompt_task on the engine's ai route,
sharing that process's GPUs; only the prompt and the answer cross the socket. A reasoner in the
control process therefore decides where the campaign goes while its weights sit beside the tools.
A campaign that declares no local model refuses the call rather than falling back to a hosted one.
The observe symmetry is the point: an external caller, an LLM oracle and a user-written half all
consume the identical observation and answer in the identical vocabulary — a SpecRevision from the
Specifier side, a candidate Stage from the Planner side. "Informed monitoring" means parity of
evidence, not a progress bar.
| Adapter | Status | Fits |
|---|---|---|
| in-process | implemented | HITL agents co-located in the job; tests; the reference implementation |
| HTTP + SSE | implemented (control/http.py) |
A reasoner outside the allocation; pipelining-as-a-service |
| MCP | not yet built | An external agent driving a campaign, submit-and-poll |
The HTTP adapter is exercised end to end by tests/test_http_adapter.py on loopback, deliberately:
a transport nothing runs looks finished while rotting. It is built on asyncio.start_server rather
than a web framework, speaks JSON plus one SSE stream, and is not public-facing — no auth, no TLS,
bind it to localhost or a private interface.
Run operations are part of the core protocol, not something a transport adds: submit_run,
list_runs, run_result, cancel_run. Admission is synchronous — 202 with a run id, or 409 with
the ValidationFailure that refused it — because a rejection severed from the request that caused it
leaves nothing to bound retries against.
Steering carries no privilege¶
A caller's directive is composed, type-checked, gated and budget-checked exactly as any Planner's
Stage is — including the Reviewer's coverage check against the applied Spec. A rejection comes back
to the caller through replan with the gate and the reason, for another turn. A caller may add and
delete objectives but may not declare one satisfied: satisfaction is computed, not asserted
(see resolution.md step 8).
The substrate beneath the two axes¶
Backends are selected by name from site configuration and resolved through
rhapsody.backends.get_backend(), so no backend class is named outside exec/backend.py:
concurrent for laptop and mock, dragon / radical / dask on HPC. That name selects the
campaign's compute route; the same engine also carries local for adapters and QC, and ai when
a local reasoner is declared.
Running the two processes¶
The interface frontend described above is reachable from a shell as of phase 7 of
plans/control-plane-refactor.md. Until then it was reachable only from tests/, and this
document described it as implemented anyway (backlog C5).
impress-a serve campaigns/<spec>.yaml # execution: executor, Reviewer, Deployer,
# stage executor, the one asyncflow engine.
# No reasoner.
# it prints: campaign <id> serving on http://127.0.0.1:<port>
impress-a control --connect <url> --campaign <id> --model D
What the split is and is not for. It is tempting to read it as the thing that keeps reasoning
from blocking execution. That independence is already there in one process: impress-a run races
the executor's pump against the reasoner's conduct as two asyncio tasks, and the shipped test for
this seam (tests/test_split_process.py) exercises the same property either way — "in one process
that independence is a property of the loop; across a socket it is a property of the process
boundary." What the boundary adds is tolerance of a reasoner that blocks synchronously, and
honesty for model C, where an external caller really is a separate program. Note also what does not
move: the Spec Loop and the Planning Loop are co-resident because a plan consumes the revision just
made, and the Reviewer and Deployer stay execution-side because the dry-run instantiates task agents
and needs the toolkit. See decision 0015.
Four more things worth knowing before using it.
Loopback is the security boundary. The plane has no auth and no TLS, so both ends belong on
the same compute node; --host exists for a deliberate choice rather than a casual one
(backlog C7).
The execution side keeps the engine, and only the engine's loop matters.
WorkflowEngine.__init__ captures the loop it is built on, and an engine built elsewhere
dispatches nothing while looking healthy - two allocations were lost to that. The control
process has its own loop and never touches an engine, which is why it is free to have one.
A lost control process drains and stops. control_liveness_timeout_s on the campaign spec
bounds the silence; on expiry the executor stops admitting, lets in-flight work finish and be
absorbed, and stops with a reason naming the loss. Draining rather than aborting is deliberate:
cancellation is advisory, so that work will finish whether or not anyone collects it.
The bound arms only once a plane has registered, and is suspended while work is in flight. Both conditions were learned the expensive way: in a single-process campaign the "caller" is the role driver in the same process, silent exactly when it is busy awaiting the tasks it just asked for, and job 23671367 lost three arms after one cycle each to a 120 s bound against ~180 s of normal task time.
impress-a run --model C is refused, because run attaches no plane and model C means an
external caller steers. It used to time out every five seconds and run its fallback, reporting
a model-D campaign as model C (backlog C6).