[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79PJERCGXJKA3JKASTFBC55":3,"skill-same:01M79PJERCGXJKA3JKASTFBC55":126},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":106,"commitSha":107,"skillDirectory":108,"forksCount":14,"repositoryHtmlUrl":109,"repositoryHomepageUrl":6,"ownerHtmlUrl":110,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":111,"install":112,"resources":125},"01M79PJERCGXJKA3JKASTFBC55","router",null,"GO v2 front door internals — policy resolution, run records, resume dashboard, and PR label correction for src\u002Fworktrail\u002Frouter","behindthedash\u002Fworktrail","behindthedash","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F30299179?v=4","01M79PHT5395GJXDSNP7MYP63D","OC","01M79PHT68KHMYHPS9D9RCYFJZ",0,"MIT","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frouter\u002Fskill.md",[],[],"2026-11-15 14:19:17",false,"---\nname: router\ndescription: GO v2 front door internals — policy resolution, run records, resume dashboard, and PR label correction for src\u002Fworktrail\u002Frouter\ntriggers:\n  files:\n    - src\u002Fworktrail\u002Frouter\u002F**\n  keywords:\n    - policy.py\n    - go-policy.yaml\n    - worktrail-go-policy.yaml\n    - run_record\n    - dashboard\n    - automerge_eligible\n    - risk label\n    - classify\n    - RISK_SIGNALS\n    - scope_review\n    - parse_invocation\n    - noun-verb grammar\n    - triage_keep_limit\n    - triage_max_queue_age_days\n    - max_parallel_workers\n    - compile_max_critical_path_over_width\n    - compile_max_same_file_chain\n    - review_skip_max_diff_lines\n    - pre_commit_cmd\n    - land_pr\n    - LandRequest\n    - LandOutcome\n    - close_stale_openspec\n    - flip_and_archive\n    - capacity-gate\n    - retry_after\n    - smoke_flakes\n    - smoke_flake_aggregate\n    - smoke_flake_selfcheck\n    - reconcile_pr_labels\n    - load_run_index\n    - base_slug\n    - automerge_preflight\n    - required_checks_gate\n    - owner_repo_from_git\n    - push_remote_name\n    - remote.pushDefault\n    - cluster_detect\n    - focus-overlap\n    - MIN_FOCUS_TOKENS\n    - OVERLAP_THRESHOLD\n    - risk_judgment\n    - judge_risk\n    - compose_tier\n    - parse_answers\n    - blast_radius\n    - red line\n    - TYPESAFE_API_KEY\n    - risk_judgment_enabled\n    - typesafe\n    - JUDGMENT_ERRORS\n    - relatedness_judgment\n    - judge_pair\n    - judge_pairs\n    - should_edge\n    - same_work\n    - should_cluster\n    - focus-judgment\n    - JUDGED_MATCH\n    - JUDGMENT_THRESHOLD\n    - JUDGMENT_PREFILTER_FLOOR\n    - MAX_JUDGED_PAIRS\n    - cluster_telemetry\n    - log_judged_pairs\n    - target_branches\n    - inline flow sequence\n    - parse_policy_yaml\n    - POLICY_KEY_TYPES\n    - _sweep_key_types\n    - _SWEEP_SKIP\n    - _TYPE_SWEEP_EXEMPT\n    - env_profiles\n    - auth.profile\n    - resolve_env_profile\n    - env_profile.py\n    - resolve_routing\n    - _CONSUMER_MENTION_J_LABELS\n    - _CONSUMER_BY_PHRASE_RE\n---\n\nYou are working on **worktrail's GO v2 front door**: loading repo policy, classifying free-text\nrequests into routes, tracking run records, and rendering the resume dashboard.\n\n## Domain purpose\n`router\u002F` is what `\u002Fgo`-style front doors consume to decide what a repo allows (policy), which\nroute a request maps to (classify), what already happened (run_record, dashboard), and whether a\nspawned agent's own `gh pr create` came out correctly labeled (pr_labels). Nothing here spawns\nagents or writes task files — that is `orchestrator\u002F`'s job.\n\n## Business rules \u002F invariants\n- **The front-door grammar is code, not prose: `parse_invocation.py` owns it.** The shape is\n  `\u003Cfront-door> [\u003Crepo>] \u003Cnoun> \u003Cverb> [args]` with exactly four nouns (`NOUNS`: `handoff`,\n  `spec`, `pr`, `decision`), plus two deliberate bare shortcuts (`\u003Cbrief-id>` = `handoff start \u003Cid>`, and\n  `\u003Crepo>` = that repo's dashboard) and the read-only `help`\u002Fempty invocations. Every\n  pre-noun-verb spelling (`auto`, `drain`, `new`, `implement spec \u003Cid>`, `continue`, `pr`,\n  `brainstorm`, `fix`, `route:\u003CA-J>`, `handoff:\u003Cid>`) is **permanent, not deprecated** — `ALIASES`\n  lists them and `_canonicalize` rewrites only a bare leading token, so a spelled-out noun-verb form\n  is never rewritten twice. Add a new form to `FORMS`\u002F`ALIASES` and the parser together, never one\n  without the other.\n- **`decision list` \u002F `decision answer \u003Cdecision-id>` are their own modes (`decision_list`,\n  `decision_answer`), not intents or brief lookups.** The parser carries the id in the result's\n  `decision_id` field and never tries to resolve it against `queue\u002F` (`brief_status` stays `None`);\n  `decision answer` with no id is `mode: help` with `help_topic: decision`. The `worktrail-go`\n  skill skips the dashboard entirely for both and runs `worktrail-decision` \u002F the\n  `answer-decision.md` procedure directly.\n- **A noun with no recognised verb returns `mode: help`, never free text.** Free text containing\n  the word `handoff` classifies to Route E at high confidence in `classify.py` (joint-highest-weight\n  signal plus a state boost whenever the queue is non-empty), so anything that escapes the parser\n  lands on the wrong route silently. `handoff new` must also never reach the intent branch as\n  `repo=handoff, intent=new` — the noun-verb match runs above the bare intent words on purpose.\n  `pr` is the one exception: bare `pr` (and `pr \u003Ctext>`) still means the old `pr` intent.\n- **`RISK_SIGNALS`' `authz` pattern carries a `(?\u003C![-@])` guard so it cannot fire inside a\n  compound token.** `\\b` treats the hyphen in a package name like `better-auth` (or the `@` in\n  `@auth\u002Fcore`) as a word boundary, so merely naming the dependency scored `high:authz`.\n  Confirmed live 2026-09-10 (run `go-20260910-085556`, devops PR #366): a config-only PR\n  classified `risk=high`, exceeded that repo's policy `max_risk=medium`, and was labeled\n  `go:no-automerge`, forcing a hand merge. This is a word-boundary artifact inside one token,\n  **not** the diff-blindness the `RISK_SIGNALS` table comment deliberately fails loud on.\n  Underscore-joined identifiers (`require_auth`) were already excluded (`_` is a word character);\n  `auth-related` still matches, because the guard looks only at what *precedes* the word.\n- **`classify_risk()` has two backends over one `RISK_ORDER` mapping, and the keyword table is\n  both the default and the fallback.** `classify_risk(text, *, judgment=False)` keeps its shape;\n  `_classify_risk_by_keyword()` is the extracted `RISK_SIGNALS` body, and\n  `risk_judgment.judge_risk()` is the second backend — one request asking for a 4-level\n  blast-radius score plus four red-line nouls (`irreversible_data_loss`,\n  `weakens_access_control`, `moves_money`, `disables_a_safeguard`), never for a tier, a label, or\n  a merge decision. The service observes; the pure, offline `compose_tier()` decides: the score\n  sets the baseline tier (rounded and clamped onto `_TIERS`), a hard red line at or above\n  `RED_LINE` (0.70) forces `critical`, the safeguard red line forces `high`, and a red line is a\n  **floor** — it can only raise a baseline, never lower one, because a change can read \"ordinary\"\n  on blast radius and still destroy data. Labels keep the `\u003Ctier>:\u003Clabel>` shape\n  (`medium:blast-radius`, `critical:moves-money`), so a judged tier is readable as such with no\n  second field. Why it exists: the keyword table tiers on word presence alone, and measured\n  2026-09-19 on `tests\u002Ffixtures\u002Frisk_probes.json` it got 8\u002F24 exact tiers and 10\u002F24 auto-merge\n  gate decisions — rating prod data deletion, an auth fail-open, refund re-submission and\n  \"make a required check non-blocking\" *mergeable*, and seven trivial doc\u002Ftest changes\n  *critical* — against the judgment's 20\u002F24 and 24\u002F24 with zero of either error.\n- **The judgment fails safe into the keyword table, always.** `judge_risk()` returns `None` — the\n  \"use the keyword table\" signal — on a missing `TYPESAFE_API_KEY`, an HTTP or transport error, a\n  timeout (`typesafe.TIMEOUT_S`, deliberately short: a tier that arrives after the operator gave up\n  is worth less than the immediate fallback), an unparseable body, or an answer set missing a field.\n  `parse_answers()` raises `ValueError` on any shape it does not recognise rather than reading a\n  missing noul as zero, so a changed or truncated response can never compose a falsely-low tier.\n  The fallback errs toward over-gating, which is the safe direction. CI needs no key and no\n  network: with the key unset the judgment path is never entered and behaviour is exactly the\n  pre-judgment one.\n- **Both judgment backends share one client, `router\u002Ftypesafe.py`, and one failure-mode rule.**\n  The endpoint (`API_URL`), `MODEL`, `API_KEY_ENV`, `TIMEOUT_S`, `is_configured()`, the\n  single-request `post(state, questions)`, the strict `noul(answers, key)` reader, and the\n  `JUDGMENT_ERRORS` tuple live there — `risk_judgment.py` re-exports `API_KEY_ENV` so its own\n  readers and tests keep one import. A second copy of the transport would be one more place for\n  the \"what counts as unavailable\" contract to drift; add a new backend by importing this module,\n  never by re-implementing the POST.\n- **`cluster_detect`'s focus signal also has two backends, and the lexical threshold is both the\n  prefilter and the fallback.** `relatedness_judgment.judge_pairs()` asks two Nouls per pair —\n  `same_work` (one item subsumes the other) and `should_cluster` (distinct work that causes\n  rework if done apart) — and the pure, offline `should_edge()` forms an edge when **either**\n  clears `JUDGMENT_THRESHOLD` (0.70). The union is deliberate: requiring both would drop exactly\n  the \"different work, must land together\" case the second question exists for. Why it exists,\n  measured 2026-09-19 in both directions: three pairs describing identical work in different\n  vocabulary scored **0.00-0.12** token overlap — invisible to `OVERLAP_THRESHOLD` (0.45) — while\n  the judgment rated them **0.76-0.86** on `same_work`; and of the 14 highest-overlap real corpus\n  pairs, **7 were unrelated** on inspection (two different epics' decomposition-gap briefs, a\n  reject-UI brief against a vitest-coverage brief).\n- **The lexical stage is demoted to a prefilter, never removed.** `_judgment_candidates()` picks\n  which pairs are worth a request at `JUDGMENT_PREFILTER_FLOOR` (0.05 — far below the edge\n  threshold on purpose, because a prefilter near 0.45 would reproduce the blindness being fixed)\n  and ranks them by overlap descending; `MAX_JUDGED_PAIRS` (40) caps one scan, because pair count\n  grows quadratically with queue size (68 briefs is 2278 pairs before repo scoping) and a\n  dashboard render may not fan out unbounded. Everything past the cap — and every pair at all when\n  the judgment is unavailable — keeps the lexical decision unchanged. The repo-scoping\n  precondition and the `MIN_FOCUS_TOKENS` thin-brief abstention are unchanged: a cross-repo pair\n  is never offered, and a brief too thin for the coefficient to read is one the judgment cannot\n  read either.\n- **A verdict replaces the focus signal and nothing else.** `_apply_relatedness_judgment()` swaps\n  a judged pair's `focus-overlap` match for `JUDGED_MATCH` (`focus-judgment`, so a reader and the\n  telemetry log can tell which rule decided) when the pair belongs together, and for **nothing**\n  when it does not — that is how a high-overlap-but-unrelated pair loses its edge. Structural\n  matches (duplicate-slug, same-target-spec, related-link) are never touched: they are facts about\n  the briefs, not a reading of their text. The whole candidate batch is handed over in ONE call,\n  already capped and ordered, so the injected side owns concurrency (`MAX_CONCURRENCY`, 8) and\n  `cluster_detect` holds no thread pool and no client; verdicts come back positionally aligned and\n  the **first** unavailable one ends the pass, because applying a later verdict past a gap would\n  make the surfaced clusters depend on which round trip failed.\n- **The judgment client is injected into `cluster_detect`, never imported by it.**\n  `compute_clusters(..., judge_pairs_fn=None, log_judged_fn=None)` defaults both to `None`, so\n  every existing caller keeps prior behaviour exactly; `dashboard.py` is the call site that\n  injects `relatedness_judgment.judge_pairs` (only when `is_configured()`) and\n  `cluster_telemetry.log_judged_pairs`. Same pattern as `_parse_fm` and `task_candidates_fn` —\n  `cluster_detect`'s own guard test rejects any network module in that file, and its contract is\n  read-only and never-crash.\n- **Every judged pair is logged for later tuning.** `cluster_telemetry.log_judged_pairs()` appends\n  one `judged` record per pair (members, the lexical overlap that ranked it, both Noul values, and\n  the verdict) sharing one timestamp, so `JUDGMENT_THRESHOLD` and the prefilter floor can be\n  retuned against real pairs without paying for inference again. Best-effort like the module's\n  other writers: the edges are already decided by the time it runs, so a failed write costs a\n  tuning datapoint and nothing else.\n- **`classify()` stays pure by default: `risk_judgment_enabled` defaults to `False`.** Only\n  `main()` turns it on, with `--no-risk-judgment` to opt out — the same confinement\n  `cited_pr_states`' live `gh` lookup already has — so `classifier_coverage`'s replay and every\n  test stay deterministic, free and offline. Enabling it changes only the `risk`\u002F`risk_signals`\n  output; route selection, its confidence, and its reason never consult it.\n- **A J score built entirely from `_MENTION_ONLY_J_LABELS` (`routing-logic`, `classify-py`)\n  alongside a strong CI\u002Fconfig signal (`_CI_CONFIG_RE`: `.github\u002Fworkflows`, `.github\u002Frulesets`,\n  `required status check`, `branch protection`) is damped to zero** — that shape means the\n  routing\u002Fclassifier file is cited as evidence for unrelated CI\u002Fbranch-protection work, not the\n  actual change target (live incident 2026-09-10, brief 20260910-143657\u002Frun go-20260910-142322).\n  The damp does **not** fire when the same text also matches `_CITED_AS_EXAMPLE_RE` (`cites`,\n  `quotes`, `verbatim`, `worked example`, `as an example`, …): a genuine self-referential bug\n  report about `classify.py`'s own routing logic that happens to quote another brief's\n  CI-config text as a worked example was itself getting wrongly demoted from J to F (brief\n  20260910-152514: J=9 undamped vs F=6, confirmed reproducible). A citation cue means the\n  CI\u002Fconfig phrase is quoted evidence, not the report's own change target, so it must not\n  trigger the damp. Scoped narrowly to these two evidence-confirmed labels — do not widen\n  `_MENTION_ONLY_J_LABELS` without its own confirmed false-positive.\n- **A J score built entirely from `_CONSUMER_MENTION_J_LABELS` (`go-skill`, `front-door`) whose\n  only occurrence is a consumer by-phrase (`_CONSUMER_BY_PHRASE_RE`: a consumption cue —\n  `consumed`\u002F`used`\u002F`read`\u002F`called`\u002F`drives`\u002F… — followed by `by` and then the front door) is\n  also damped to zero** — that shape names the front door as a *consumer* of the result under\n  discussion, which cannot be the change target (live incident 2026-10-03, brief 20261003-204443:\n  the bare clause \"the machine-readable surface consumed programmatically by drain, queue-triage,\n  and the go front door\" scored J=7 at high confidence with every other route at 0). The by-phrase\n  frame is what separates the two shapes, so no citation carve-out is needed: \"add a guard to the\n  go front door so it stops misrouting consumer mentions\" still routes J. Damping is scoped to a J\n  score built *entirely* from these two labels — a request that also carries another J signal\n  (e.g. `cassette`) still wins on it. Do not widen `_CONSUMER_MENTION_J_LABELS` without its own\n  confirmed false-positive.\n- **The parser translates into the executor's vocabulary, not the user's.** `worktrail-sdd-workflow`\n  still speaks `handoff:\u003Cid>`, `route:\u003CX>`, and the v1 intent words (`V1_INTENTS`); so `spec\n  explore` yields `intent: brainstorm`, and `spec fix` yields `route: F` (the executor has no `fix`\n  intent). The result's `canonical` field carries the noun-verb spelling so the skill can print\n  `(reads as: worktrail-go \u003Ccanonical>)` when it differs from `raw`; it is `None` for free text.\n- **`worktrail-help`'s reference block is generated from `FORMS` + `ALIASES` via `render_forms()`**\n  and pinned by `tests\u002Frouter\u002Ftest_parse_invocation.py::test_help_forms_block_matches_the_parser_registry`\n  — regenerate it, never hand-edit it. Only `\u003Cfree text>` may carry `parsed=False`.\n- **`policy.py` uses two YAML parsers on purpose.** Most keys go through `parse_policy_yaml`, a\n  flat, stdlib-only, one-nesting-level subset. `routing:` and `add_ons:` are re-parsed with real\n  `yaml.safe_load` (`_resolve_routing`, `_resolve_add_ons`) because both need arbitrary nesting\n  the flat parser would flatten into siblings of the wrong key. Adding a new deeply-nested policy\n  key means adding a matching `_resolve_*` real-YAML path, not extending the flat parser. The one\n  narrow exception inside the flat parser is `_parse_scalar`: a value that starts with `[` and ends\n  with `]` is handed to `yaml.safe_load` so an inline flow sequence (`[]`, `[main, dev]`) loads as\n  a real list; anything that is not a valid flow sequence (an unclosed `[`, a quoted `\"[not a\n  list]\"`, a YAML error) stays a plain string. Before this, a documented `target_branches: []`\n  loaded as the truthy string `'[]'`.\n- **Policy resolution fails closed.** A malformed `add_ons`\u002F`routing`\u002F`automerge` shape falls back\n  to the safe default (`{}` \u002F `None` \u002F disabled) with a warning appended to `meta[\"warnings\"]`,\n  never widens autonomy. `automerge.max_risk`, `agent_cli`, `fallback_agent_cli`, `agent_model`,\n  `max_workers`, `pr_pacing_wait_s`, and `max_parallel_workers` are all validated\u002Fclamped the same\n  way in `load_policy`.\n- **`routing.env_profiles` names *where* a target's environment comes from and stores no values.**\n  `_validate_routing_env_profiles` (never-raise warn-and-drop, like its sibling\n  `_validate_routing_*` validators; resolved *before* `targets` and returned in the resolved\n  routing dict, because a target's `auth.profile` is validated against it) accepts\n  `{name: {from, keys, expect?}}` — `from` is a path to a JSON file with an `env` object, `keys`\n  lists which of that object's names to copy, and `expect` maps a name to the literal it must\n  equal before a worker may launch. `keys` and `expect` are deliberately independent: a key may\n  be asserted without being copied (provenance checking) or copied without being asserted (so\n  its value is never printable). A malformed `expect` drops the **whole profile**, not just the\n  assertion — a silently-dropped assertion is indistinguishable from a passing one, which would\n  defeat the only thing `expect` exists for.\n  `resolve_routing()` must carry this table into the resolved `{targets, tiers, roles, purposes,\n  default_tier, env_profiles, drain}` dict it returns: `spawnlib` reads the profile table off\n  *that* dict (never a second policy read, which could diverge from the table `select_cell`\n  served from), so dropping the key made every profile-bearing cell raise `OperatorConfigError`\n  (\"not declared in routing.env_profiles\") at launch even when the profile was declared —\n  confirmed live 2026-10-02, the drain's intake-triage spawn died on a `claude-deepseek` cell\n  whose `deepseek` profile was declared in `routing.yaml` all along.\n- **`auth.profile` and `auth.env` are mutually exclusive alternatives for one auth lane, and a\n  profile on a `subscription` target is a warning.** `_validate_routing_targets` warns on a\n  non-mapping `auth`, on both `env` and `profile` declared together (the spawn hard-fails; the\n  target is still kept so it appears in `--check`), and on `auth.profile` on a `subscription`\n  target, because that lane strips `ANTHROPIC_API_KEY` *after* profile injection — a\n  profile-supplied key cannot survive there, though the target is still valid for non-key\n  variables. `auth.codex_home` alongside a profile is not a conflict (it selects a home, not\n  credentials). `_warn_undeclared_env_profiles` warns when an `auth.profile` names a profile\n  `env_profiles` does not declare; the target is kept (mirroring \"`pool: api` without\n  `api_opt_in` is kept but ineligible\") and the authoritative failure is at spawn.\n- **`worktrail-routing --check` resolves every `auth.profile` cell against the real file**,\n  marking the cell `FAIL`, printing the full `OperatorConfigError` to stderr, and exiting 1 —\n  but deliberately NOT recording an `agent_capacity` gate. A recorded gate is skipped *silently*\n  by `select_cell` on the next spawn, which would turn a loud configuration error into an\n  invisible fallback to the next rung — precisely the failure class env profiles exist to\n  remove. Gates model provider conditions; this is operator config, and its `auth` cooldown\n  would outlive the fix.\n- **`load_policy()` runs a coarse type sweep (`_sweep_key_types`) before the per-key checks; the\n  two layers are deliberately separate.** `POLICY_KEY_TYPES` declares an expected type (or tuple)\n  for every flat `DEFAULTS` key, and a wrong-typed value is replaced by its `DEFAULTS` entry with\n  one `meta[\"warnings\"]` line (`\u003Ckey> must be \u003Ctype>[ or null]; got \u003Cvalue!r> — using default\n  \u003Cdefault!r>`) — e.g. `protected_paths: migrations\u002F` becomes `[]`, `pre_pr_cmd: true` becomes\n  `None`. A key whose default is `None` also accepts `None`, and a YAML `true` never satisfies an\n  integer key (`bool` is an `int` subclass). The per-key checks further down `load_policy` still\n  run last, unchanged, and own value-level rules (allowed literals, integer minimums, per-entry\n  cleaning). `routing`\u002F`add_ons` are exempt (`_TYPE_SWEEP_EXEMPT`; their own resolvers run first),\n  and every key that already has a stricter per-key check is declared in `POLICY_KEY_TYPES` but\n  listed in `_SWEEP_SKIP` so the sweep never swallows a value before that check's own warning text\n  (which callers assert on) can fire — the sweep effectively covers the keys that had no\n  value-level check at all. `run_record_dir` restores its lazily-resolved\n  `default_run_record_dir()`, not `None`.\n- **A bare string under `require_human_routes` or `automerge.target_branches` is NOT a type error.**\n  Both are declared `(list, str)`: `automerge_eligible()` tests `route in require_human_routes`, so\n  a single-route `require_human_routes: B` is a working gate that sweeping it to `[]` would silently\n  open, and it already normalizes a bare `target_branches: dev` to a one-branch list. Only a value\n  that is neither (e.g. `target_branches: 7`) falls back to `[]` with a warning naming\n  `automerge.target_branches`. The sweep reaches `automerge.target_branches` separately because it\n  is a flat key living one level down. A policy key added to `DEFAULTS` with no `POLICY_KEY_TYPES`\n  entry (and not in `_TYPE_SWEEP_EXEMPT`) fails\n  `tests\u002Frouter\u002Ftest_policy_key_types.py::test_every_defaults_key_has_a_declared_type_or_is_exempt`.\n- **`automerge.target_branches` empty means \"base branch only\", and a scalar is one branch, not a\n  substring.** `automerge_eligible()` treats `target_branches: []` (and unset) as no filter; a\n  non-empty list rejects any PR whose target branch is not in it (`target branch \u003Cb> not in\n  [...]`). A hand-edited scalar `target_branches: main` is coerced to `[\"main\"]` before the check,\n  because a bare string would otherwise fall through to a substring test (`'ma' in 'main'`). Both\n  the `[]` spelling and the scalar case are pinned in `tests\u002Frouter\u002Ftest_policy.py`.\n- **`max_parallel_workers` (default 6, minimum 1) is a ceiling, not a width.** It only applies when\n  neither `--max-workers` nor policy `max_workers` is set: `live._resolve_max_workers` then runs\n  `min(plan width, max_parallel_workers)` workers instead of a fixed 3 (a width-7 plan ran as three\n  serial ticks on 2026-09-02). A set `max_workers` still wins outright. Invalid values\n  (non-int, bool, `\u003C 1`) drop to the default with a `meta[\"warnings\"]` entry, same as the other\n  integer keys.\n- **Integer policy keys follow the `triage_keep_limit` validation pattern.** `triage_keep_limit`\n  (default 2) and `triage_max_queue_age_days` (default 14) are the intake-triage escalation\n  bounds: a value that is not an `int`, is a `bool`, or is below 1 is forced back to `DEFAULTS[key]`\n  with a `meta[\"warnings\"]` entry naming the key. Their consumer is `workqueue\u002Fqueue_triage.py`'s\n  escalation, which reads them with `.get(key, default)` so the policy side and the consumer side\n  can land in either order — as of 2026-09-02 the keys are in `DEFAULTS` but no consumer reads\n  them yet in this checkout. Copy this loop when adding another bounded-int key rather than\n  inventing a new validation shape.\n- **Plan-shape and review-skip keys use that same bounded-int loop.**\n  `compile_max_critical_path_over_width` (default 2, min 1) and `compile_max_same_file_chain`\n  (default 2, min 1) are the plan-shape gates `conductor\u002Fcompile.py` consumes: a compiled plan is\n  rejected when its critical path exceeds `max(width, compile_max_critical_path_over_width)` or a\n  dependent chain all touching one file exceeds `compile_max_same_file_chain`.\n  `review_skip_max_diff_lines` (default 0 = disabled, min 0) is the fast path `orchestrator\u002Flive.py`'s\n  `drive()` consumes beside `_review_exempt`: when > 0, a task's first review is skipped once the\n  implement report is a verified success under that many added+removed diff lines (test files\n  excluded). Invalid values drop to the default with a `meta[\"warnings\"]` entry.\n- **`pre_commit_cmd` (default `None`) is the one optional-string policy key.** A non-string,\n  non-`None` value is forced to `None` with a warning. Its consumers are `orchestrator\u002Fdispatch.py`\n  (a worker-prompt hard rule for implement\u002Ffix and the ci-fix group prompt) and\n  `orchestrator\u002Flive.py`\u002F`verify.py` (post-commit amend backstop). `None` means repos without a\n  wired command see no behavior change. `onboarding\u002Frepo_init.py`'s `detect_pre_commit_cmd`\n  seeds it into a fresh `.worktrail\u002Fpolicy.yaml` by scanning `.github\u002Fworkflows\u002F*.yml|yaml`\n  `run:` step lines for `ruff`\u002F`oxlint`\u002F`prettier` (`PRE_COMMIT_CMD_BY_LINTER`, joined with `&&`\n  in that order); an existing policy file is never touched.\n- **`automerge.enabled: false` does not, by itself, block orchestrator-driven merges.** Only\n  `automerge_eligible()` reads that key, and only when an agent follows sdd-workflow's Phase 8\n  merge-gate instructions — `orchestrator`'s own `auto_merge()` is a separate code path that\n  unconditionally calls `gh pr merge` once CI passes and does not consult this key at all.\n- **Run records enforce ten explicit completion states** (`run_record.py` `finish`, §22) — a run\n  can never end in vague language. `finish` also code-enforces `no_implementation_without_approval`\n  (a route-A run cannot finish on an implementation-completion state without a recorded\n  `decisions` entry first) and `pre_pr_gate.py`'s `scope_review_failures()`, unconditional on\n  route, exactly once per run regardless of how many group PRs the orchestrator created.\n- **Scope-review entries are append-only; the gate judges only the latest entry per `--item`.**\n  `scope_review_failures()` collapses `status | item | detail` entries to the last one per item\n  before checking `blocked` \u002F `out-of-scope`, so re-recording an item supersedes an earlier\n  mis-phrased or blocked entry (and a later `blocked` entry can equally regress a prior\n  `complete`). Malformed entries still fail regardless of position.\n- **An `out-of-scope` reason must begin with a prefix from `run_record.OUT_OF_SCOPE_REASON_PREFIXES`**\n  (`different purpose:` \u002F `user approved:`). `cmd_scope_review` rejects any other reason at write\n  time with `SystemExit`, and `scope_review_failures()` re-checks the same tuple at gate time so a\n  hand-edited record is still caught. Extend the tuple, never the two call sites separately.\n- **`set-list PATH KEY [VALUE ...]` is the only invocation that writes a list field, and the repair\n  path for a list-typed field left holding a scalar.** `set` stores its VALUE verbatim, so\n  `set PATH handoffs_consumed '[\"a\",\"b\"]'` writes the **string** `'[\"a\",\"b\"]'`, and every appender\n  into that field — `append`, `intervention` (`interventions`), and `record_decision_event`\n  (`pending_decisions`) — then refuses to touch it (brief 20261003-204455, where the documented\n  recovery from `append` was itself a dead end). `cmd_set_list` writes `list(VALUES)` (no values\n  produces `[]`, so an emptied field is expressible) and rejects `status`, which is a phase, not\n  a list, with `SystemExit` naming `set`. All three append refusals share\n  `_scalar_list_field_hint(key)`, which names `set-list` — the old `append` message said \"use\n  `set`\", a command that cannot perform the repair.\n- **`classifier_coverage.py` reports a `handoffs_consumed` shape it cannot read as ids, and never\n  decodes one.** `_consumed_ids()` returns `(ids, diagnostics)`: a list of id strings (what every\n  current writer produces) and a single plain id string (the older `set` form, still on disk) are\n  ids, while a JSON-encoded array\u002Fobject stored as a string (the same `set PATH handoffs_consumed\n  '[\"a\",\"b\"]'` footgun the bullet above describes), a comma-joined string, a non-string value, and a\n  non-string list entry are diagnostics. Each malformed shape used to come through as ONE brief id\n  that cannot exist, so the run's real attribution silently vanished from the `actual` join and this\n  audit never surfaced it (brief 20261003-221534). They are reported, never parsed and never split —\n  recovering the real ids is a separate judgment about what those records meant.\n  `load_actual_routes_with_diagnostics()` is the audit's loader (`load_actual_routes()` is its\n  `routes` projection; the newest run id still wins when several consumed one brief), the\n  diagnostics land in the `--json` payload as `corpus.malformed_consumed_records` (`record`,\n  `reason`, `value`), and `render_report` prints a `malformed handoffs_consumed: N record(s)` line\n  whenever that list is non-empty, so a reader knows `actual` is blind rather than complete.\n- **`capacity-gate --retry-after` is validated as ISO-8601 and stored verbatim, never slug-sanitized.**\n  `cmd_capacity_gate` runs it through `_iso_retry_after` (a `datetime.fromisoformat` check that\n  raises `SystemExit` on a non-ISO value) rather than `_safe_provider`, which is a slug sanitizer\n  and turned `+00:00` into `_00:00` — an offset every downstream `retry_after` consumer\n  (`orchestrator\u002Fagent_capacity._parse_time`) then failed to parse (fixed 2026-09-06). Only\n  `--provider` and `--failure-class` go through `_safe_provider`.\n- **`finish` best-effort-applies the `go:risk-*` PR label correction** (`pr_labels.\n  ensure_pr_risk_label`) whenever the record carries a `pull_request` — a spawned headless agent's\n  raw `gh pr create` is never reachable by the interactive Claude Code PreToolUse\n  label-enforcement hook (Codex\u002FOpenCode have no equivalent mechanism at all).\n- **PR label writes use the REST endpoint, not `gh pr edit --add-label`.** `gh pr edit`'s GraphQL\n  mutation also touches classic-Projects fields and fails outright on a repo\u002Forg with a legacy\n  Projects (classic) board still attached (confirmed live 2026-08-07). `_current_pr_labels`'s\n  read-only `gh pr view` call is unaffected and stays as-is.\n- **`reconcile_pr_labels.load_run_index()` now reads records through `run_record._load_lenient`,\n  not the raising `_load`** — a single unreadable\u002Fmalformed record (hand-edited outside\n  `run_record.py`'s own renderer) is skipped with a `WARNING: skipping unreadable run record: ...`\n  line on stderr instead of aborting the whole scheduled sweep. Same tolerance policy `_load_lenient`\n  already applies to `active-conflicts` and the other directory-wide `run_record.py` scans (fixed\n  2026-09-12).\n- **`check_deferred_work_handoff.load_deferred_work_entries()` and\n  `check_durable_artifact_capture_gate.find_planned_run_records()` — the two Stop-hook check\n  scripts — now surface that same `_load_lenient` warning too, instead of discarding it.**\n  Both previously unpacked `_warning` and threw it away, so a malformed run record failed silently\n  with no signal that the check had skipped data. Both now print\n  `WARNING: skipping unreadable run record: \u003Cdetail>` to stderr and skip the record, matching the\n  tolerance-with-visibility policy above (fixed 2026-09-12).\n- **`dashboard.py` detects spec artifacts by exclusion + content, never one strict filename\n  pattern.** Known auxiliary files (`user-request.md`, `decision-log.md`,\n  `traceability-matrix.md`, etc.) are named explicitly; any other top-level `*.md` is a candidate\n  spec doc, with a dated filename winning when several exist. A `## Clarifications` heading is\n  NOT the resolution-gate signal — only ~22\u002F46 real specs carry one; the gate keys on unresolved\n  `[NEEDS CLARIFICATION: ...]` markers in the spec body instead.\n- **The dashboard JSON payload's `smoke_flakes` key is always present, never absent.**\n  `smoke_flake_aggregate(repos)` calls `smoke_flake_selfcheck.check_repo()` once per in-scope repo\n  (both `--root` single-repo and `--repos` multi-repo mode), tags each entry with its repo name,\n  and merges them into one `{\"entries\": [...]}` keeping the detector's ordering (count desc, suite\n  asc), so a consumer can read the key without an existence check. The aggregate is passive: any\n  failure yields `{\"entries\": []}` and the `rendered` smoke-flake section is simply omitted — it\n  never breaks the dashboard. `smoke_flake_selfcheck` is imported unconditionally (the\n  detector-not-yet-shipped `try\u002Fexcept ImportError` fallback is gone now that the module ships).\n  The entry shape and the recency window are documented in\n  `skills\u002Fworktrail-go\u002Freferences\u002Fdashboard-render.md`.\n- **`skill_dispatch.evaluate_single_brief()`\u002F`apply_single_brief_verdict()` resolve a bare `repo:`\n  value to an on-disk checkout before using it as `cwd`.** A brief's `repo:` frontmatter is almost\n  always a short name (e.g. `\"worktrail\"`), not a path. `evaluate_single_brief` runs it through\n  `dashboard._resolve_repo_dir(resolved_repo, repos_root)` to build `group_cwd` whenever an\n  explicit repo is resolved and no `cwd` override was passed — previously it passed the bare name\n  straight through, which `subprocess.run` then rejected as a nonexistent relative `cwd` when\n  invoked from outside the target repo (e.g. `worktrail-go`'s normal cwd). `apply_single_brief_verdict`\n  now takes and forwards a `repos_root` parameter to `queue_triage.apply_verdicts()` so a\n  `propose-change`\u002F`fold-into-change` verdict's own `_resolve_repo_dir()` call can find the repo\n  too — both call sites must resolve consistently, not just the evaluate path (fixed together\n  2026-09-03).\n- **`land_pr.py` is the one shared PR-landing pipeline every PR-opening call site composes with,\n  instead of each reimplementing a subset of it.** `land_pr(LandRequest) -> LandOutcome` runs, in\n  order: commit pending work (refuses `dirty_tree` without a `commit_message`), the compile-marker\n  gate for every OpenSpec change whose `tasks.md` changed, the preflight gate + label read-back,\n  push, find-or-create the PR (shared with `orchestrator\u002Fintegrate.py`'s group-PR step), CI watch\n  to a terminal outcome (transient-infra reruns, no-checks-yet grace period, `code_defect` vs\n  `ceiling` classification via `CI_PATCH_ITERATION_CEILING`), the merge-state guard, the\n  review-thread gate, then finish (or, in checkpoint mode, append a decision to) the run record.\n  Refusal (steps 1-4) never touches the remote; a push or PR-create failure past that point is\n  reported as `outcome=\"ceiling\"`, never `refused`, because the remote is already mutated (an\n  untouched-remote promise `refused` would misrepresent). Registered as `worktrail-land-pr`\n  (`worktrail.router.land_pr:main`). See the module's own docstring for the authoritative ordered\n  step list — it exists because PR #902 shipped 112 gate-verified files that were never committed\n  before `git push`, a gap each prior call site (`queue_triage.py`, `drain.py`,\n  `orchestrator\u002Fintegrate.py`, and the agent-executed sdd-workflow\u002F`worktrail-go` prose) closed\n  differently or not at all. As of 2026-09-05 `drain.py` (`_land_remediation_pr`),\n  `close_stale_openspec.py`, and `workqueue\u002Fqueue_triage.py` all compose with it.\n- **`_push()` always pushes with an explicit `HEAD:\u003Cbranch>` refspec** (`git push -u \u003Cremote>\n  HEAD:\u003Cbranch>`), never a bare `git push` to the configured upstream: a branch created via\n  `git worktree add ... -b \u003Cbranch> origin\u002Fdev` tracks `origin\u002Fdev`, so a bare push targeted the\n  wrong remote branch (repro 2026-09-05, gracefully-giving-back PR #716). It no longer runs the\n  `rev-parse @{u}` upstream lookup at all. On a genuine `\"push\"` refusal it appends git's stderr\n  (falling back to stdout) to an optional `detail_out: list[str]` out-param, and `land_pr()`\n  surfaces that as `LandOutcome.detail` instead of `null` — an out-param rather than a widened\n  return type so existing callers\u002Fmocks of `_push(repo, branch, remote, runner)` keep working. A\n  timeout\u002F`OSError` still returns `\"push_ambiguous\"` with nothing appended. Regression tests live\n  in `tests\u002Frouter\u002Ftest_land_pr_push_refusal.py`, deliberately not in `test_land_pr.py`.\n- **`worktrail-land-pr` writes one `REFUSED at \u003Cstep>: \u003Cdetail>` line to stderr; stdout stays the\n  machine contract.** `_refusal_line()` takes the first non-blank line of `outcome.detail`,\n  truncating past `_MAX_REFUSAL_DETAIL_CHARS` (200) with a trailing `...`; an empty\u002F`None` detail\n  yields the step alone. `main()` prints it only for `outcome == \"refused\"`, alongside the unchanged\n  JSON payload (`--json` is required), so a machine consumer sees exactly what it saw before. It\n  exists because the operator otherwise gets a JSON blob and has to read this module to interpret it\n  — two live refusals in run go-20261003-153531 (PR #1402) each did, and refusal is the single most\n  common landing failure (brief 20261003-204324).\n- **Every post-PR-open `gh` call in `land_pr.py` is scoped to the push-target repo via `base_slug`,\n  never left to `gh`'s bare-number resolution.** `_gh(..., base_slug=)` appends `-R \u003Cbase_slug>`\n  (the slug `_push_target()` returns) when set; `_watch_ci`, `_checks_registered`, `_log_excerpt`,\n  `_pr_is_merged`, `_merge_state_guard` (including its `gh run rerun`), and `_review_thread_gate`\n  all take and thread it. On a `remote.pushDefault=fork` checkout `origin` is the upstream, so a\n  bare PR number or run id resolved against the upstream's same-numbered — and often long-merged —\n  PR, and `land_pr()` reported `completed_and_merged` \u002F `\"merged externally\"` while the fork PR\n  was still OPEN (live 2026-09-18, behindthedash\u002Faspens PR #15 vs upstream `aspenkit\u002Faspens` #15).\n  `_review_thread_gate` splits the slug into `owner`\u002F`name` and passes them to\n  `check_review_threads.check`, which otherwise derives them from `origin`. With no\n  `pushDefault`, `base_slug` is `None` and calls are unchanged. Any new PR- or run-scoped `gh`\n  call added to `land_pr.py` must take `base_slug` too.\n- **`automerge_preflight` reads the remote the PR will actually be opened against, and refuses\n  rather than falling back to another one.** `required_checks_gate()` resolves the target remote\n  once via `push_remote_name()` (`remote.pushDefault`, else `origin`) and threads it into\n  `owner_repo_from_git(..., remote=)`; both also accept an explicit `remote` override. A selected\n  remote that does not exist returns `None` — the old fallback to `origin` answered about a\n  *different repository*, which on a fork layout is the read-only upstream (behindthedash\u002Faspens\n  PR #26, 2026-09-18: the gate read `aspenkit\u002Faspens`'s `allow_auto_merge=false` and put\n  `go:no-automerge` on a PR that was never going to be opened there). The refusal reason names\n  the remote it tried, and `is_preflight_query_error()` stays False for it — an unresolvable\n  remote is a confirmed state, not a transient read failure. The orchestrator's adapter\n  (`verify.Verifier._preflight_runner`) rewrites **every** `git` call to `git -C \u003Crepo> ...`, not\n  just `git remote get-url`: the verifier's runner executes from its own neutral cwd, so an\n  unpinned `git config --get remote.pushDefault` read would answer for that directory and\n  silently re-select `origin`.\n- **`flip_and_archive`'s default (`task_ids=None`) targets *every* task id, not just the pending\n  ones.** The whole point of this module is bookkeeping drift, and its purest case is a change whose\n  `tasks.md` is already 100% `[x]` but was never archived. A pending-only default left both\n  `flipped` and `already_checked` empty for that change, so the \"nothing to flip\" guard refused to\n  archive exactly the case it exists to close. Already-checked ids land in `already_checked` rather\n  than being skipped, so the default path still archives a fully-checked change.\n- **`close_stale_openspec.py` now lands the PR itself.** `main()` requires `--base` and `--run`;\n  after a successful `flip_and_archive` it calls `land_pr(LandRequest(route=\"E\", risk=\"low\",\n  title=\"chore(\u003Cchange-id>): close stale bookkeeping\", commit_message=\"chore(\u003Cchange-id>):\n  archive completed change\", ...))`, merges `asdict(outcome)` into the result under `\"landing\"`,\n  and maps the outcome to the exit code (`landed`→0, `refused`→2, `code_defect`\u002F\n  `review_threads_blocking`→3, `ceiling`→4, anything else→1). A `flip_and_archive` error still\n  exits 1 without ever calling `land_pr`. The `worktrail-go` close-stale row is one integrated\n  invocation now (`worktrail-close-stale-openspec ... --base \"$BASE\" --run \"$RUN\" --json`), not a\n  separate `worktrail-land-pr` step. Confirming a task is truly shipped remains the agent's call.\n- **`cluster_detect.py`'s brief-to-brief focus-overlap signal abstains when either side carries\n  fewer than `MIN_FOCUS_TOKENS` (10) distinct tokens.** The overlap coefficient divides by the\n  *smaller* token set, so a very short focus text is trivially a near-subset of any longer brief\n  and clears `OVERLAP_THRESHOLD` on shared boilerplate alone: on\n  `tests\u002Ffixtures\u002Fclassifier_corpus.json` (as it stood before the 2026-09-19 regeneration) the 5-token focus `canonical checkout drift: \u003Crepo>`\n  scored 0.60 against five unrelated briefs, and 52 of the 112 pairs the threshold flagged\n  involved an item that thin. `_focus_overlap()` is the guarded wrapper carrying the floor and is\n  what `_signal_matches` and `_llm_gate_score` call, so a thin pair also never reaches the LLM\n  verification band and spends a call on noise; `_overlap_coefficient()` stays the raw\n  mathematical quantity for callers measuring something other than two briefs' focus text\n  (`create_handoff`'s spec-slug labels, `_target_task_edges`' task lines). A brief below the floor\n  is **not** excluded from clustering — `duplicate-slug`, `same-target-spec`, `related-link` and\n  `blocked-by` all still connect it; only the \"these two read alike\" signal abstains, and the same\n  floor gates which pairs `_judgment_candidates()` will offer to the relatedness judgment.\n\n## Critical files\n- `router\u002Fparse_invocation.py` — the `worktrail-go` Phase 1 grammar (`parse`, `FORMS`, `ALIASES`,\n  `NOUNS`, `MODES`, `render_forms`); never shells out or writes, reads `queue\u002F` only when a folder\n  is supplied, and delegates repo names to the caller (`--repos`) and brief-id resolution to\n  `work_queue.resolve()` so nothing here becomes a second implementation\n- `router\u002Fclassify.py` — `classify_risk()` and the `RISK_SIGNALS` table (the `authz` pattern's\n  `(?\u003C![-@])` compound-token guard lives here, now inside the extracted\n  `_classify_risk_by_keyword()`); also `classify()`'s two J-damping guards\n  (`_MENTION_ONLY_J_LABELS`, `_CI_CONFIG_RE`, `_CITED_AS_EXAMPLE_RE`; and\n  `_CONSUMER_MENTION_J_LABELS`, `_CONSUMER_BY_PHRASE_RE`) and the default-off\n  `risk_judgment_enabled` flag that `main()` is the only caller to enable\n- `router\u002Ftypesafe.py` — the one client both judgment backends share: `API_URL`\u002F`MODEL`\u002F\n  `API_KEY_ENV`\u002F`TIMEOUT_S`, `is_configured()`, `post(state, questions)`, the strict `noul()`\n  reader, and the `JUDGMENT_ERRORS` tuple that defines \"unavailable\"; knows nothing about either\n  question set, and is where a new backend gets its transport instead of copying one\n- `router\u002Frisk_judgment.py` — the second `classify_risk` backend: `QUESTIONS` (one blast-radius\n  score plus the four red-line nouls), `is_configured()`, `ask()`'s single request,\n  `parse_answers()`'s strict shape check, the pure `compose_tier()` mapping onto\n  `classify.RISK_ORDER`, and `judge_risk()`'s `None`-on-any-failure contract (its `asker`\n  parameter is the injection seam tests use instead of a network fake); the tier policy lives in\n  `compose_tier()`, never in the service's answer\n- `router\u002Frelatedness_judgment.py` — the second `cluster_detect` focus backend: the two-Noul\n  `QUESTIONS` (`same_work`, `should_cluster`), the pure `should_edge()` union rule at\n  `JUDGMENT_THRESHOLD`, `judge_pair()`'s `None`-on-any-failure contract (same injectable `asker`\n  seam), and `judge_pairs()`'s order-preserving concurrent batch (`MAX_CONCURRENCY`); the edge\n  rule lives in `should_edge()`, never in the service's answer\n- `router\u002Fpolicy.py` — `load_policy()`; the single source of truth for a repo's resolved GO policy;\n  also `parse_policy_yaml`\u002F`_parse_scalar` (the flat parser and its inline-flow-sequence handling),\n  `POLICY_KEY_TYPES`\u002F`_SWEEP_SKIP`\u002F`_TYPE_SWEEP_EXEMPT`\u002F`_sweep_key_types()` (the coarse type sweep\n  that runs ahead of the per-key checks; covered by `tests\u002Frouter\u002Ftest_policy_key_types.py`) and\n  `automerge_eligible()` (including the `target_branches` scalar coercion)\n- `router\u002Fenv_profile.py` — `resolve_env_profile()`: expands `from`, requires an absolute path\n  (refused rather than resolved relative to the routing file, because `explicit_cell_override`\n  points `WORKTRAIL_ROUTING_FILE` at a mkstemp file under \u002Ftmp), JSON-parses the file, requires\n  a mapping `env` object, asserts every `expect` entry, then copies every `keys` entry; refuses\n  a missing\u002Fempty\u002Fnon-string key. Every failure raises `OperatorConfigError` naming target,\n  profile, file and key, and **no message ever contains a value for a key not named in\n  `expect`** (the operator declared that key non-secret by asserting on it, and only that key).\n  Deliberately not in `spawnlib`\u002F`routing_cli`\u002F`policy`: `routing_cli` imports\n  `..orchestrator.agent_capacity` and `spawnlib` imports `..router.routing_cli`, so a\n  module-level `routing_cli → spawnlib` edge would be an import cycle, and `policy.py`'s\n  validator must never open a profile file — reads belong at spawn and `--check` time.\n- `router\u002Frun_record.py` — `finish()`'s ten-state enforcement and its two code-enforced gates;\n  `cmd_scope_review` write-time reason validation and `OUT_OF_SCOPE_REASON_PREFIXES`;\n  `cmd_capacity_gate`'s `_iso_retry_after` timestamp validation; `cmd_set_list`'s list write\n  (and its `status` refusal) plus `_scalar_list_field_hint()`, the refusal all three\n  list-appenders raise through; `_load_lenient()`, the\n  skip-and-warn wrapper around the raising `_load()` that every directory-wide scan (including\n  `reconcile_pr_labels.load_run_index()`, `check_deferred_work_handoff.py`, and\n  `check_durable_artifact_capture_gate.py`) should use instead of the raising loader\n- `router\u002Fpre_pr_gate.py` — `scope_review_failures()`, the latest-entry-per-item scope gate\n  that `finish` calls\n- `router\u002Fpr_labels.py` — the one place that issues the `go:risk-*` REST label correction; both\n  `drain.py` and sdd-workflow's Phase 8 call into it rather than reimplementing it\n- `router\u002Freconcile_pr_labels.py` — `load_run_index()`, the scheduled sweep that maps every PR URL\n  under a runs dir to its `{risk_level, gates, route}`, tolerant of one malformed record via\n  `run_record._load_lenient`\n- `router\u002Fcheck_deferred_work_handoff.py` — the Stop-hook deferred-work handoff guard;\n  `load_deferred_work_entries()` reads `deferred_work` entries via `_load_lenient` and now prints\n  its discarded warning to stderr instead of silently skipping a malformed record\n- `router\u002Fcheck_durable_artifact_capture_gate.py` — the Stop-hook durable-artifact capture gate;\n  `find_planned_run_records()` reads run records via `_load_lenient` and now prints its discarded\n  warning to stderr instead of silently skipping a malformed record\n- `router\u002Fdashboard.py` — pure file inspection (no git, network, or agents); spec lifecycle stage\n  and next-action detection; also the source of `_resolve_repo_dir()`, which `skill_dispatch.py`'s\n  single-brief-triage path uses to resolve a bare `repo:` value to an on-disk checkout, of\n  `smoke_flake_aggregate()`, which builds the always-present `smoke_flakes` payload key, and of\n  the `compute_clusters` call site that injects `relatedness_judgment.judge_pairs` (only when\n  configured) and `cluster_telemetry.log_judged_pairs`\n- `router\u002Fsmoke_flake_selfcheck.py` — `check_repo()`, the per-repo smoke-flake detector that reads\n  recorded flakes out of a repo's run journals (recency-windowed) and that\n  `dashboard.smoke_flake_aggregate()` calls once per in-scope repo\n- `router\u002Fland_pr.py` — `land_pr()`, `LandRequest`\u002F`LandOutcome`; the shared\n  commit\u002Fcompile-marker\u002Fpreflight\u002Fpush\u002FPR\u002FCI-watch\u002Fmerge-guard\u002Freview-thread-gate\u002Ffinish pipeline\n  every PR-opening call site should compose with instead of reimplementing a subset; `_push()`'s\n  explicit-refspec + `detail_out` contract lives here, as does `_gh()`'s `base_slug` (`-R \u003Cslug>`)\n  scoping of every post-PR-open call, and `_refusal_line()`'s stderr `REFUSED at \u003Cstep>: \u003Cdetail>`\n  line for the operator (stdout's JSON payload is unchanged)\n- `router\u002Fautomerge_preflight.py` — `required_checks_gate()`, `owner_repo_from_git()`,\n  `push_remote_name()`, `is_preflight_query_error()`; the live GitHub-side half of the automerge\n  gate and the single resolution point for the *read* side's target remote, so the gate can never\n  inspect a different repository than `land_pr` pushes the branch and opens the PR against\n- `router\u002Fclose_stale_openspec.py` — `flip_and_archive()` plus `main()`'s `land_pr` landing and\n  outcome→exit-code mapping for the `worktrail-close-stale-openspec` console script\n- `router\u002Fcluster_detect.py` — the brief-clustering signals (`_signal_matches`, `_llm_gate_score`)\n  that `workqueue\u002Fcreate_handoff.py` consumes; `_focus_overlap()` is the guarded focus comparison\n  carrying `MIN_FOCUS_TOKENS`, while `_overlap_coefficient()` stays the raw coefficient every\n  non-focus caller keeps reading; `_judgment_candidates()`\u002F`_apply_relatedness_judgment()` own\n  *which* pairs are worth judging and *what a verdict does to an edge* (`JUDGED_MATCH`,\n  `JUDGMENT_PREFILTER_FLOOR`, `MAX_JUDGED_PAIRS`) while the client and the telemetry writer stay\n  injected\n- `router\u002Fcluster_telemetry.py` — the one append-only cluster log; `log_shown`, `log_outcome`, and\n  `log_judged_pairs()`'s `judged` record kind (members, overlap, both Noul values, verdict), all\n  best-effort writers that never affect what they record\n\n---\n**Last Updated:** 2026-10-05\n","You are working on **worktrail's GO v2 front door**: loading repo policy, classifying free-text\nrequests into routes, tracking run records, and rendering the resume dashboard.\n\n## Domain purpose\n`router\u002F` is what `\u002Fgo`-style front doors consume to decide what a repo allows (policy), which\nroute a request maps to (classify), what already happened (run_record, dashboard), and whether a\nspawned agent's own `gh pr create` came out correctly labeled (pr_labels). Nothing here spawns\nagents or writes task files — that is `orchestrator\u002F`'s job.\n\n## Business rules \u002F invariants\n- **The front-door grammar is code, not prose: `parse_invocation.py` owns it.** The shape is\n  `\u003Cfront-door> [\u003Crepo>] \u003Cnoun> \u003Cverb> [args]` with exactly four nouns (`NOUNS`: `handoff`,\n  `spec`, `pr`, `decision`), plus two deliberate bare shortcuts (`\u003Cbrief-id>` = `handoff start \u003Cid>`, and\n  `\u003Crepo>` = that repo's dashboard) and the read-only `help`\u002Fempty invocations. Every\n  pre-noun-verb spelling (`auto`, `drain`, `new`, `implement spec \u003Cid>`, `continue`, `pr`,\n  `brainstorm`, `fix`, `route:\u003CA-J>`, `handoff:\u003Cid>`) is **permanent, not deprecated** — `ALIASES`\n  lists them and `_canonicalize` rewrites only a bare leading token, so a spelled-out noun-verb form\n  is never rewritten twice. Add a new form to `FORMS`\u002F`ALIASES` and the parser together, never one\n  without the other.\n- **`decision list` \u002F `decision answer \u003Cdecision-id>` are their own modes (`decision_list`,\n  `decision_answer`), not intents or brief lookups.** The parser carries the id in the result's\n  `decision_id` field and never tries to resolve it against `queue\u002F` (`brief_status` stays `None`);\n  `decision answer` with no id is `mode: help` with `help_topic: decision`. The `worktrail-go`\n  skill skips the dashboard entirely for both and runs `worktrail-decision` \u002F the\n  `answer-decision.md` procedure directly.\n- **A noun with no recognised verb returns `mode: help`, never free text.** Free text containing\n  the word `handoff` classifies to Route E at high confidence in `classify.py` (joint-highest-weight\n  signal plus a state boost whenever the queue is non-empty), so anything that escapes the parser\n  lands on the wrong route silently. `handoff new` must also never reach the intent branch as\n  `repo=handoff, intent=new` — the noun-verb match runs above the bare intent words on purpose.\n  `pr` is the one exception: bare `pr` (and `pr \u003Ctext>`) still means the old `pr` intent.\n- **`RISK_SIGNALS`' `authz` pattern carries a `(?\u003C![-@])` guard so it cannot fire inside a\n  compound token.** `\\b` treats the hyphen in a package name like `better-auth` (or the `@` in\n  `@auth\u002Fcore`) as a word boundary, so merely naming the dependency scored `high:authz`.\n  Confirmed live 2026-09-10 (run `go-20260910-085556`, devops PR #366): a config-only PR\n  classified `risk=high`, exceeded that repo's policy `max_risk=medium`, and was labeled\n  `go:no-automerge`, forcing a hand merge. This is a word-boundary artifact inside one token,\n  **not** the diff-blindness the `RISK_SIGNALS` table comment deliberately fails loud on.\n  Underscore-joined identifiers (`require_auth`) were already excluded (`_` is a word character);\n  `auth-related` still matches, because the guard looks only at what *precedes* the word.\n- **`classify_risk()` has two backends over one `RISK_ORDER` mapping, and the keyword table is\n  both the default and the fallback.** `classify_risk(text, *, judgment=False)` keeps its shape;\n  `_classify_risk_by_keyword()` is the extracted `RISK_SIGNALS` body, and\n  `risk_judgment.judge_risk()` is the second backend — one request asking for a 4-level\n  blast-radius score plus four red-line nouls (`irreversible_data_loss`,\n  `weakens_access_control`, `moves_money`, `disables_a_safeguard`), never for a tier, a label, or\n  a merge decision. The service observes; the pure, offline `compose_tier()` decides: the score\n  sets the baseline tier (rounded and clamped onto `_TIERS`), a hard red line at or above\n  `RED_LINE` (0.70) forces `critical`, the safeguard red line forces `high`, and a red line is a\n  **floor** — it can only raise a baseline, never lower one, because a change can read \"ordinary\"\n  on blast radius and still destroy data. Labels keep the `\u003Ctier>:\u003Clabel>` shape\n  (`medium:blast-radius`, `critical:moves-money`), so a judged tier is readable as such with no\n  second field. Why it exists: the keyword table tiers on word presence alone, and measured\n  2026-09-19 on `tests\u002Ffixtures\u002Frisk_probes.json` it got 8\u002F24 exact tiers and 10\u002F24 auto-merge\n  gate decisions — rating prod data deletion, an auth fail-open, refund re-submission and\n  \"make a required check non-blocking\" *mergeable*, and seven trivial doc\u002Ftest changes\n  *critical* — against the judgment's 20\u002F24 and 24\u002F24 with zero of either error.\n- **The judgment fails safe into the keyword table, always.** `judge_risk()` returns `None` — the\n  \"use the keyword table\" signal — on a missing `TYPESAFE_API_KEY`, an HTTP or transport error, a\n  timeout (`typesafe.TIMEOUT_S`, deliberately short: a tier that arrives after the operator gave up\n  is worth less than the immediate fallback), an unparseable body, or an answer set missing a field.\n  `parse_answers()` raises `ValueError` on any shape it does not recognise rather than reading a\n  missing noul as zero, so a changed or truncated response can never compose a falsely-low tier.\n  The fallback errs toward over-gating, which is the safe direction. CI needs no key and no\n  network: with the key unset the judgment path is never entered and behaviour is exactly the\n  pre-judgment one.\n- **Both judgment backends share one client, `router\u002Ftypesafe.py`, and one failure-mode rule.**\n  The endpoint (`API_URL`), `MODEL`, `API_KEY_ENV`, `TIMEOUT_S`, `is_configured()`, the\n  single-request `post(state, questions)`, the strict `noul(answers, key)` reader, and the\n  `JUDGMENT_ERRORS` tuple live there — `risk_judgment.py` re-exports `API_KEY_ENV` so its own\n  readers and tests keep one import. A second copy of the transport would be one more place for\n  the \"what counts as unavailable\" contract to drift; add a new backend by importing this module,\n  never by re-implementing the POST.\n- **`cluster_detect`'s focus signal also has two backends, and the lexical threshold is both the\n  prefilter and the fallback.** `relatedness_judgment.judge_pairs()` asks two Nouls per pair —\n  `same_work` (one item subsumes the other) and `should_cluster` (distinct work that causes\n  rework if done apart) — and the pure, offline `should_edge()` forms an edge when **either**\n  clears `JUDGMENT_THRESHOLD` (0.70). The union is deliberate: requiring both would drop exactly\n  the \"different work, must land together\" case the second question exists for. Why it exists,\n  measured 2026-09-19 in both directions: three pairs describing identical work in different\n  vocabulary scored **0.00-0.12** token overlap — invisible to `OVERLAP_THRESHOLD` (0.45) — while\n  the judgment rated them **0.76-0.86** on `same_work`; and of the 14 highest-overlap real corpus\n  pairs, **7 were unrelated** on inspection (two different epics' decomposition-gap briefs, a\n  reject-UI brief against a vitest-coverage brief).\n- **The lexical stage is demoted to a prefilter, never removed.** `_judgment_candidates()` picks\n  which pairs are worth a request at `JUDGMENT_PREFILTER_FLOOR` (0.05 — far below the edge\n  threshold on purpose, because a prefilter near 0.45 would reproduce the blindness being fixed)\n  and ranks them by overlap descending; `MAX_JUDGED_PAIRS` (40) caps one scan, because pair count\n  grows quadratically with queue size (68 briefs is 2278 pairs before repo scoping) and a\n  dashboard render may not fan out unbounded. Everything past the cap — and every pair at all when\n  the judgment is unavailable — keeps the lexical decision unchanged. The repo-scoping\n  precondition and the `MIN_FOCUS_TOKENS` thin-brief abstention are unchanged: a cross-repo pair\n  is never offered, and a brief too thin for the coefficient to read is one the judgment cannot\n  read either.\n- **A verdict replaces the focus signal and nothing else.** `_apply_relatedness_judgment()` swaps\n  a judged pair's `focus-overlap` match for `JUDGED_MATCH` (`focus-judgment`, so a reader and the\n  telemetry log can tell which rule decided) when the pair belongs together, and for **nothing**\n  when it does not — that is how a high-overlap-but-unrelated pair loses its edge. Structural\n  matches (duplicate-slug, same-target-spec, related-link) are never touched: they are facts about\n  the briefs, not a reading of their text. The whole candidate batch is handed over in ONE call,\n  already capped and ordered, so the injected side owns concurrency (`MAX_CONCURRENCY`, 8) and\n  `cluster_detect` holds no thread pool and no client; verdicts come back positionally aligned and\n  the **first** unavailable one ends the pass, because applying a later verdict past a gap would\n  make the surfaced clusters depend on which round trip failed.\n- **The judgment client is injected into `cluster_detect`, never imported by it.**\n  `compute_clusters(..., judge_pairs_fn=None, log_judged_fn=None)` defaults both to `None`, so\n  every existing caller keeps prior behaviour exactly; `dashboard.py` is the call site that\n  injects `relatedness_judgment.judge_pairs` (only when `is_configured()`) and\n  `cluster_telemetry.log_judged_pairs`. Same pattern as `_parse_fm` and `task_candidates_fn` —\n  `cluster_detect`'s own guard test rejects any network module in that file, and its contract is\n  read-only and never-crash.\n- **Every judged pair is logged for later tuning.** `cluster_telemetry.log_judged_pairs()` appends\n  one `judged` record per pair (members, the lexical overlap that ranked it, both Noul values, and\n  the verdict) sharing one timestamp, so `JUDGMENT_THRESHOLD` and the prefilter floor can be\n  retuned against real pairs without paying for inference again. Best-effort like the module's\n  other writers: the edges are already decided by the time it runs, so a failed write costs a\n  tuning datapoint and nothing else.\n- **`classify()` stays pure by default: `risk_judgment_enabled` defaults to `False`.** Only\n  `main()` turns it on, with `--no-risk-judgment` to opt out — the same confinement\n  `cited_pr_states`' live `gh` lookup already has — so `classifier_coverage`'s replay and every\n  test stay deterministic, free and offline. Enabling it changes only the `risk`\u002F`risk_signals`\n  output; route selection, its confidence, and its reason never consult it.\n- **A J score built entirely from `_MENTION_ONLY_J_LABELS` (`routing-logic`, `classify-py`)\n  alongside a strong CI\u002Fconfig signal (`_CI_CONFIG_RE`: `.github\u002Fworkflows`, `.github\u002Frulesets`,\n  `required status check`, `branch protection`) is damped to zero** — that shape means the\n  routing\u002Fclassifier file is cited as evidence for unrelated CI\u002Fbranch-protection work, not the\n  actual change target (live incident 2026-09-10, brief 20260910-143657\u002Frun go-20260910-142322).\n  The damp does **not** fire when the same text also matches `_CITED_AS_EXAMPLE_RE` (`cites`,\n  `quotes`, `verbatim`, `worked example`, `as an example`, …): a genuine self-referential bug\n  report about `classify.py`'s own routing logic that happens to quote another brief's\n  CI-config text as a worked example was itself getting wrongly demoted from J to F (brief\n  20260910-152514: J=9 undamped vs F=6, confirmed reproducible). A citation cue means the\n  CI\u002Fconfig phrase is quoted evidence, not the report's own change target, so it must not\n  trigger the damp. Scoped narrowly to these two evidence-confirmed labels — do not widen\n  `_MENTION_ONLY_J_LABELS` without its own confirmed false-positive.\n- **A J score built entirely from `_CONSUMER_MENTION_J_LABELS` (`go-skill`, `front-door`) whose\n  only occurrence is a consumer by-phrase (`_CONSUMER_BY_PHRASE_RE`: a consumption cue —\n  `consumed`\u002F`used`\u002F`read`\u002F`called`\u002F`drives`\u002F… — followed by `by` and then the front door) is\n  also damped to zero** — that shape names the front door as a *consumer* of the result under\n  discussion, which cannot be the change target (live incident 2026-10-03, brief 20261003-204443:\n  the bare clause \"the machine-readable surface consumed programmatically by drain, queue-triage,\n  and the go front door\" scored J=7 at high confidence with every other route at 0). The by-phrase\n  frame is what separates the two shapes, so no citation carve-out is needed: \"add a guard to the\n  go front door so it stops misrouting consumer mentions\" still routes J. Damping is scoped to a J\n  score built *entirely* from these two labels — a request that also carries another J signal\n  (e.g. `cassette`) still wins on it. Do not widen `_CONSUMER_MENTION_J_LABELS` without its own\n  confirmed false-positive.\n- **The parser translates into the executor's vocabulary, not the user's.** `worktrail-sdd-workflow`\n  still speaks `handoff:\u003Cid>`, `route:\u003CX>`, and the v1 intent words (`V1_INTENTS`); so `spec\n  explore` yields `intent: brainstorm`, and `spec fix` yields `route: F` (the executor has no `fix`\n  intent). The result's `canonical` field carries the noun-verb spelling so the skill can print\n  `(reads as: worktrail-go \u003Ccanonical>)` when it differs from `raw`; it is `None` for free text.\n- **`worktrail-help`'s reference block is generated from `FORMS` + `ALIASES` via `render_forms()`**\n  and pinned by `tests\u002Frouter\u002Ftest_parse_invocation.py::test_help_forms_block_matches_the_parser_registry`\n  — regenerate it, never hand-edit it. Only `\u003Cfree text>` may carry `parsed=False`.\n- **`policy.py` uses two YAML parsers on purpose.** Most keys go through `parse_policy_yaml`, a\n  flat, stdlib-only, one-nesting-level subset. `routing:` and `add_ons:` are re-parsed with real\n  `yaml.safe_load` (`_resolve_routing`, `_resolve_add_ons`) because both need arbitrary nesting\n  the flat parser would flatten into siblings of the wrong key. Adding a new deeply-nested policy\n  key means adding a matching `_resolve_*` real-YAML path, not extending the flat parser. The one\n  narrow exception inside the flat parser is `_parse_scalar`: a value that starts with `[` and ends\n  with `]` is handed to `yaml.safe_load` so an inline flow sequence (`[]`, `[main, dev]`) loads as\n  a real list; anything that is not a valid flow sequence (an unclosed `[`, a quoted `\"[not a\n  list]\"`, a YAML error) stays a plain string. Before this, a documented `target_branches: []`\n  loaded as the truthy string `'[]'`.\n- **Policy resolution fails closed.** A malformed `add_ons`\u002F`routing`\u002F`automerge` shape falls back\n  to the safe default (`{}` \u002F `None` \u002F disabled) with a warning appended to `meta[\"warnings\"]`,\n  never widens autonomy. `automerge.max_risk`, `agent_cli`, `fallback_agent_cli`, `agent_model`,\n  `max_workers`, `pr_pacing_wait_s`, and `max_parallel_workers` are all validated\u002Fclamped the same\n  way in `load_policy`.\n- **`routing.env_profiles` names *where* a target's environment comes from and stores no values.**\n  `_validate_routing_env_profiles` (never-raise warn-and-drop, like its sibling\n  `_validate_routing_*` validators; resolved *before* `targets` and returned in the resolved\n  routing dict, because a target's `auth.profile` is validated against it) accepts\n  `{name: {from, keys, expect?}}` — `from` is a path to a JSON file with an `env` object, `keys`\n  lists which of that object's names to copy, and `expect` maps a name to the literal it must\n  equal before a worker may launch. `keys` and `expect` are deliberately independent: a key may\n  be asserted without being copied (provenance checking) or copied without being asserted (so\n  its value is never printable). A malformed `expect` drops the **whole profile**, not just the\n  assertion — a silently-dropped assertion is indistinguishable from a passing one, which would\n  defeat the only thing `expect` exists for.\n  `resolve_routing()` must carry this table into the resolved `{targets, tiers, roles, purposes,\n  default_tier, env_profiles, drain}` dict it returns: `spawnlib` reads the profile table off\n  *that* dict (never a second policy read, which could diverge from the table `select_cell`\n  served from), so dropping the key made every profile-bearing cell raise `OperatorConfigError`\n  (\"not declared in routing.env_profiles\") at launch even when the profile was declared —\n  confirmed live 2026-10-02, the drain's intake-triage spawn died on a `claude-deepseek` cell\n  whose `deepseek` profile was declared in `routing.yaml` all along.\n- **`auth.profile` and `auth.env` are mutually exclusive alternatives for one auth lane, and a\n  profile on a `subscription` target is a warning.** `_validate_routing_targets` warns on a\n  non-mapping `auth`, on both `env` and `profile` declared together (the spawn hard-fails; the\n  target is still kept so it appears in `--check`), and on `auth.profile` on a `subscription`\n  target, because that lane strips `ANTHROPIC_API_KEY` *after* profile injection — a\n  profile-supplied key cannot survive there, though the target is still valid for non-key\n  variables. `auth.codex_home` alongside a profile is not a conflict (it selects a home, not\n  credentials). `_warn_undeclared_env_profiles` warns when an `auth.profile` names a profile\n  `env_profiles` does not declare; the target is kept (mirroring \"`pool: api` without\n  `api_opt_in` is kept but ineligible\") and the authoritative failure is at spawn.\n- **`worktrail-routing --check` resolves every `auth.profile` cell against the real file**,\n  marking the cell `FAIL`, printing the full `OperatorConfigError` to stderr, and exiting 1 —\n  but deliberately NOT recording an `agent_capacity` gate. A recorded gate is skipped *silently*\n  by `select_cell` on the next spawn, which would turn a loud configuration error into an\n  invisible fallback to the next rung — precisely the failure class env profiles exist to\n  remove. Gates model provider conditions; this is operator config, and its `auth` cooldown\n  would outlive the fix.\n- **`load_policy()` runs a coarse type sweep (`_sweep_key_types`) before the per-key checks; the\n  two layers are deliberately separate.** `POLICY_KEY_TYPES` declares an expected type (or tuple)\n  for every flat `DEFAULTS` key, and a wrong-typed value is replaced by its `DEFAULTS` entry with\n  one `meta[\"warnings\"]` line (`\u003Ckey> must be \u003Ctype>[ or null]; got \u003Cvalue!r> — using default\n  \u003Cdefault!r>`) — e.g. `protected_paths: migrations\u002F` becomes `[]`, `pre_pr_cmd: true` becomes\n  `None`. A key whose default is `None` also accepts `None`, and a YAML `true` never satisfies an\n  integer key (`bool` is an `int` subclass). The per-key checks further down `load_policy` still\n  run last, unchanged, and own value-level rules (allowed literals, integer minimums, per-entry\n  cleaning). `routing`\u002F`add_ons` are exempt (`_TYPE_SWEEP_EXEMPT`; their own resolvers run first),\n  and every key that already has a stricter per-key check is declared in `POLICY_KEY_TYPES` but\n  listed in `_SWEEP_SKIP` so the sweep never swallows a value before that check's own warning text\n  (which callers assert on) can fire — the sweep effectively covers the keys that had no\n  value-level check at all. `run_record_dir` restores its lazily-resolved\n  `default_run_record_dir()`, not `None`.\n- **A bare string under `require_human_routes` or `automerge.target_branches` is NOT a type error.**\n  Both are declared `(list, str)`: `automerge_eligible()` tests `route in require_human_routes`, so\n  a single-route `require_human_routes: B` is a working gate that sweeping it to `[]` would silently\n  open, and it already normalizes a bare `target_branches: dev` to a one-branch list. Only a value\n  that is neither (e.g. `target_branches: 7`) falls back to `[]` with a warning naming\n  `automerge.target_branches`. The sweep reaches `automerge.target_branches` separately because it\n  is a flat key living one level down. A policy key added to `DEFAULTS` with no `POLICY_KEY_TYPES`\n  entry (and not in `_TYPE_SWEEP_EXEMPT`) fails\n  `tests\u002Frouter\u002Ftest_policy_key_types.py::test_every_defaults_key_has_a_declared_type_or_is_exempt`.\n- **`automerge.target_branches` empty means \"base branch only\", and a scalar is one branch, not a\n  substring.** `automerge_eligible()` treats `target_branches: []` (and unset) as no filter; a\n  non-empty list rejects any PR whose target branch is not in it (`target branch \u003Cb> not in\n  [...]`). A hand-edited scalar `target_branches: main` is coerced to `[\"main\"]` before the check,\n  because a bare string would otherwise fall through to a substring test (`'ma' in 'main'`). Both\n  the `[]` spelling and the scalar case are pinned in `tests\u002Frouter\u002Ftest_policy.py`.\n- **`max_parallel_workers` (default 6, minimum 1) is a ceiling, not a width.** It only applies when\n  neither `--max-workers` nor policy `max_workers` is set: `live._resolve_max_workers` then runs\n  `min(plan width, max_parallel_workers)` workers instead of a fixed 3 (a width-7 plan ran as three\n  serial ticks on 2026-09-02). A set `max_workers` still wins outright. Invalid values\n  (non-int, bool, `\u003C 1`) drop to the default with a `meta[\"warnings\"]` entry, same as the other\n  integer keys.\n- **Integer policy keys follow the `triage_keep_limit` validation pattern.** `triage_keep_limit`\n  (default 2) and `triage_max_queue_age_days` (default 14) are the intake-triage escalation\n  bounds: a value that is not an `int`, is a `bool`, or is below 1 is forced back to `DEFAULTS[key]`\n  with a `meta[\"warnings\"]` entry naming the key. Their consumer is `workqueue\u002Fqueue_triage.py`'s\n  escalation, which reads them with `.get(key, default)` so the policy side and the consumer side\n  can land in either order — as of 2026-09-02 the keys are in `DEFAULTS` but no consumer reads\n  them yet in this checkout. Copy this loop when adding another bounded-int key rather than\n  inventing a new validation shape.\n- **Plan-shape and review-skip keys use that same bounded-int loop.**\n  `compile_max_critical_path_over_width` (default 2, min 1) and `compile_max_same_file_chain`\n  (default 2, min 1) are the plan-shape gates `conductor\u002Fcompile.py` consumes: a compiled plan is\n  rejected when its critical path exceeds `max(width, compile_max_critical_path_over_width)` or a\n  dependent chain all touching one file exceeds `compile_max_same_file_chain`.\n  `review_skip_max_diff_lines` (default 0 = disabled, min 0) is the fast path `orchestrator\u002Flive.py`'s\n  `drive()` consumes beside `_review_exempt`: when > 0, a task's first review is skipped once the\n  implement report is a verified success under that many added+removed diff lines (test files\n  excluded). Invalid values drop to the default with a `meta[\"warnings\"]` entry.\n- **`pre_commit_cmd` (default `None`) is the one optional-string policy key.** A non-string,\n  non-`None` value is forced to `None` with a warning. Its consumers are `orchestrator\u002Fdispatch.py`\n  (a worker-prompt hard rule for implement\u002Ffix and the ci-fix group prompt) and\n  `orchestrator\u002Flive.py`\u002F`verify.py` (post-commit amend backstop). `None` means repos without a\n  wired command see no behavior change. `onboarding\u002Frepo_init.py`'s `detect_pre_commit_cmd`\n  seeds it into a fresh `.worktrail\u002Fpolicy.yaml` by scanning `.github\u002Fworkflows\u002F*.yml|yaml`\n  `run:` step lines for `ruff`\u002F`oxlint`\u002F`prettier` (`PRE_COMMIT_CMD_BY_LINTER`, joined with `&&`\n  in that order); an existing policy file is never touched.\n- **`automerge.enabled: false` does not, by itself, block orchestrator-driven merges.** Only\n  `automerge_eligible()` reads that key, and only when an agent follows sdd-workflow's Phase 8\n  merge-gate instructions — `orchestrator`'s own `auto_merge()` is a separate code path that\n  unconditionally calls `gh pr merge` once CI passes and does not consult this key at all.\n- **Run records enforce ten explicit completion states** (`run_record.py` `finish`, §22) — a run\n  can never end in vague language. `finish` also code-enforces `no_implementation_without_approval`\n  (a route-A run cannot finish on an implementation-completion state without a recorded\n  `decisions` entry first) and `pre_pr_gate.py`'s `scope_review_failures()`, unconditional on\n  route, exactly once per run regardless of how many group PRs the orchestrator created.\n- **Scope-review entries are append-only; the gate judges only the latest entry per `--item`.**\n  `scope_review_failures()` collapses `status | item | detail` entries to the last one per item\n  before checking `blocked` \u002F `out-of-scope`, so re-recording an item supersedes an earlier\n  mis-phrased or blocked entry (and a later `blocked` entry can equally regress a prior\n  `complete`). Malformed entries still fail regardless of position.\n- **An `out-of-scope` reason must begin with a prefix from `run_record.OUT_OF_SCOPE_REASON_PREFIXES`**\n  (`different purpose:` \u002F `user approved:`). `cmd_scope_review` rejects any other reason at write\n  time with `SystemExit`, and `scope_review_failures()` re-checks the same tuple at gate time so a\n  hand-edited record is still caught. Extend the tuple, never the two call sites separately.\n- **`set-list PATH KEY [VALUE ...]` is the only invocation that writes a list field, and the repair\n  path for a list-typed field left holding a scalar.** `set` stores its VALUE verbatim, so\n  `set PATH handoffs_consumed '[\"a\",\"b\"]'` writes the **string** `'[\"a\",\"b\"]'`, and every appender\n  into that field — `append`, `intervention` (`interventions`), and `record_decision_event`\n  (`pending_decisions`) — then refuses to touch it (brief 20261003-204455, where the documented\n  recovery from `append` was itself a dead end). `cmd_set_list` writes `list(VALUES)` (no values\n  produces `[]`, so an emptied field is expressible) and rejects `status`, which is a phase, not\n  a list, with `SystemExit` naming `set`. All three append refusals share\n  `_scalar_list_field_hint(key)`, which names `set-list` — the old `append` message said \"use\n  `set`\", a command that cannot perform the repair.\n- **`classifier_coverage.py` reports a `handoffs_consumed` shape it cannot read as ids, and never\n  decodes one.** `_consumed_ids()` returns `(ids, diagnostics)`: a list of id strings (what every\n  current writer produces) and a single plain id string (the older `set` form, still on disk) are\n  ids, while a JSON-encoded array\u002Fobject stored as a string (the same `set PATH handoffs_consumed\n  '[\"a\",\"b\"]'` footgun the bullet above describes), a comma-joined string, a non-string value, and a\n  non-string list entry are diagnostics. Each malformed shape used to come through as ONE brief id\n  that cannot exist, so the run's real attribution silently vanished from the `actual` join and this\n  audit never surfaced it (brief 20261003-221534). They are reported, never parsed and never split —\n  recovering the real ids is a separate judgment about what those records meant.\n  `load_actual_routes_with_diagnostics()` is the audit's loader (`load_actual_routes()` is its\n  `routes` projection; the newest run id still wins when several consumed one brief), the\n  diagnostics land in the `--json` payload as `corpus.malformed_consumed_records` (`record`,\n  `reason`, `value`), and `render_report` prints a `malformed handoffs_consumed: N record(s)` line\n  whenever that list is non-empty, so a reader knows `actual` is blind rather than complete.\n- **`capacity-gate --retry-after` is validated as ISO-8601 and stored verbatim, never slug-sanitized.**\n  `cmd_capacity_gate` runs it through `_iso_retry_after` (a `datetime.fromisoformat` check that\n  raises `SystemExit` on a non-ISO value) rather than `_safe_provider`, which is a slug sanitizer\n  and turned `+00:00` into `_00:00` — an offset every downstream `retry_after` consumer\n  (`orchestrator\u002Fagent_capacity._parse_time`) then failed to parse (fixed 2026-09-06). Only\n  `--provider` and `--failure-class` go through `_safe_provider`.\n- **`finish` best-effort-applies the `go:risk-*` PR label correction** (`pr_labels.\n  ensure_pr_risk_label`) whenever the record carries a `pull_request` — a spawned headless agent's\n  raw `gh pr create` is never reachable by the interactive Claude Code PreToolUse\n  label-enforcement hook (Codex\u002FOpenCode have no equivalent mechanism at all).\n- **PR label writes use the REST endpoint, not `gh pr edit --add-label`.** `gh pr edit`'s GraphQL\n  mutation also touches classic-Projects fields and fails outright on a repo\u002Forg with a legacy\n  Projects (classic) board still attached (confirmed live 2026-08-07). `_current_pr_labels`'s\n  read-only `gh pr view` call is unaffected and stays as-is.\n- **`reconcile_pr_labels.load_run_index()` now reads records through `run_record._load_lenient`,\n  not the raising `_load`** — a single unreadable\u002Fmalformed record (hand-edited outside\n  `run_record.py`'s own renderer) is skipped with a `WARNING: skipping unreadable run record: ...`\n  line on stderr instead of aborting the whole scheduled sweep. Same tolerance policy `_load_lenient`\n  already applies to `active-conflicts` and the other directory-wide `run_record.py` scans (fixed\n  2026-09-12).\n- **`check_deferred_work_handoff.load_deferred_work_entries()` and\n  `check_durable_artifact_capture_gate.find_planned_run_records()` — the two Stop-hook check\n  scripts — now surface that same `_load_lenient` warning too, instead of discarding it.**\n  Both previously unpacked `_warning` and threw it away, so a malformed run record failed silently\n  with no signal that the check had skipped data. Both now print\n  `WARNING: skipping unreadable run record: \u003Cdetail>` to stderr and skip the record, matching the\n  tolerance-with-visibility policy above (fixed 2026-09-12).\n- **`dashboard.py` detects spec artifacts by exclusion + content, never one strict filename\n  pattern.** Known auxiliary files (`user-request.md`, `decision-log.md`,\n  `traceability-matrix.md`, etc.) are named explicitly; any other top-level `*.md` is a candidate\n  spec doc, with a dated filename winning when several exist. A `## Clarifications` heading is\n  NOT the resolution-gate signal — only ~22\u002F46 real specs carry one; the gate keys on unresolved\n  `[NEEDS CLARIFICATION: ...]` markers in the spec body instead.\n- **The dashboard JSON payload's `smoke_flakes` key is always present, never absent.**\n  `smoke_flake_aggregate(repos)` calls `smoke_flake_selfcheck.check_repo()` once per in-scope repo\n  (both `--root` single-repo and `--repos` multi-repo mode), tags each entry with its repo name,\n  and merges them into one `{\"entries\": [...]}` keeping the detector's ordering (count desc, suite\n  asc), so a consumer can read the key without an existence check. The aggregate is passive: any\n  failure yields `{\"entries\": []}` and the `rendered` smoke-flake section is simply omitted — it\n  never breaks the dashboard. `smoke_flake_selfcheck` is imported unconditionally (the\n  detector-not-yet-shipped `try\u002Fexcept ImportError` fallback is gone now that the module ships).\n  The entry shape and the recency window are documented in\n  `skills\u002Fworktrail-go\u002Freferences\u002Fdashboard-render.md`.\n- **`skill_dispatch.evaluate_single_brief()`\u002F`apply_single_brief_verdict()` resolve a bare `repo:`\n  value to an on-disk checkout before using it as `cwd`.** A brief's `repo:` frontmatter is almost\n  always a short name (e.g. `\"worktrail\"`), not a path. `evaluate_single_brief` runs it through\n  `dashboard._resolve_repo_dir(resolved_repo, repos_root)` to build `group_cwd` whenever an\n  explicit repo is resolved and no `cwd` override was passed — previously it passed the bare name\n  straight through, which `subprocess.run` then rejected as a nonexistent relative `cwd` when\n  invoked from outside the target repo (e.g. `worktrail-go`'s normal cwd). `apply_single_brief_verdict`\n  now takes and forwards a `repos_root` parameter to `queue_triage.apply_verdicts()` so a\n  `propose-change`\u002F`fold-into-change` verdict's own `_resolve_repo_dir()` call can find the repo\n  too — both call sites must resolve consistently, not just the evaluate path (fixed together\n  2026-09-03).\n- **`land_pr.py` is the one shared PR-landing pipeline every PR-opening call site composes with,\n  instead of each reimplementing a subset of it.** `land_pr(LandRequest) -> LandOutcome` runs, in\n  order: commit pending work (refuses `dirty_tree` without a `commit_message`), the compile-marker\n  gate for every OpenSpec change whose `tasks.md` changed, the preflight gate + label read-back,\n  push, find-or-create the PR (shared with `orchestrator\u002Fintegrate.py`'s group-PR step), CI watch\n  to a terminal outcome (transient-infra reruns, no-checks-yet grace period, `code_defect` vs\n  `ceiling` classification via `CI_PATCH_ITERATION_CEILING`), the merge-state guard, the\n  review-thread gate, then finish (or, in checkpoint mode, append a decision to) the run record.\n  Refusal (steps 1-4) never touches the remote; a push or PR-create failure past that point is\n  reported as `outcome=\"ceiling\"`, never `refused`, because the remote is already mutated (an\n  untouched-remote promise `refused` would misrepresent). Registered as `worktrail-land-pr`\n  (`worktrail.router.land_pr:main`). See the module's own docstring for the authoritative ordered\n  step list — it exists because PR #902 shipped 112 gate-verified files that were never committed\n  before `git push`, a gap each prior call site (`queue_triage.py`, `drain.py`,\n  `orchestrator\u002Fintegrate.py`, and the agent-executed sdd-workflow\u002F`worktrail-go` prose) closed\n  differently or not at all. As of 2026-09-05 `drain.py` (`_land_remediation_pr`),\n  `close_stale_openspec.py`, and `workqueue\u002Fqueue_triage.py` all compose with it.\n- **`_push()` always pushes with an explicit `HEAD:\u003Cbranch>` refspec** (`git push -u \u003Cremote>\n  HEAD:\u003Cbranch>`), never a bare `git push` to the configured upstream: a branch created via\n  `git worktree add ... -b \u003Cbranch> origin\u002Fdev` tracks `origin\u002Fdev`, so a bare push targeted the\n  wrong remote branch (repro 2026-09-05, gracefully-giving-back PR #716). It no longer runs the\n  `rev-parse @{u}` upstream lookup at all. On a genuine `\"push\"` refusal it appends git's stderr\n  (falling back to stdout) to an optional `detail_out: list[str]` out-param, and `land_pr()`\n  surfaces that as `LandOutcome.detail` instead of `null` — an out-param rather than a widened\n  return type so existing callers\u002Fmocks of `_push(repo, branch, remote, runner)` keep working. A\n  timeout\u002F`OSError` still returns `\"push_ambiguous\"` with nothing appended. Regression tests live\n  in `tests\u002Frouter\u002Ftest_land_pr_push_refusal.py`, deliberately not in `test_land_pr.py`.\n- **`worktrail-land-pr` writes one `REFUSED at \u003Cstep>: \u003Cdetail>` line to stderr; stdout stays the\n  machine contract.** `_refusal_line()` takes the first non-blank line of `outcome.detail`,\n  truncating past `_MAX_REFUSAL_DETAIL_CHARS` (200) with a trailing `...`; an empty\u002F`None` detail\n  yields the step alone. `main()` prints it only for `outcome == \"refused\"`, alongside the unchanged\n  JSON payload (`--json` is required), so a machine consumer sees exactly what it saw before. It\n  exists because the operator otherwise gets a JSON blob and has to read this module to interpret it\n  — two live refusals in run go-20261003-153531 (PR #1402) each did, and refusal is the single most\n  common landing failure (brief 20261003-204324).\n- **Every post-PR-open `gh` call in `land_pr.py` is scoped to the push-target repo via `base_slug`,\n  never left to `gh`'s bare-number resolution.** `_gh(..., base_slug=)` appends `-R \u003Cbase_slug>`\n  (the slug `_push_target()` returns) when set; `_watch_ci`, `_checks_registered`, `_log_excerpt`,\n  `_pr_is_merged`, `_merge_state_guard` (including its `gh run rerun`), and `_review_thread_gate`\n  all take and thread it. On a `remote.pushDefault=fork` checkout `origin` is the upstream, so a\n  bare PR number or run id resolved against the upstream's same-numbered — and often long-merged —\n  PR, and `land_pr()` reported `completed_and_merged` \u002F `\"merged externally\"` while the fork PR\n  was still OPEN (live 2026-09-18, behindthedash\u002Faspens PR #15 vs upstream `aspenkit\u002Faspens` #15).\n  `_review_thread_gate` splits the slug into `owner`\u002F`name` and passes them to\n  `check_review_threads.check`, which otherwise derives them from `origin`. With no\n  `pushDefault`, `base_slug` is `None` and calls are unchanged. Any new PR- or run-scoped `gh`\n  call added to `land_pr.py` must take `base_slug` too.\n- **`automerge_preflight` reads the remote the PR will actually be opened against, and refuses\n  rather than falling back to another one.** `required_checks_gate()` resolves the target remote\n  once via `push_remote_name()` (`remote.pushDefault`, else `origin`) and threads it into\n  `owner_repo_from_git(..., remote=)`; both also accept an explicit `remote` override. A selected\n  remote that does not exist returns `None` — the old fallback to `origin` answered about a\n  *different repository*, which on a fork layout is the read-only upstream (behindthedash\u002Faspens\n  PR #26, 2026-09-18: the gate read `aspenkit\u002Faspens`'s `allow_auto_merge=false` and put\n  `go:no-automerge` on a PR that was never going to be opened there). The refusal reason names\n  the remote it tried, and `is_preflight_query_error()` stays False for it — an unresolvable\n  remote is a confirmed state, not a transient read failure. The orchestrator's adapter\n  (`verify.Verifier._preflight_runner`) rewrites **every** `git` call to `git -C \u003Crepo> ...`, not\n  just `git remote get-url`: the verifier's runner executes from its own neutral cwd, so an\n  unpinned `git config --get remote.pushDefault` read would answer for that directory and\n  silently re-select `origin`.\n- **`flip_and_archive`'s default (`task_ids=None`) targets *every* task id, not just the pending\n  ones.** The whole point of this module is bookkeeping drift, and its purest case is a change whose\n  `tasks.md` is already 100% `[x]` but was never archived. A pending-only default left both\n  `flipped` and `already_checked` empty for that change, so the \"nothing to flip\" guard refused to\n  archive exactly the case it exists to close. Already-checked ids land in `already_checked` rather\n  than being skipped, so the default path still archives a fully-checked change.\n- **`close_stale_openspec.py` now lands the PR itself.** `main()` requires `--base` and `--run`;\n  after a successful `flip_and_archive` it calls `land_pr(LandRequest(route=\"E\", risk=\"low\",\n  title=\"chore(\u003Cchange-id>): close stale bookkeeping\", commit_message=\"chore(\u003Cchange-id>):\n  archive completed change\", ...))`, merges `asdict(outcome)` into the result under `\"landing\"`,\n  and maps the outcome to the exit code (`landed`→0, `refused`→2, `code_defect`\u002F\n  `review_threads_blocking`→3, `ceiling`→4, anything else→1). A `flip_and_archive` error still\n  exits 1 without ever calling `land_pr`. The `worktrail-go` close-stale row is one integrated\n  invocation now (`worktrail-close-stale-openspec ... --base \"$BASE\" --run \"$RUN\" --json`), not a\n  separate `worktrail-land-pr` step. Confirming a task is truly shipped remains the agent's call.\n- **`cluster_detect.py`'s brief-to-brief focus-overlap signal abstains when either side carries\n  fewer than `MIN_FOCUS_TOKENS` (10) distinct tokens.** The overlap coefficient divides by the\n  *smaller* token set, so a very short focus text is trivially a near-subset of any longer brief\n  and clears `OVERLAP_THRESHOLD` on shared boilerplate alone: on\n  `tests\u002Ffixtures\u002Fclassifier_corpus.json` (as it stood before the 2026-09-19 regeneration) the 5-token focus `canonical checkout drift: \u003Crepo>`\n  scored 0.60 against five unrelated briefs, and 52 of the 112 pairs the threshold flagged\n  involved an item that thin. `_focus_overlap()` is the guarded wrapper carrying the floor and is\n  what `_signal_matches` and `_llm_gate_score` call, so a thin pair also never reaches the LLM\n  verification band and spends a call on noise; `_overlap_coefficient()` stays the raw\n  mathematical quantity for callers measuring something other than two briefs' focus text\n  (`create_handoff`'s spec-slug labels, `_target_task_edges`' task lines). A brief below the floor\n  is **not** excluded from clustering — `duplicate-slug`, `same-target-spec`, `related-link` and\n  `blocked-by` all still connect it; only the \"these two read alike\" signal abstains, and the same\n  floor gates which pairs `_judgment_candidates()` will offer to the relatedness judgment.\n\n## Critical files\n- `router\u002Fparse_invocation.py` — the `worktrail-go` Phase 1 grammar (`parse`, `FORMS`, `ALIASES`,\n  `NOUNS`, `MODES`, `render_forms`); never shells out or writes, reads `queue\u002F` only when a folder\n  is supplied, and delegates repo names to the caller (`--repos`) and brief-id resolution to\n  `work_queue.resolve()` so nothing here becomes a second implementation\n- `router\u002Fclassify.py` — `classify_risk()` and the `RISK_SIGNALS` table (the `authz` pattern's\n  `(?\u003C![-@])` compound-token guard lives here, now inside the extracted\n  `_classify_risk_by_keyword()`); also `classify()`'s two J-damping guards\n  (`_MENTION_ONLY_J_LABELS`, `_CI_CONFIG_RE`, `_CITED_AS_EXAMPLE_RE`; and\n  `_CONSUMER_MENTION_J_LABELS`, `_CONSUMER_BY_PHRASE_RE`) and the default-off\n  `risk_judgment_enabled` flag that `main()` is the only caller to enable\n- `router\u002Ftypesafe.py` — the one client both judgment backends share: `API_URL`\u002F`MODEL`\u002F\n  `API_KEY_ENV`\u002F`TIMEOUT_S`, `is_configured()`, `post(state, questions)`, the strict `noul()`\n  reader, and the `JUDGMENT_ERRORS` tuple that defines \"unavailable\"; knows nothing about either\n  question set, and is where a new backend gets its transport instead of copying one\n- `router\u002Frisk_judgment.py` — the second `classify_risk` backend: `QUESTIONS` (one blast-radius\n  score plus the four red-line nouls), `is_configured()`, `ask()`'s single request,\n  `parse_answers()`'s strict shape check, the pure `compose_tier()` mapping onto\n  `classify.RISK_ORDER`, and `judge_risk()`'s `None`-on-any-failure contract (its `asker`\n  parameter is the injection seam tests use instead of a network fake); the tier policy lives in\n  `compose_tier()`, never in the service's answer\n- `router\u002Frelatedness_judgment.py` — the second `cluster_detect` focus backend: the two-Noul\n  `QUESTIONS` (`same_work`, `should_cluster`), the pure `should_edge()` union rule at\n  `JUDGMENT_THRESHOLD`, `judge_pair()`'s `None`-on-any-failure contract (same injectable `asker`\n  seam), and `judge_pairs()`'s order-preserving concurrent batch (`MAX_CONCURRENCY`); the edge\n  rule lives in `should_edge()`, never in the service's answer\n- `router\u002Fpolicy.py` — `load_policy()`; the single source of truth for a repo's resolved GO policy;\n  also `parse_policy_yaml`\u002F`_parse_scalar` (the flat parser and its inline-flow-sequence handling),\n  `POLICY_KEY_TYPES`\u002F`_SWEEP_SKIP`\u002F`_TYPE_SWEEP_EXEMPT`\u002F`_sweep_key_types()` (the coarse type sweep\n  that runs ahead of the per-key checks; covered by `tests\u002Frouter\u002Ftest_policy_key_types.py`) and\n  `automerge_eligible()` (including the `target_branches` scalar coercion)\n- `router\u002Fenv_profile.py` — `resolve_env_profile()`: expands `from`, requires an absolute path\n  (refused rather than resolved relative to the routing file, because `explicit_cell_override`\n  points `WORKTRAIL_ROUTING_FILE` at a mkstemp file under \u002Ftmp), JSON-parses the file, requires\n  a mapping `env` object, asserts every `expect` entry, then copies every `keys` entry; refuses\n  a missing\u002Fempty\u002Fnon-string key. Every failure raises `OperatorConfigError` naming target,\n  profile, file and key, and **no message ever contains a value for a key not named in\n  `expect`** (the operator declared that key non-secret by asserting on it, and only that key).\n  Deliberately not in `spawnlib`\u002F`routing_cli`\u002F`policy`: `routing_cli` imports\n  `..orchestrator.agent_capacity` and `spawnlib` imports `..router.routing_cli`, so a\n  module-level `routing_cli → spawnlib` edge would be an import cycle, and `policy.py`'s\n  validator must never open a profile file — reads belong at spawn and `--check` time.\n- `router\u002Frun_record.py` — `finish()`'s ten-state enforcement and its two code-enforced gates;\n  `cmd_scope_review` write-time reason validation and `OUT_OF_SCOPE_REASON_PREFIXES`;\n  `cmd_capacity_gate`'s `_iso_retry_after` timestamp validation; `cmd_set_list`'s list write\n  (and its `status` refusal) plus `_scalar_list_field_hint()`, the refusal all three\n  list-appenders raise through; `_load_lenient()`, the\n  skip-and-warn wrapper around the raising `_load()` that every directory-wide scan (including\n  `reconcile_pr_labels.load_run_index()`, `check_deferred_work_handoff.py`, and\n  `check_durable_artifact_capture_gate.py`) should use instead of the raising loader\n- `router\u002Fpre_pr_gate.py` — `scope_review_failures()`, the latest-entry-per-item scope gate\n  that `finish` calls\n- `router\u002Fpr_labels.py` — the one place that issues the `go:risk-*` REST label correction; both\n  `drain.py` and sdd-workflow's Phase 8 call into it rather than reimplementing it\n- `router\u002Freconcile_pr_labels.py` — `load_run_index()`, the scheduled sweep that maps every PR URL\n  under a runs dir to its `{risk_level, gates, route}`, tolerant of one malformed record via\n  `run_record._load_lenient`\n- `router\u002Fcheck_deferred_work_handoff.py` — the Stop-hook deferred-work handoff guard;\n  `load_deferred_work_entries()` reads `deferred_work` entries via `_load_lenient` and now prints\n  its discarded warning to stderr instead of silently skipping a malformed record\n- `router\u002Fcheck_durable_artifact_capture_gate.py` — the Stop-hook durable-artifact capture gate;\n  `find_planned_run_records()` reads run records via `_load_lenient` and now prints its discarded\n  warning to stderr instead of silently skipping a malformed record\n- `router\u002Fdashboard.py` — pure file inspection (no git, network, or agents); spec lifecycle stage\n  and next-action detection; also the source of `_resolve_repo_dir()`, which `skill_dispatch.py`'s\n  single-brief-triage path uses to resolve a bare `repo:` value to an on-disk checkout, of\n  `smoke_flake_aggregate()`, which builds the always-present `smoke_flakes` payload key, and of\n  the `compute_clusters` call site that injects `relatedness_judgment.judge_pairs` (only when\n  configured) and `cluster_telemetry.log_judged_pairs`\n- `router\u002Fsmoke_flake_selfcheck.py` — `check_repo()`, the per-repo smoke-flake detector that reads\n  recorded flakes out of a repo's run journals (recency-windowed) and that\n  `dashboard.smoke_flake_aggregate()` calls once per in-scope repo\n- `router\u002Fland_pr.py` — `land_pr()`, `LandRequest`\u002F`LandOutcome`; the shared\n  commit\u002Fcompile-marker\u002Fpreflight\u002Fpush\u002FPR\u002FCI-watch\u002Fmerge-guard\u002Freview-thread-gate\u002Ffinish pipeline\n  every PR-opening call site should compose with instead of reimplementing a subset; `_push()`'s\n  explicit-refspec + `detail_out` contract lives here, as does `_gh()`'s `base_slug` (`-R \u003Cslug>`)\n  scoping of every post-PR-open call, and `_refusal_line()`'s stderr `REFUSED at \u003Cstep>: \u003Cdetail>`\n  line for the operator (stdout's JSON payload is unchanged)\n- `router\u002Fautomerge_preflight.py` — `required_checks_gate()`, `owner_repo_from_git()`,\n  `push_remote_name()`, `is_preflight_query_error()`; the live GitHub-side half of the automerge\n  gate and the single resolution point for the *read* side's target remote, so the gate can never\n  inspect a different repository than `land_pr` pushes the branch and opens the PR against\n- `router\u002Fclose_stale_openspec.py` — `flip_and_archive()` plus `main()`'s `land_pr` landing and\n  outcome→exit-code mapping for the `worktrail-close-stale-openspec` console script\n- `router\u002Fcluster_detect.py` — the brief-clustering signals (`_signal_matches`, `_llm_gate_score`)\n  that `workqueue\u002Fcreate_handoff.py` consumes; `_focus_overlap()` is the guarded focus comparison\n  carrying `MIN_FOCUS_TOKENS`, while `_overlap_coefficient()` stays the raw coefficient every\n  non-focus caller keeps reading; `_judgment_candidates()`\u002F`_apply_relatedness_judgment()` own\n  *which* pairs are worth judging and *what a verdict does to an edge* (`JUDGED_MATCH`,\n  `JUDGMENT_PREFILTER_FLOOR`, `MAX_JUDGED_PAIRS`) while the client and the telemetry writer stay\n  injected\n- `router\u002Fcluster_telemetry.py` — the one append-only cluster log; `log_shown`, `log_outcome`, and\n  `log_judged_pairs()`'s `judged` record kind (members, overlap, both Noul values, verdict), all\n  best-effort writers that never affect what they record\n\n---\n**Last Updated:** 2026-10-05\n",{"name":5,"triggers":24,"description":7},{"files":25,"keywords":27},[26],"src\u002Fworktrail\u002Frouter\u002F**",[28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105],"policy.py","go-policy.yaml","worktrail-go-policy.yaml","run_record","dashboard","automerge_eligible","risk label","classify","RISK_SIGNALS","scope_review","parse_invocation","noun-verb grammar","triage_keep_limit","triage_max_queue_age_days","max_parallel_workers","compile_max_critical_path_over_width","compile_max_same_file_chain","review_skip_max_diff_lines","pre_commit_cmd","land_pr","LandRequest","LandOutcome","close_stale_openspec","flip_and_archive","capacity-gate","retry_after","smoke_flakes","smoke_flake_aggregate","smoke_flake_selfcheck","reconcile_pr_labels","load_run_index","base_slug","automerge_preflight","required_checks_gate","owner_repo_from_git","push_remote_name","remote.pushDefault","cluster_detect","focus-overlap","MIN_FOCUS_TOKENS","OVERLAP_THRESHOLD","risk_judgment","judge_risk","compose_tier","parse_answers","blast_radius","red line","TYPESAFE_API_KEY","risk_judgment_enabled","typesafe","JUDGMENT_ERRORS","relatedness_judgment","judge_pair","judge_pairs","should_edge","same_work","should_cluster","focus-judgment","JUDGED_MATCH","JUDGMENT_THRESHOLD","JUDGMENT_PREFILTER_FLOOR","MAX_JUDGED_PAIRS","cluster_telemetry","log_judged_pairs","target_branches","inline flow sequence","parse_policy_yaml","POLICY_KEY_TYPES","_sweep_key_types","_SWEEP_SKIP","_TYPE_SWEEP_EXEMPT","env_profiles","auth.profile","resolve_env_profile","env_profile.py","resolve_routing","_CONSUMER_MENTION_J_LABELS","_CONSUMER_BY_PHRASE_RE","main","db448e94704b506e1a5a0665d349fc422611fe9e",".claude\u002Fskills\u002Frouter","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail","https:\u002F\u002Fgithub.com\u002Fbehindthedash","2026-11-14 18:34:42",{"source":8,"skillName":5,"commands":113,"prompt":123,"zipAvailable":124},[114,117,120],{"tool":115,"command":116},"npx","npx skills add behindthedash\u002Fworktrail --skill router",{"tool":118,"command":119},"bunx","bunx skills add behindthedash\u002Fworktrail --skill router",{"tool":121,"command":122},"pnpm","pnpm dlx skills add behindthedash\u002Fworktrail --skill router","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frouter\u002Fskill.md",true,[],[127,134,141,148,155,162],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":19},"01M79PMY53NKDHVZ2AFSGNNJH7","worktrail-sdd-workflow","Internal SDD workflow executor invoked by \u002Fgo only. Do not call directly. Executes classified routes A–J: feature planning, implementation (parallel orchestration, PR generation), defect repair, refactoring, spec changes, investigation, and workflow evolution.","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-sdd-workflow\u002FSKILL.md",[],[],{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":19},"01M79PMKBE8SYW0ZP14AEJDM5D","worktrail-routing-config","Configure Worktrail's agent routing table (`~\u002F.worktrail\u002Frouting.yaml`, or a repo-local `routing:` policy block) — which harness\u002Fmodel executes each role and tier, and how fallback between them works. Use when the operator wants to add or remove a harness\u002Fadapter (claude\u002Fcodex\u002Fopencode), add a model to an existing harness (e.g. adding a DeepSeek model to opencode), pin or change who does code review, add a new tier or purpose mapping, change the default tier, or is confused about which harness actually served a spawn (e.g. \"why did this use Codex when I only configured Claude\"). Trigger phrases: \"routing.yaml\", \"add a harness\", \"disable a harness\", \"add an adapter\", \"remove an adapter\", \"add a model\", \"add deepseek to opencode\", \"change the reviewer\", \"pin the reviewer\", \"routing tiers\", \"routing targets\", \"default_tier\", \"independent reviewer\", \"why did codex get called\". This skill is about *editing the config file*; it does not cover `\u002Fgo`'s own dispatch mechanics (see `worktrail-go`'s SKILL.md Phase 7 for how `tier_for()`\u002F`select_cell()` resolve it at runtime).","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-routing-config\u002FSKILL.md",[],[],{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":19},"01M79PMB24YTZTZVVAKA4A4R38","worktrail-repo-init","Bootstrap a new repo, or migrate an existing single-branch repo, onto the workspace's repo-standards doctrine (~\u002Frules\u002FCLAUDE.repo.md): the AGENTS.md-is-truth\u002FCLAUDE.md-imports-it split, a dev\u002Fprd, dev\u002Fstg\u002Fprd, or main-only (trunk) branch model with matching GitHub rulesets, an OpenSpec scaffold, an auto-merge workflow, and a seeded .worktrail\u002Fpolicy.yaml. Trigger phrases: \"onboard this repo\", \"apply repo standards\", \"initialize repo standards\", \"set up this repo like the rest of the fleet\", \"bring this repo into line with the repo standards doctrine\".","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-repo-init\u002FSKILL.md",[],[],{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":19},"01M79PM54RFP51Q2JPQGE13ZP8","worktrail-help","Show the Worktrail front-door commands and accepted positional arguments. Use when the user asks how to invoke worktrail-go, wants the available handoff, spec, pr, repo, or route forms, invokes worktrail-go with help or with a bare noun, or asks how to answer a filed product decision (worktrail-decision).","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-help\u002FSKILL.md",[],[],{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":19},"01M79PKVZVBF4VFT5XEPCPNM9S","worktrail-handoff","Capture a discovered problem, gap, tech debt, or deferred work into a local work queue so a future agent session can pick it up cold. Use mid-session whenever you set work aside instead of doing it now — a fix you judge out of scope for this PR, work that belongs in a follow-up or a separate\u002Flater PR, an item you're deferring, or something worth fixing you won't tackle now — so the outstanding item isn't lost without derailing current work; can be called multiple times per session. Trigger phrases: \"defer this\", \"item deferred\", \"out of scope for this PR\", \"follow-up work\", \"leave for another PR\", \"capture for later\", \"outstanding item\". This skill captures only. Picking a brief back up is the front door's job: worktrail-go \u003Cbrief-id>.","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-handoff\u002FSKILL.md",[],[],{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":19},"01M79PKJZD9MPN7Q8GWR01KX0J","worktrail-go","Use when the user invokes worktrail-go, asks to pick up queued work, resume active specs, implement or fix a spec, route engineering work, or orient across repositories. Renders the orientation dashboard, classifies free-text requests, claims\u002Fresumes handoff briefs, and dispatches SDD work without requiring the user to know sdd-workflow. Grammar: worktrail-go [REPO] \u003Cnoun> \u003Cverb>, nouns handoff \u002F spec \u002F pr \u002F decision. Triggers: worktrail-go, worktrail-go help, worktrail-go spec fix, worktrail-go spec implement, worktrail-go spec route F, worktrail-go handoff new, worktrail-go handoff auto, worktrail-go decision answer, worktrail-go BRIEF-ID, bare worktrail-go, multi-repo orientation.","https:\u002F\u002Fgithub.com\u002Fbehindthedash\u002Fworktrail\u002Fblob\u002Fmain\u002Fskills\u002Fworktrail-go\u002FSKILL.md",[],[]]