Repository navigation
factory: the router — routing rules, the AI filter and priority order (lane R) - #2480
Merged
Merged
Conversation
factoryIntakeOwned hands intake.Options.Judge the floor's model-backed judge (factoryJudge), so the app, a team server and the command line ask a routing rule's question the same way, booked as `factory filter`. A rule names no model yet, so the factory's default answers. The manual's routing section now defers to lane A's page for model, cost and what the model sees, and keeps what intake adds: the answer kept on a job, "couldn't judge", the activity line and test these rules.
santoshkumarradha
force-pushed
the
factory/gi-router
branch
from
November 6, 2026 21:24
abfb370 to
670fa34
Compare
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.
Lane R of the general-factory wave (docs/design/factory-general/DESIGN.md §1, §1b).
What changes
internal/factory/route).Matchesis pure and table-tested. A source matches a job'sOriginorSourceRef, whole or up to://.AnswerKeyis a 16-hex SHA-256 of the question, title, body and sorted labels.Cleanis the one check of a table, shared by the store, the factory service and the wire.Previewbacks the "test these rules" view.store.Routes/KeptRoutes/SetRoutes(rules, by, expect)usefactory-routes.json, kept beside the house rules. An unreadable file is an error, never an empty table.factory.routes,factory.routes_set(operator only,expectgivesstale) andfactory.routes_test(no writes, no model calls), behind the hello featurefactory.routes. The factory side isGET/PUT /v1/routeswith the phase marker, plusPOST /v1/routes/test.Intake.admitis one ordered filter: the job's own state first, then routing, then the label skip (unmatched jobs only), then the repository as routed, its switch, and jobs already filed. A rule's decision is applied in one place (intake/route.go:applyRoute,stage,startDecision). The rule's pipeline comes fromfactory.Recipe.Named, the same lookupjob_start {pipeline}now uses.autouses the newpipeline.File.DecideAdmitted: the rule stands in for the start label, and size, cost and protected paths still apply.askholds withrouting rule <name>.backlogfiles the job.factoryIntakeOwned: app,codeaf factory serve, CLI) now gets lane A'sfactoryJudge. WhenDecidereturns Pending,Options.Judgeis called once per rule per job per pass. The answer is kept onItem.Judgedunder the write lock. A judge error counts as "no" and is kept ascouldn't judge: …with no key, so it is asked again next pass. With no judge, a rule that asks never matches. When an AI yes matches a stranger's ticket,autobecomes ask. The activity line names the rule and the answer's reason.lease.runsBefore: Start now, then p0, p1, p2, p3, then no priority, then oldest. All priority spellings come from one table infactory/jobs.go.Shared changes outside lane R's files
route.Answer,Answers,AnswerKey,Outcome.Answer,factory.RouteAnswer). AddsItem.Judged map[string]RouteAnswer, which the contract described but did not declare.judge.WithRuleModelis not called, becauseroute.Matchhas nomodelfield yet. The factory's default model answers every question.factory.Recipe.Namedreplaces serve's privatepipelineStages, which is deleted.pipeline.File.DecideAdmittedis split out ofDecideJob.DecideJobbehaves as before.factory.RepoNamemoves into the factory package so route can use it without depending on the store.store.RepoNamedelegates to it.factory.PriorityRank/ValidPrioritynow read the shared table.PriorityShort/PriorityFromShortare added.TestPriorityMarksDoNotReorderExecutionis replaced byTestPriorityOrdersExecutionAtOneJobAtOnce, because the contract reverses it.Proof
With no rules, intake is unchanged: every existing intake test passes as written. Two serve tests failed once when nine packages ran together (
TestThePullCarriesEachStepsWholeReportAndAReaderNone,TestFactorySetupDoubleContinueEndsReadingOnce). Both pass alone, and the whole serve package passes on a fresh-count=1run.No change entry yet: this PR targets the integration branch, not
dev.🤖 Generated with Claude Code