Repository navigation
factory: a job keeps its brief versions; factory.job_brief reads the newest or its stub - #2111
Merged
Merged
Conversation
…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.
…te states are status words
# Conflicts: # internal/appwire/server.go
# 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
factory.job_brief, params{factory: string, job: int, since?: int}.sinceis the brief rev the person last saw; without it,changed_since_seenis what the newest version changed from the one before.factory.job_brief.GET /v1/jobs/{id}/brief[?since=N](listed inapi.ServiceRoutes). A factory older than the route answers not found, which the engine turns intoconflictwith the factory's too-old sentence.api.Job) gainsbrief?: {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:
IsProofStage)"2 of 3"claims shown of totalclaims"40 passed · 1 failed · 3 skipped", or"exit 1"when it named no teststests/exitclean"clean","1 finding","2 findings"findingsrule_checks)"passed"/"asked": the publish finding while it is on the job's head, else the start findingrule_checks(refpublish/start, step"")keyis the step's name (orrules), stable across versions.tryis the step's round (at least 1).Blocks (the palette as Go types,
internal/factory/brief.go)Every block is
{kind, heading, ...}.kindis 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, andrest(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.evis{step, try, kind, ref?}. A block's change key iskind/heading(heading lower-cased).BriefBlock.Fault(needsYou)andBriefVerdictFaulthold the limits; the writer PR drops anything over them.Storage
factory.Item.Briefs []BriefVersion(the last 20, oldest first) andItem.BriefWriting {State, AfterStep, Failure, At}for a write that is under way or failed.Item.KeepBriefnumbers each version, works outchanged_keysagainst the previous one, and trims. Both are the service's own record and do not travel in the job read (api.Lostsays so); the lease writes items field by field, so a worker report cannot overwrite them.Seen state
factory.job_brief_seenbelongs to a parallel PR. Until it lands, the app passessinceitself (the last rev it showed). With nosince, 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/codeafwire harness: the method carries a factory's brief (with and withoutsince) and turns an older factory intoconflict.make test-touched BASE=origin/app/v3: every selected test passed on its first run.make test-lawsfails 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-checkfails on app/v3's existing unnumbered entries.Limits
Phase.Result); facts read that try.factory.job_step_editis not in the manual either.