Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6a21f01
wip: review loops
xserban Nov 28, 2026
b57a707
Merge branch 'conductor-reconcile' into review-loops
xserban Nov 28, 2026
502a0a5
feat(conductor): review loops on frame and write, a conducted frame, …
xserban Nov 28, 2026
a08a7c0
fix(conductor): a brief protocol is ready at once; a blocked queue st…
xserban Nov 28, 2026
c1e701c
fix: fingerprint in review_output (writing-import rule); tool list test
xserban Nov 28, 2026
c9aee89
fix: refuse at frame a query the source would refuse; pause on a gath…
xserban Nov 28, 2026
1e0deb5
fix(screening): completed batches count against the tier screen cap; …
xserban Nov 28, 2026
e5eefb3
perf(dedup,conductor): title pairs prefiltered in C; one memo scope p…
xserban Nov 28, 2026
d66fa98
fix(search): drop the deprecated OpenAlex concepts.id filter key (lay…
xserban Nov 28, 2026
b32c387
feat(brief): rank the screening queue before the first run; arXiv-onl…
xserban Nov 29, 2026
e52dd57
fix(review-loop): tell a revising proposer its round and findings in …
xserban Nov 29, 2026
7fd6d53
feat(brief): cap evidence rows per work at 8 and name the headline re…
xserban Nov 29, 2026
1b81ed6
style: format
xserban Nov 29, 2026
e385bab
style: file-level noqa for imported fixtures
xserban Nov 29, 2026
c5afa77
feat(brief): screen by yield to 100, acquire 30, rank lexically, 30 runs
xserban Nov 29, 2026
9afb8b8
feat(write): coverage in the limits; revision and coverage rules for …
xserban Nov 29, 2026
a0d7030
feat(brief): screen every record, 100 a run, 3 hours; acquire in rank…
xserban Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions docs/MAP.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions docs/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -1298,3 +1298,27 @@ Status: new · Added: 2026-11-24 · Slice: — · Depends on: the search record
**Why:** programme runs will make absence claims constantly ("nobody compared compression rates for 3D"), and absence is the hardest claim to support. Today an absence is a sentence in a report; it should be a derived statement from the search record.
**Rigour notes:** computed from the recorded searches and screening, never typed; wording is fixed by the platform ("not found in these sources"), so an agent cannot upgrade it to "does not exist"; a claim goes stale when the search record grows (new watch results).
**Open questions:** whether it is a report section over existing events (no new event type) or needs its own record; the link to the gap-finder statistics; how a watch run re-checks an open absence claim.

## Shakedown of the tier runs (added 2026-11-28)


### IDEA-145 — Narrative report in the style of a deep-research report, with every sentence verified
Status: new · Added: 2026-11-28 · Slice: — · Depends on: the `write` stage and drafts (rf-write, `draft_*`), anchored passages (`factory/document/`), manuscript verification; Living Syllabus `docs/DESIGN.md` (note pipeline)
**What:** a "complete report" output like Gemini Deep Research's: a narrative across threads (which primitive wins where, and why), with a selection playbook, written from the project's read set, where every evidence sentence cites an anchored paragraph and a short quote and passes an independent claim check. The researcher suggested writing it with Gemini, for its larger context window.
**Why:** deep-research reports are getting good at connecting findings across many papers; the factory's reports (`brief note`, `report evidence`, `answers export`) are organised around extracted rows and do not connect threads. Seen on 2026-11-28: a 73-reference Gemini report on linear attention for vision and medical imaging (about 1 h) read well, but 2 references resolved to the wrong paper, one cited an author's homepage, and about 30 pointed to second-hand sites.
**Rigour notes:** narrative sentences are labelled background, evidence or interpretation; evidence sentences must resolve to an anchored paragraph whose text contains the quote (platform check, no model); the claim check runs in a separate session, preferably another model family; report claims from external tools stay leads, never evidence. Build once and share with Living Syllabus notes (outline → draft → check) rather than as a second writer.
**Open questions:** using Gemini needs a ruling: CLAUDE.md says all judgement comes from Claude through MCP; a Gemini CLI session acting as an MCP client would keep the platform model-free but changes that rule; provenance must name the tool and model. Whether the shakedown runs (`la-brief`, `la-deep`, 2026-11-28) show which parts a report needs before building it.

### IDEA-146 — `brief new` cannot set the autonomy level (shakedown finding)
Status: new · Added: 2026-11-28 · Slice: 9 · Depends on: decision 164 (autonomy levels), `services/project.py::init_project`
**What:** `factory brief new` records the question but has no `--autonomy-level`; `factory init` takes `--tier` and `--autonomy-level` but records no question. An autonomous `brief` or `deep` project with its goal cannot be created from the CLI. The service accepts both (`init_project(..., tier=, autonomy_level=)` then `state_goal`). Found while setting up the first real tier runs.
**Why:** the faster tier path is meant to run like a deep-research tool; its first step should not need a script.
**Rigour notes:** the level is fixed at init (decision 161), so the option belongs on the creating command, not a later one.
**Open questions:** add `--autonomy-level` to `brief new`, or let `init` take the goal.

### IDEA-147 — A reviewer of another model family in the review loops
Status: new · Added: 2026-11-28 · Slice: 9 · Depends on: the review loops (plan 2026-11-28-review-loops), a decision on the rule that judgement comes from Claude through MCP
**What:** let the reviewer of a review loop (stages `review-frame`, `review-write`), or an extra auditor after it, be a session of another model family: Gemini CLI first, launched headless by the runner as an MCP client of the factory, with its model named in the provenance. Antigravity only if it can run without its interface.
**Why:** two Opus sessions are independent but share the same blind spots; a reviewer of another family catches the misreadings both would make. The researcher asked for it on 2026-11-28.
**Rigour notes:** the platform stays model-free (the reviewer is an outside process, as `claude -p` is); the verdict is recorded with the same validation as any reviewer's; agreement between families is measured, not assumed.
**Open questions:** the ruling on CLAUDE.md's "All judgement comes from Claude through MCP" (shared with IDEA-145); whether Gemini CLI honours an allow-list as strictly as `--allowedTools`; cost and context per round.
97 changes: 97 additions & 0 deletions docs/plans/2026-11-28-review-loops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Plan: review loops in the conductor, and a conducted frame

Date: 2026-11-28. Branch `review-loops`. Scope: slice 9 (tiers and autonomy), conductor C8.

## Why

The first live tier run (living-syllabus shakedown `la-brief`, tier brief, autonomous) stopped in
its first step. Four causes, all in the conducted frame:

1. The `frame` stage runs `rf-frame`, an interactive skill (interview, quote back, wait for the
researcher), while the conducted prompt says nobody answers. Its allow-list also lacks the
reads the skill calls (`briefing_get`, `decision_list`).
2. No tool records the tier's protocol template (`ProtocolTemplate.instantiate` is called only
in tests), so a frame session must write a full `ProtocolSpec` by hand.
3. At brief and deep the conductor waits after frame on two human gates, `protocol.ready` and
`protocol.press_confirm` (the second is declared by no module, so it never closes), although
`rf-brief` says no protocol gate binds in those tiers.
4. The prompt ends a run on any refusal, a refused read included.

A fifth (a finished CLI-started run was never closed) is fixed in PR #80.

The researcher also asked that judged outputs be checked by a second session and revised, in a
loop with escapes, rather than in one pass.

## Design

### Review loop (steps `frame` and `write`)

At `supervised` and `autonomous`, a loop step has the roles proposer, verifier and, when an agent
may close one of its gates, auditor. The verifier of a loop step is a reviewer session (stage
`review-frame` or `review-write`, skill `rf-review`) that records one verdict per round with
`review_record`: `accept`, or `revise` with findings. Each finding has a severity (`blocking` or
`minor`), a target, a text, and optionally the id of an earlier finding it repeats. The platform
numbers rounds and findings (`R2.F1`) and fingerprints the step's output when the verdict is
recorded (frame: question, protocol and seeds; write: the drafts). On `revise` the proposer runs
again; it reads the findings with `review_view` and answers each blocking one with `review_reply`
(`addressed` or `declined`, with a note) before the reviewer runs again.

The loop ends, computed from the log, when:

- the verdict is `accept` (outcome `accepted`);
- round 5 is reached (`max-rounds`);
- every blocking finding of a round repeats a blocking finding of the round before and there are
no fewer of them (`no-progress`);
- the output's fingerprint equals that of an earlier round (`repeat`: unchanged or reverted);
- the run or time budget is spent (the conductor's existing budget pause).

A loop that ends with blocking findings still open continues at tiers brief and deep, and the
conductor records `conductor.review_ended` with the open finding ids; the evidence note lists
them. At other tiers it pauses with reason `review-disputed`. A reviewer run that records no
verdict pauses with `review-missing`; `advance --retry` runs the reviewer again.

Bulk steps (screen, extract) keep their sampled second pass and audit: a loop per record would
cost much and add little. The develop step keeps its own lead/drafter/critic sessions; moving it
onto this loop is a follow-up.

### Conducted frame

- Stage `frame` runs skill `rf-frame-conducted`: record the stated goal verbatim as `raw_goal`,
fill the question from it (unknowns as open slots), add the seeds the goal names, and record the
tier's protocol with `protocol_from_template`. No interview and no decisions: they are optional
at `exploratory` and a conducted session has no researcher.
- `protocol_from_template` (new tool): the agent gives criteria and the planned queries; the
platform instantiates the tier's template (`ProtocolTemplate.instantiate`), enforcing its
sources and queries per source, names the project's creator as reviewer of record, and records
the protocol as a draft through `record_protocol`.
- At tiers brief and deep the frame step's protocol gates do not bind in the conductor
(`TIER_UNBOUND_GATES`); the review loop stands in for them, and the note says so.

### Models

`frame`, `write`, `review-frame` and `review-write` run on Opus 5.5 (few, short, judged sessions).
Screening and extraction stay on Haiku. A reviewer of another model family (Gemini CLI as an MCP
client) needs a ruling on the rule that judgement comes from Claude: backlog.

### Prompt

A refused read is reported and the session continues; a refused write is reported and the
session stops.

## Events

- `review.verdict_recorded` (agent): conductor id, step, stage id, round, verdict, findings,
fingerprint, summary.
- `review.reply_recorded` (agent): conductor id, step, round, replies.
- `conductor.review_ended` (system): conductor id, step, stage id, outcome, reason, rounds, open
finding ids.

No projection table: the loop state is derived from the log, as the conductor's is.

## Tests (TDD)

Service: verdict and reply validation (only during the step's reviewer or proposer run, one per
round, `accept` without blocking findings, replies cover every blocking finding), round and
finding numbering, fingerprints. Conductor: accept after one round; revise then accept; each
escape; continue at brief, pause at pilot; missing verdict; frame gates unbound at brief.
Template tool: sources and per-source caps enforced; reviewer of record is the creator.
17 changes: 17 additions & 0 deletions platform/src/factory/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,20 @@ def status_cmd(ctx: typer.Context, as_json: Annotated[bool, _JSON] = False) -> N
with _reporting_errors():
status = conductor_service.conductor_status(_resolve_project(state))
_echo(status, as_json)


@conductor_app.command("release-review")
def release_review_cmd(
ctx: typer.Context,
note: Annotated[str, typer.Option("--note", help="Why the run may go on.")] = "",
) -> None:
"""Let the conductor go on past a review loop that ended with blocking findings open (pause
`review-disputed`); the findings stay open and labelled. Your act, recorded as you."""
from factory.cli.main import _reporting_errors, _resolve_project, _state
from factory.services import review_loop

state = _state(ctx)
with _reporting_errors():
project = _resolve_project(state)
released = review_loop.release(project, project.human_actor(), note)
typer.echo(f"released the review of step {released.step}; advance to go on")
10 changes: 10 additions & 0 deletions platform/src/factory/events/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from factory.model.conductor import (
ConductorFinished,
ConductorPaused,
ConductorReviewEnded,
ConductorStarted,
ConductorStepFinished,
ConductorStepStarted,
Expand Down Expand Up @@ -203,6 +204,11 @@
RegionReviewed,
RegionSnapshotTaken,
)
from factory.model.review_loop import (
ReviewReleased,
ReviewReplyRecorded,
ReviewVerdictRecorded,
)
from factory.model.reviews import ReviewDecided, ReviewRequested
from factory.model.runner import PipelineFinished, PipelineStarted, RunnerFinished, RunnerStarted
from factory.model.screening import (
Expand Down Expand Up @@ -432,6 +438,10 @@ def default_catalog() -> EventCatalog:
catalog.register(EventType("conductor.step_finished", ConductorStepFinished, 1))
catalog.register(EventType("conductor.paused", ConductorPaused, 1))
catalog.register(EventType("conductor.finished", ConductorFinished, 1))
catalog.register(EventType("conductor.review_ended", ConductorReviewEnded, 1))
catalog.register(EventType("review.verdict_recorded", ReviewVerdictRecorded, 1))
catalog.register(EventType("review.reply_recorded", ReviewReplyRecorded, 1))
catalog.register(EventType("review.released", ReviewReleased, 1))
catalog.register(EventType("work.marked_core", WorkMarkedCore, 1))
catalog.register(EventType("work.unmarked_core", WorkUnmarkedCore, 1))
catalog.register(EventType("notice.observed", NoticeObserved, 1))
Expand Down
122 changes: 122 additions & 0 deletions platform/src/factory/mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,128 @@ def record() -> JsonValue:

return _reply(project, record, rename=spec_path)

@server.tool()
def protocol_from_template(
project: str,
criteria: list[dict[str, JsonValue]],
queries: list[dict[str, JsonValue]],
role: str,
model: str,
skill: str,
reason: str = "",
effects: dict[str, str] | None = None,
) -> dict[str, JsonValue]:
"""Record the protocol of the project's tier from its template: you give the criteria and
the planned queries, the platform fills sources, screening, extraction schema and snowball
plan, enforces the template's sources and queries per source, and names the project's
creator as reviewer of record. At brief and deep (run without a person) it is recorded
ready so screening can start, and a later call is an amendment: give `reason` (the review
finding ids it answers) and `effects`, one of `loosened`, `tightened` or `clarified` per
changed criterion id. At other tiers it is recorded as a draft. Gaps are returned."""

def record() -> JsonValue:
from factory.model.protocol import Criterion, CriterionEffect, PlannedQuery
from factory.services import tier_protocol

opened = open_project(settings, project, session=session, clock=clock)
actor = make_agent_actor(settings, session, role, model, skill)
parsed_criteria = [
parse_input(Criterion, c, f"criteria.{i}") for i, c in enumerate(criteria)
]
parsed_queries = [
parse_input(PlannedQuery, q, f"queries.{i}") for i, q in enumerate(queries)
]
try:
declared = {k: CriterionEffect(v) for k, v in (effects or {}).items()}
except ValueError as exc:
raise FactoryValidationError(
[ValidationIssue("effects", "loosened, tightened or clarified")]
) from exc
result = tier_protocol.record_from_template(
opened, actor, parsed_criteria, parsed_queries, reason=reason, effects=declared
)
data = result.model_dump(mode="json")
data["gaps"] = [
{"field": spec_path(gap.field), "reason": gap.reason} for gap in result.gaps
]
return _withheld(opened, data)

return _reply(project, record, rename=spec_path)

@server.tool()
def review_view(project: str) -> dict[str, JsonValue]:
"""The review loop of the conductor's current step (frame or write): the verdicts so far,
each with its numbered findings, the proposer's replies, the round cap and whether the
loop has ended. Read-only."""

def view() -> JsonValue:
from factory.services import review_loop

opened = open_project(settings, project, session=session, clock=clock)
return review_loop.review_view(opened).model_dump(mode="json")

return _reply(project, view, include_work_ids=False)

@server.tool()
def review_record(
project: str,
verdict: str,
summary: str,
role: str,
model: str,
skill: str,
findings: list[dict[str, JsonValue]] | None = None,
) -> dict[str, JsonValue]:
"""Record your verdict on the step's output, once per review run: `accept` (no blocking
finding) or `revise` (at least one). Each finding: `severity` (`blocking` or `minor`),
`target` (the slot, criterion, query, section or sentence), `text` (what is wrong), and
`repeats` (the id of an earlier finding it restates, when it is still open). The platform
numbers the round and findings and fingerprints the output. Only the reviewer role of a
conducted loop step may call it."""

def record() -> JsonValue:
from factory.model.review_loop import FindingInput
from factory.services import review_loop

opened = open_project(settings, project, session=session, clock=clock)
actor = make_agent_actor(settings, session, role, model, skill)
if verdict not in ("accept", "revise"):
raise FactoryValidationError([ValidationIssue("verdict", "accept or revise")])
parsed = [
parse_input(FindingInput, f, f"findings.{i}") for i, f in enumerate(findings or [])
]
payload = review_loop.record_verdict(
opened, actor, "accept" if verdict == "accept" else "revise", parsed, summary
)
return payload.model_dump(mode="json")

return _reply(project, record, include_work_ids=False)

@server.tool()
def review_reply(
project: str,
replies: list[dict[str, JsonValue]],
role: str,
model: str,
skill: str,
) -> dict[str, JsonValue]:
"""Answer the findings of the last `revise` verdict of your step, after revising the
output: one reply per blocking finding (`finding_id`, `action` `addressed` or `declined`,
`note` saying what changed or why not). Minor findings may be answered too. Only the
proposer of a conducted loop step may call it, once per round."""

def record() -> JsonValue:
from factory.model.review_loop import Reply
from factory.services import review_loop

opened = open_project(settings, project, session=session, clock=clock)
actor = make_agent_actor(settings, session, role, model, skill)
parsed = [parse_input(Reply, r, f"replies.{i}") for i, r in enumerate(replies)]
payload = review_loop.record_reply(opened, actor, parsed)
return payload.model_dump(mode="json")

return _reply(project, record, include_work_ids=False)

@server.tool()
def protocol_press_review(
project: str,
Expand Down
19 changes: 19 additions & 0 deletions platform/src/factory/model/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
"trust-pause",
"human-gate",
"refused",
"review-disputed",
"review-missing",
"blocked",
]
ReviewOutcome = Literal["accepted", "escaped"]
ReviewEndReason = Literal["accepted", "max-rounds", "no-progress", "repeat"]


class ConductorStarted(StrictModel):
Expand Down Expand Up @@ -111,3 +116,17 @@ class ConductorFinished(StrictModel):
conductor_id: str = Field(pattern=CONDUCTOR_ID_RE)
steps_done: int = Field(ge=1)
runs: int = Field(ge=0)


class ConductorReviewEnded(StrictModel):
"""The review loop of a step ended (plan 2026-11-28-review-loops): computed from the
`review.*` events of the step, never typed by an agent. `open_findings` are the ids of the
blocking findings of the last verdict when the loop escaped; empty when accepted."""

conductor_id: str = Field(pattern=CONDUCTOR_ID_RE)
step: int = Field(ge=0)
stage_id: NonBlank
outcome: ReviewOutcome
reason: ReviewEndReason
rounds: int = Field(ge=1)
open_findings: tuple[NonBlank, ...] = ()
Loading
Loading