Skip to content

factory: a job keeps its brief versions; factory.job_brief reads the newest or its stub - #2111

Merged
santoshkumarradha merged 7 commits into
app/v3from
feat/c25-d-brief-store
Nov 2, 2026
Merged

santoshkumarradha merged 7 commits into
app/v3from
feat/c25-d-brief-store

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

What the job page needs

The job page's Brief (pinned line and Brief tab) needs the job's current brief from the engine: a verdict, a facts row whose numbers come from the steps themselves, two to four blocks from a fixed palette, and what changed since the person last looked. Before any brief is written, the page shows a stub made from engine data only.

This PR stores brief versions on the job and serves the read. The writer (the model call that fills verdict and blocks) is a follow-up PR that stacks on this one.

Wire

  • Method factory.job_brief, params {factory: string, job: int, since?: int}. since is the brief rev the person last saw; without it, changed_since_seen is what the newest version changed from the one before.
  • Hello feature factory.job_brief.
  • Factory route GET /v1/jobs/{id}/brief[?since=N] (listed in api.ServiceRoutes). A factory older than the route answers not found, which the engine turns into conflict with the factory's too-old sentence.
  • The job read (api.Job) gains brief?: {rev: int, status: string}, absent while the job has only its stub, so a page that polls the job re-reads the brief only when one of them moves.

Result (FactoryJobBrief):

{
  "factory": "f1", "job": 7,
  "status": "ready | generating | failed | stub",
  "failure": "only while failed", "failed_after": "proof",
  "since": 2,
  "brief": {
    "rev": 3, "stub": false, "after_step": "proof", "made_at": "2026-11-01T12:00:00Z",
    "model": "deepseek/deepseek-v4.1-flash", "cost_usd": 0.002,
    "issue": "Retries double-send after a worker restart",
    "steps_done": 5, "steps_total": 6,
    "verdict": "Fixed. Retries no longer double-send after a worker restart.",
    "verdict_evidence": [{"step": "test", "try": 2, "kind": "tests", "ref": "go test ./..."}],
    "facts": [{"key": "test", "label": "Test", "value": "42 passed", "ok": true,
               "evidence": {"step": "test", "try": 2, "kind": "tests", "ref": "go test ./..."}}],
    "blocks": [ ... ],
    "changed_keys": ["verdict", "review"]
  },
  "changed_since_seen": ["review"]
}

A stub is rev: 0, stub: true: the issue's line as verdict, steps done of total, facts, blocks: [].

Facts (computed, never written by a model)

One chip per step that reported a structured result, in run order, then the rules chip; at most 5 and the rules chip is never the one cut:

step value ok evidence kind
proof step (IsProofStage) "2 of 3" claims shown of total all shown, at least one claims
check step "40 passed · 1 failed · 3 skipped", or "exit 1" when it named no tests no failures, exit 0 tests / exit
step whose until is clean "clean", "1 finding", "2 findings" done with 0 findings findings
rules (rule_checks) "passed" / "asked": the publish finding while it is on the job's head, else the start finding passed rule_checks (ref publish/start, step "")

key is the step's name (or rules), stable across versions. try is the step's round (at least 1).

Blocks (the palette as Go types, internal/factory/brief.go)

Every block is {kind, heading, ...}. kind is one of the palette's kinds and fills only its own fields:

  • bullets: bullets: [{text, evidence: [ev]}], 1 to 4, at most 14 words each.
  • flow: flow: [{label, nodes: [{text, mark?}]}], 1 to 2 rows, 1 to 6 nodes a row, at most one marked; evidence.
  • diagram: mermaid, nodes: [string] 2 to 8, each drawn in the mermaid; evidence.
  • table: table: {columns: [2..3], rows: [[cell]] 1..5}, rows as wide as columns; evidence.
  • where_to_look: spots: [{id?, file, symbol?, lines, why, evidence}] 1 to 3, and rest (required).
  • proof: proof: {command?, shown, total}; evidence.
  • open_question: questions: [{text, action?: {label, step, ask?}, evidence}] 1 to 2.
  • your_call: options: [string] 2 to 3, only while the job waits on its person; evidence.
  • screenshots: shots: [{label, ref, evidence}] 1 to 2.

ev is {step, try, kind, ref?}. A block's change key is kind/heading (heading lower-cased). BriefBlock.Fault(needsYou) and BriefVerdictFault hold the limits; the writer PR drops anything over them.

Storage

factory.Item.Briefs []BriefVersion (the last 20, oldest first) and Item.BriefWriting {State, AfterStep, Failure, At} for a write that is under way or failed. Item.KeepBrief numbers each version, works out changed_keys against the previous one, and trims. Both are the service's own record and do not travel in the job read (api.Lost says so); the lease writes items field by field, so a worker report cannot overwrite them.

Seen state

factory.job_brief_seen belongs to a parallel PR. Until it lands, the app passes since itself (the last rev it showed). With no since, the answer is relative to the previous version.

Tests

  • internal/factory: table tests for facts (every kind, exit-only check, failed/skipped, clean review, unreported steps, a publish finding on an older head, rules asked, no run), the five-fact cap, the stub, KeepBrief (revs, changed keys, keep 20, end of writing), changed-since, status, every palette limit, the verdict.
  • internal/factory/serve: the stub before any version, a stored version with changed-since and a failed write, 404/422, the job read's brief mark, the published-routes law.
  • internal/appwire: registration, the hello feature, strict params, exact JSON.
  • cmd/codeaf wire harness: the method carries a factory's brief (with and without since) and turns an older factory into conflict.
  • make test-touched BASE=origin/app/v3: every selected test passed on its first run. make test-laws fails on laws that app/v3 already fails without this change (commentlaw on the pipeline-copy files, lockdefer in cmd/codeaf/app.go and others, task-engine complexity, taxonomy); none of them names a file this PR touches. make changelog-check fails on app/v3's existing unnumbered entries.

Limits

  • The stub's verdict is the issue's title. The issue is not summarised yet.
  • Only the latest try of a step keeps a structured result (Phase.Result); facts read that try.
  • Wire-only, no manual change: the brief has no chat or TUI surface, and factory.job_step_edit is not in the manual either.

…the newest or its stub

The job keeps its last 20 BriefVersions on the item. The facts row is
computed from the steps' structured results (test counts or exit,
findings, proof claims shown of total, rule checks), and a job with no
version is answered a stub from engine data alone. GET /v1/jobs/{id}/brief
answers the newest version, its status and the keys changed since a rev;
the job read carries the brief's rev and status. The Brief block palette
is Go types with its limits as faults. The hello says factory.job_brief.
santoshkumarradha and others added 3 commits November 1, 2026 19:46
# Conflicts:
#	internal/appwire/server.go
#	internal/factory/api/codec.go
…y declares

#2109 and this branch each added the same constant and the same helper with
identical bodies; the merge keeps app/v3's declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 2, 2026 01:24
@santoshkumarradha
santoshkumarradha merged commit ea8b130 into app/v3 Nov 2, 2026
@santoshkumarradha
santoshkumarradha deleted the feat/c25-d-brief-store branch November 2, 2026 01:24
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.

1 participant