Skip to content

factory: the facts the desktop needs on the wire (lane W) - #2481

Merged
santoshkumarradha merged 3 commits into
factory/general-intakefrom
factory/gi-wire
Nov 6, 2026
Merged

santoshkumarradha merged 3 commits into
factory/general-intakefrom
factory/gi-wire

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

Lane W of the general-factory wave: the facts the new desktop UI reads, each computed once in internal/factory and sent. The desktop never re-derives them. Spec: docs/design/factory-general-ui/DESIGN.md §0 in codeaf-desk #279.

Wire (additive; every field is ignored by older clients)

Field Shape Hello word
job.source {name, ref?, url?}: github + owner/repo#N + issue URL, jira + ENG-142, inbox:ops + A1, terminal/chat factory.job_source
job.repo_url read off the PR/issue address (keeps a non-github.com host); falls back to https://github.com/<owner>/<name>; absent without owner/name factory.job_source
job.route {rule, answer?: {yes, why, model?}} from Item.Route / Item.Judged[rule] factory.job_source
job.steps_done / job.steps_total always present; factory.StepCount factory.job_steps
job.runs_on, step.runs_on {model, from}, from ∈ step, job, one_model, effort, factory, worker, runner; set on reads only factory.job_runs_on
entry.author person | engine | agent on transcript entries agents.entry_author
desk.source_ref the raw Item.SourceRef, for the client seam's round trip —

The existing job.model keeps its meaning (the person's pick for the job), so it is not repurposed. runs_on is never set by FromItem, which keeps it out of worker reports: an older factory rejects unknown fields.

The one step count

There were three counts. briefProgress counted run phases (skipped ones included), job.step.count was len(Phases), and the desktop counted its own rail rows. factory.StepCount replaces all three: run phases minus skipped ones, plus switched-on steps the run has not reached yet. The Brief and the wire both call it.

Model resolution fix

  • Before: step/job pick → (one model: launch) → effort tier → factory default → cfg.Model. For a profile with no typed model, cfg.Model is config.ChatDefaultAt = config.DefaultModel. The chain was also split across factoryStepModel and stageOpenModel.
  • After: a single factory.StepModel: step pick → job pick → one model → effort → factory default (the queued one, else the current one) → the person's worker seat (config.TierSeatAt(profile, worker), pinned or routed) → the runner's launch model.
  • Callers: the stage maker (factoryOpenModel), the queue's model (defaultModel) and the wire's runs_on (serve.Config.RunnerModels). What the page shows is what runs.

Chat authorship and suggestions

  • appEntryAuthor sets author from the producer's marks, not from the text: user lines are person, except [carry on] lines (session.IsCarryOn), which are engine. Runner progress lines, notes and summaries are engine; answers and tools are agent.
  • appMarkStepBrief marks a step chat's first message (the brief the maker submits on Open) as engine, using the owner record beside the journal.
  • session.cleanReplySuggestion drops a draft that opens with [carry on] or names a belt tool with an underscore (stage_result is always included). It is filtered where drafts are made.

Proof scratch (PR #148 root cause)

  • Cause: no engine code makes .proof-prefix-NNNN. The proof step's model needed a second copy of the repo and had nowhere outside the checkout to put it. readChange counts every untracked file and commitApproved runs git add -A, so the copy became part of the change, tripped the protected-path approval and was committed.
  • Fix, first half: each conversation step gets run.ScratchDir(worktree) under the OS temp dir. It is made before the step opens, named in the brief ("everything left in the checkout is published") and removed on Discard.
  • Fix, second half: repoCopies finds a new top-level folder that mirrors the repo's tracked files. It must be hidden or copy at least half the repo. readChange leaves it out. commitApproved excludes it from the add and runs git rm --cached on a copy a step already committed. The folder stays on disk.

Also

inbox.Split now delegates to factory.SourceKey (the same rule, in one place).

TestEveryFieldRoundTrips was red on the base, failing on SourceRef, Route and Judged. It is green now: Item.Judged is named in Lost (only the deciding rule's answer crosses).

The lanes manual heading gains "why does this model start with ~": the new factory text shifted retrieval for that probe.

Proof

  • make test-laws: green.
  • make test-focus PKGS='./internal/factory/... ./internal/appwire' RUN=.: 24 packages ok. TestReportGoroutineEndsWithoutLosingSpend failed once while test-laws was running alongside, then passed with -count=3 alone. The same run before rebasing hit failures already fixed by 106097c.
  • cmd/codeaf: RUN='Entr|Transcript|StepStream|StepChat|Stage|Factory.*Model|Effort|Suggest|Hello|Feature' ok.
  • internal/session: the three TestReplySuggestion* tests only.
  • New tests:
    • TestStepCountIsTheOneCountTheBriefReadsToo, TestStepModelTriesEachRungInOrder, TestNextModelStageIsTheCurrentOrNextConversation, TestJobSourceAndRepoURL
    • TestAJobCarriesItsSourceRouteAndStepCount, TestRunsOnSaysTheOneResolutionOnReadsOnly
    • TestAStepWithNoFactoryDefaultRunsOnThePersonsWorkerModel
    • TestATranscriptEntrySaysWhoWroteIt, TestReplySuggestionNeverOffersWordsAddressedToTheModel
    • TestAProofRunLeavesNoExtraFilesInTheDiff, TestACommittedCopyIsTakenOutAndANewPackageStays

Docs: docs/design/app-v3/PROTOCOL.md ("Factory job facts", "Transcript entry author"); manual factory.md and factory-stage-conversations.md (the model a step runs on).

🤖 Generated with Claude Code

job.source/repo_url/route, one step count (steps_done/steps_total), runs_on
from the one model chain (which now reaches the person's worker model before
the launch default), entry.author on transcript entries, no machinery in
suggested replies, and a step scratch folder outside the checkout with
repository copies kept out of the change and the commit.
@santoshkumarradha
santoshkumarradha merged commit f2b96ae into factory/general-intake Nov 6, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the factory/gi-wire branch November 6, 2026 22:08
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