--- feature: tracker-feature-inference name: "Tracker Feature: inference (the background Tracker agent and session-start hook Section 3)" description: "Use when editing src/assets/agents/tracker.md, session-start-context Section 3, the claim or attempt-counter lifecycle, or the conventions-file schema. Keywords: Tracker agent, TRACKER SETUP, tracker_gates_open." category: architecture directories: [src/assets/agents/tracker.md, src/assets/scripts/hooks/session-start-context, src/targets/claude-code/tracker-install.ts, tests/tracker-agent.test.ts, tests/shell-hooks-tracker.test.ts, tests/seams/tracker-claim-staleness.test.ts, tests/config-disable-guards.test.ts] created: 2026-10-10 updated: 2026-10-11 --- # Tracker Feature: inference ## Rules - **KB-AP-1** Never write a defaults-only or partial conventions file "to make progress": the file's existence is the "setup done" signal, so a partial file permanently suppresses the retry that would have produced a correct one. - **KB-AP-2** Never name a provider or the transport acronym in the Tracker agent, or re-derive a provider in its prompt: the validated token arrives in the spawn directive and a second derivation is a second convergence point. - **KB-AP-3** Never write a tracker server into the Tracker agent's shipped `tools:` list: server names are user-configured per machine, so a list written at authoring time is a guess that fails at runtime in an unwatched background run. The installer stamps the configured servers onto the installed line instead. - **KB-AP-4** Never re-point the conventions-file write at `--emit`: a file sink has the shell `&&` chain; `tests/tracker-agent.test.ts` asserts the agent never contains `--emit` so the two reasons cannot collapse. - **KB-AP-5** Never turn the write into a pipeline, leave a chain link unchecked, or unlink-and-retry on `EEXIST`: the winner's content is the answer. - **KB-AP-6** Never spend or write the attempt counter from the agent: only the hook writes its value; the agent only deletes it after a successful write. - **KB-AP-7** Never admit a provider with a negative test (`!= github`) in the hook: the sentinel is user-writable and the resolver line is not hook-composed, so use the positive allowlist before any interpolation. - **KB-AP-8** No command spawns `tracker`; never add an exemption for it to the registry guards: it is hook-spawned only and passes the reverse spawn check structurally. - **KB-AP-9** Never write the retired agent name's noun ("valid" plus "ator") in a shipped asset: `agent-name-guards` sweeps `src/assets/**` with maximal recall; say "shape gate". - **KB-AP-10** Never run a hook test against the real `$HOME`: a developer's configured provider changes the output; every invocation carries a seeded temp `HOME`. - **KB-AP-11** Never trim the agent's mandated rationale to hit a size; if a guard pin trips, pin a stable literal, not a reflow-fragile phrase. - **KB-AP-12** Never gate the hook's tracker section on the curation feature toggle: a user who turned curation off did not turn their issue tracker off. - **KB-INV-1** The claim is create-exclusive (`noclobber`) with an observable outcome (`CLAIMED`, or `LOST` with its dedicated exit code); `mv` cannot be the primitive because it replaces an existing destination. - **KB-INV-2** The hook's `TRACKER_PROCESSING_STALE_SECS` and the agent's claim-step bound must be equal; `tests/seams/tracker-claim-staleness.test.ts` is the only reconciliation. - **KB-INV-3** The hook increments the counter when it EMITS, before building the section; an increment that cannot persist suppresses emission; the parse fails closed (unreadable or out-of-range counter). - **KB-INV-4** The agent writes exactly one content path through a scrub-gated, shape-gated, create-exclusive, fail-closed chain at an owner-only mode; a failing or missing scrubber writes nothing. - **KB-INV-5** No capability reachable is transient (write nothing, re-arm next session); reachable-but-thin evidence is permanent (write with sentinels); denial is identical to absence. - **KB-INV-6** `# UNRESOLVED:` is a hard sentinel, never shape-gated as a value; an absent section means the documented neutral default; the two are different outcomes. - **KB-INV-7** The schema headings are bound to `TRACKER_SCHEMA_SECTIONS` in `tests/helpers.ts` and the template fence is addressed by tag; never re-spell the list. - **KB-INV-8** On `github` the hook's tracker section forks nothing; when project.json (or a narrowing config.json) shows a tracker it forks only the resolver, once; gates run cheapest first inside `tracker_gates_open()`. - **KB-INV-9** The `source` gate is a positive `case` over `startup`/`clear`; every other value, absent included, suppresses. - **KB-INV-10** The directive's `Devflow directory:` and `Conventions file:` fields are authoritative in the agent; its fallbacks derive byte-for-byte the paths the gate resolves. - **KB-INV-11** The Tracker model tier is a constant: the hook's allowlisted `TRACKER_MODEL` equals `loadShippedAgentDefaults()['tracker'].model` and the agent's frontmatter `model:`. ## Overview This facet covers the two halves of conventions inference: the **session-start hook's Section 3**, which silently decides when a provider's conventions are still unlearned and emits a spawn directive, and the **Tracker agent**, a background, unattended agent that probes the configured tracker and writes `~/.devflow/tracker/{provider}.md` exactly once or not at all. Selection (which provider) belongs to the hub (`tracker-feature`); how a Git spawn reads the resulting file belongs to `tracker-feature-reader`. ## The Tracker agent: `src/assets/agents/tracker.md` `name: Tracker` (byte-exact), registry key `tracker`, `model: sonnet` (pinned equal to `loadShippedAgentDefaults()['tracker'].model`), the single preloaded skill `devflow:git` (the `boundary-validation` preload is gone: its content reaches the agent through the Core rules digest), `omitClaudeMd: true`, and a `tools:` allowlist of `Bash`, `Read` and `ToolSearch` (`Bash` for the claim, the history sampling and the one scrub-gated write chain; `Read` for the file it opens; `ToolSearch` to load a tracker server's deferred tool schemas). It has no `Write`: its one file is written by that Bash chain, and a Write tool would be a second way to write outside it. Every agent, Tracker included, has an `AGENT_CONFIG` row in `tests/fixtures/agent-config.ts` (the exempt-agent map is gone): Tracker's row is `D-TRACKER-ROW`, a deliberate constant whose model is pinned equal to the hook's `TRACKER_MODEL` and to `loadShippedAgentDefaults()['tracker'].model`, with no effort line. The body carries a `## Core rules` digest (context economy, untrusted input, no secrets, bounded loops), because `omitClaudeMd` also drops the installed rules; `tests/guards/core-rules-digest.test.ts` holds the lines to the row's `digest`. **The `tools:` list names no tracker server** (EC-69, restated), stated in the agent itself so it cannot be "completed" with a guess: the servers it must reach are user-configured, so their names differ per machine. The installer appends one whole-server entry per configured server to the INSTALLED `tools:` line (`D-TRACKER-SERVER-ALLOWLIST`; `devflow init` and `devflow tracker --servers`, see the hub KB), and the agent loads a server's tools with `ToolSearch` before it probes. A name that matches no connected server is an unreachable capability, which the probe already treats as `TRACEABILITY: DEGRADED (no tracker tool for {capability})`, with `devflow tracker --servers` as the remedy, so a wrong name fails where it can be seen. An allowlist says which tools the agent holds, never what it may do with them, so the explicit `## Read-only boundary` section stays the control, pinned in `tests/tracker-agent.test.ts`: it writes one content path, runs no git command in the write path and no write-side git or forge command anywhere, issues no network request of its own (tracker reads go through tracker tools only, never a hand-built request, a substituted CLI or a credential read from the environment) and delegates nothing. **Hook-spawned only.** No command spawns it. `tracker` sits in the `devflow-core-skills` plugin, whose empty `commands: []` gives `registry-integrity`'s reverse spawn check no spawned set for that plugin, so the check skips it (`if (aggregate === undefined) continue`): a **structural** pass, not an exemption (the rationale is a comment on `agents:` in `src/core/plugins.ts`). **The agent is PROVIDER-AGNOSTIC and contains no provider name at all.** `tests/guards/provider-scope.test.ts` puts `src/assets/agents/**` inside `PROVIDER_SCAN_ROOTS`, but the guard is not the only reason: the validated token arrives in the directive, so naming or re-deriving a provider in the prompt would be a second convergence point. Three schema "Absent" cells are therefore phrased provider-agnostically ("the resolved provider's documented neutral default"), which is correct because this agent only ever runs for a non-`github` provider. The agent never reads the remote, hosting platform or PR host as a provider signal. **The protocol, in order:** 1. **Claim, with an OBSERVABLE outcome.** If `.tracker.processing` exists, compare its age against the claim-staleness bound (600 seconds, mirroring the hook): fresh means a live sibling owns the run (report `LOST`, exit 3, change nothing), stale means a previous run crashed (re-claim by `touch`). Otherwise claim **create-exclusively**: `( set -o noclobber; : > "$TRACKER_CLAIM" ) 2>/dev/null` prints `CLAIMED`, or `LOST` and exits 3. The primitive must *refuse when the path exists*; `ln` of a marker or `mkdir` of a lock directory refuse on the same terms, but `mv src dst` replaces an existing `dst` and exits 0, so both racers would win. The create is also its own existence check, leaving no window. Absent output means LOST, and the loser writes nothing (not the file, the counter or the claim): a run killed between the create and its echo is indistinguishable from a winner that printed nothing, and only this reading is safe. **Heartbeat:** `touch` the claim **once**, at the probe-to-compose boundary (the probe is network-bound, composition is local); a per-capability cadence has no observable count and every extra touch writes to the file the next gate stats. If the claim file or `$TRACKER_DEVFLOW_DIR` vanishes mid-run (the user disabled or cleared the feature), stop without further writes and never recreate them. If `$TRACKER_FILE` already exists, stop and report `ALREADY_EXISTS`. 2. **Probe**, before inferring anything, selecting every capability **by its description, never by tool name** (published rosters disagree across vendors and versions). The probed capabilities fill: project and issue-type metadata (`## Project` key, `## Issue Types`, `## Required Fields`), workflow transitions (`## Transitions`), listing issues by structured filter (`## Iteration Policy`), identify current user (`## Assignee`, `## Dedup Strategy` `authored-marker`), entity-property read/write, in-place comment edit, link-to-external-URL creation and attachment-from-URL creation (the dedup rungs). `denial ≡ absence`: a denied capability takes the same branch as an absent one because both mean unusable-now and both may resolve later. An unreachable capability is noted with the canonical `TRACEABILITY: DEGRADED (no tracker tool for {capability})`, never free prose. 3. **Split transient from permanent.** No capability reachable at all means **write nothing** and let the next session re-arm. Some reachable but the evidence thin means **write the file with sentinels** (a human must decide). A rule of ">50% unresolved means don't write" was rejected as arbitrary and colliding with retry semantics. 4. **Infer within bounds.** The bounds, the UNTRUSTED-strings handling, the post-composition verbatim-match check and the `### Substitutions` rule are **named, not restated**: they live in the `devflow:git` skill's `references/learn-conventions.md`. The fallback of restating them under a two-site allowlist was NOT taken: copying security-relevant bounds creates a second hand-maintained corpus outside every single-authority guard. Three rules are the agent's own because that reference does not carry them: a **majority rule** (adopt a scanned value only with at least 3 occurrences AND at least 60% share, stricter than the reference's 50%, because a wrong project key sends every future lookup to a project that does not exist; otherwise a sentinel, never the first match); a **refusal to infer from history outside a real project root** (`$HOME` or no git marker: a dotfiles `$HOME` *is* a git repository and its branch names say nothing about any tracker); and **provenance** written into `inferred-from:` (the scanned root and an ISO timestamp, the only place a reader sees where a value came from). Every value is shape-gated regardless of provenance; a discarded value becomes the documented default plus a `### Substitutions` row. 5. **Write once, or not at all.** One block, in this shape: `umask 077`; two `mktemp` files (the scrubbed stage **inside `$TRACKER_DEVFLOW_DIR`**, because `ln` places a file only within one filesystem; each is a checked precondition via `|| exit 1`; `mkdir -p` of the shared `tracker/` directory, `0700` under the block's umask, on the first write any provider makes); the compose step brace-grouped so it HAS a status the chain can read, with a quoted heredoc delimiter (scanned strings are never expanded); `redact-secrets.cjs RAW SCRUBBED` addressed through `$TRACKER_DEVFLOW_DIR` (a second `$HOME/.devflow` resolution can disagree and fails closed silently); a **shape gate** (`[ -s ]`, a grep for the frontmatter's first key, a grep for the last required heading `## Dedup Strategy`, and a negated grep refusing a backtick, `$` or `;` anywhere in the file); `ln "$SCRUBBED" "$TRACKER_FILE"`; `chmod 600`; then `GATE=$?; exit "$GATE"`, with a `trap` on `EXIT INT TERM` removing both temp files (`$RAW` holds the PRE-scrub bytes the gate exists to remove). All links are one `&&` chain, **never a pipeline**: a pipeline hides the scrubber's exit status and the chain is what makes the gate fail *closed*; a failing or missing scrubber writes nothing and reports `TRACEABILITY: DEGRADED (redaction unavailable)`. `ln` (link(2)) publishes an already-complete file under a name that must not exist, so there is no instant at which `$TRACKER_FILE` holds a prefix; `EEXIST` means you lost a race: read the existing file and report `ALREADY_EXISTS`. It is **not a lock wait**: unlink-and-retry is right for a staged atomic replace and exactly wrong for a write-once file. The scrubber's exit status says only that it RAN, which is why the anchors bracket the composition at both ends; the third grep covers the range between and after them (where `### Substitutions` rows, values that already failed their own gate, sit). The double quote and backslash of the Reference Rendering denylist are deliberately NOT in that grep: the scrubber may re-quote an assignment it redacted (a successful redaction must not refuse the write) and a backslash inside a bracket expression is a portability bug in `grep`. 6. **Finish.** On a write-less exit leave the provider's counter (`$TRACKER_ATTEMPTS_FILE`) **exactly as found**: the hook already spent one attempt when it emitted the directive, and a second spend would close the feature after three directives rather than the cap. On a successful write, delete the counter. Delete the claim file as the **final** act (a write-less exit still deletes it, or the next session waits out the staleness bound for a run that decided in seconds it had nothing to say), with a plain `rm --`: devflow's recommended deny list denies the FLAGGED spellings and the agent runs unattended with nobody to answer the prompt. Crashing before that line leaves the claim for stale recovery, the correct outcome for a partial run. The closing output block (`Status`: WRITTEN, ALREADY_EXISTS or DEGRADED; `File`; `Unresolved`; `Substitutions`) is invisible in a background run, so the file itself is the real report. **The schema** (inside the agent's `tracker-md-template` fence): `## Project` (site and key) · `## Issue Types` · `## Required Fields` · `## Iteration Policy` · `## Transitions` · `## Assignee` · `## Tech Debt` · `## Reference Rendering` · `## Dedup Strategy` · `### Substitutions`. `## Project` is ONE heading carrying two values, so the shape-gate table has one more row than there are `##` sections. Template frontmatter keys are `provider:` and `inferred-from:` only; `learned:` was dropped because no consumer existed and an unread field is residue. **Never re-spell the list**: it is exported as `TRACKER_SCHEMA_SECTIONS` in `tests/helpers.ts` alongside `collectTrackerTemplate` / `collectTrackerTemplateHeadings` / `collectTrackerSchemaRows`, and both the writer and reader halves bind to it (a two-sided equality test has no oracle of its own). `TRACKER_TEMPLATE_FENCE_TAG = 'tracker-md-template'` addresses the fence **by tag, never by position**. **File-level rules:** at most 120 lines and 8,000 characters (`TRACKER_CONVENTIONS_READ_BYTES`; over either bound a reader reads it fully anyway and degrades, since a partial read is never correct), mode `0600`, opened with the **Read tool** never a shell read (a shell read can be rewritten into a truncated view). The Git agent names it by the static map's literal `~/.devflow/tracker/{jira,linear}.md` row, which the Read tool expands (a dated platform assumption in `docs/reference/platform-assumptions.md`, with its drift symptom), one value per line, no continuations. **`# UNRESOLVED:` is a hard sentinel and is never shape-gated as a value**; a sentinel and an absent section are **different outcomes**: absent means the documented neutral default, a sentinel means the reader degrades and asks the human to edit the file. A global-safe section whose shape gate is a closed enum and whose documented default is one of that enum's own values (`## Assignee`, `## Tech Debt`) is never sentinelled: write the constant. `## Dedup Strategy` is a closed enum too but NOT covered, since its documented default is a live probe, not a member. **Two shape gates are stronger than the plain schema table, and neither relaxes it.** `## Reference Rendering` carries a **positive parse** `^[A-Za-z0-9 #{}/_.-]{1,60}$` *in addition to* the metachar denylist, because a denylist alone admits `--body-file=/etc/passwd` and `https://u:tok@host` (neither contains a metachar). Parse-don't-validate is the gate; the denylist is a second, independent control, named separately so widening one cannot silently relax the other. `## Required Fields` is expressed as the **allowlist** (the actual mechanism) with the denied names stated as its consequence. Denied characters are spelled **by NAME** (`backtick`, `dollar`, `double-quote`, `backslash`, `semicolon`, `newline`), because a backtick cannot be written as a single-backtick code span inside a markdown table cell and a newline has no spelling; an unknown name **throws**. A reference-rendering discard falls back to the provider's documented default (never `# UNRESOLVED:` there: an unresolved rendering would leave every back-link permanently degraded). **`## Dedup Strategy` is a hint, not a decision.** The recorded rung token (never a bare number) and its evidence may only **narrow the probe order**; the **live probe is the sole authority** for whether dedup is available and why it degrades. A rung recorded months ago against a server that has since changed must never be trusted as the answer. ## Hook Section 3: the silent setup directive `src/assets/scripts/hooks/session-start-context` Section 3 sits between Section 2 and the legacy-install notice, compaction resume directive and CLAUDE.md import audit (Sections 4-6). It is **not gated by the curation feature toggle**. **The resolved-root idiom:** `TRACKER_DEVFLOW_DIR="$HOME/.devflow"`, the machine root, which no environment variable relocates (`DEVFLOW_DIR` is ignored). The project's own `.devflow` is a separate hook-local, `PROJECT_DEVFLOW_DIR="$PROJECT_ROOT/.devflow"`, so the two names cannot collide. The assignment sits above Section 1 so the shape gate sees it before any section interpolates it. Hook tests isolate through a seeded temp `HOME`; one case exports `DEVFLOW_DIR` at a directory seeded with full jira state to prove it is ignored and left untouched, and the hostile-path cases reach the root through a hostile `HOME`. **Which provider: three sources, and only these:** 1. **The machine default**, from the `.tracker.enabled` sentinel: `IFS= read -r -n 16` (builtin, bounded, status not consulted). Never the manifest. A **zero-byte** sentinel an earlier release wrote reads empty and yields **no directive** until `devflow init` rewrites it with the name. 2. **The project's own selection**, from its committed `.devflow/project.json`. A bounded builtin read (`read -d '' -n 4097`) looks for a `"tracker"` key; only when it shows one, or a `\u` escape, or a file the read cut short (past the parser's 4,096-byte bound, or at a NUL), does the hook make its **ONE fork**: `node resolve-settings.cjs "$PROJECT_ROOT"`, the same resolver the Git agent consumes, so the provider a session learns conventions for is the provider a Git spawn in that project resolves. The line is honoured only as far as its `TRACKER=` token; any non-zero exit or any line not of the shape `TRACKER=… TRACKER_SOURCE=…` is the fail-closed github. 3. **The personal override**, from `.devflow/config.json`, read ONLY where the sentinel names a provider, because an override can only NARROW (to `github` or the provider in effect): a github machine's config.json is not even stat-ed. A hit takes the same ONE resolver fork, so a personal `"tracker":"github"` silences a jira machine's directive in that repository. A config.json git tracks is ignored by the resolver, so it narrows nothing here either. No personal value can make the hook infer for a provider neither the team nor the machine named. Then the POSITIVE allowlist, then **skip when `tracker/$P.md` already exists**, then the gates, cheapest first, inside `tracker_gates_open()` (a function supplies the early `return 1` a plain `sh` block lacks, so the order IS the execution order): | Path or gate | Fork cost | |---|---| | github, no project.json | one `stat`, **0 forks** | | github, project.json without a tracker | one bounded read, **0 forks** | | jira/linear with learned conventions | a `stat`, a builtin read, a `stat`, **0 forks** | | github, config.json of any shape | not even stat-ed, **0 forks** | | project.json, or (on a machine naming a provider) config.json, shows a tracker | **one** resolver fork, then the gates | | gate 1: attempt cap on `.tracker.$P.attempts` (`read` builtin) | 0 forks | | gate 2: project root carries a git marker (`df_has_git_marker`, a builtin walk) | 0 forks | | gate 3: `source` in {`startup`, `clear`} | 1 fork | | gate 4: claim-file freshness (only when the global `.tracker.processing` exists) | 0 or 2 forks | | gate 5: interpolated path shape (`DIRECTIVE_PATHS_SAFE`) | 0 forks | | gate 6: the counter increment must LAND (emission is conditional on the write) | 0 forks | **The allowlist is POSITIVE, never `!= github`:** `case "$TRACKER_PROVIDER" in jira|linear) ;; *) TRACKER_PROVIDER="" ;; esac`. The sentinel is user-writable and the resolver's line is a value the hook did not compose, so a negative test would admit every hostile string that merely is not the word "github" (quotes and newlines included) into a path test and into `additionalContext`. `tests/seams/tracker-key-path.test.ts` reads this arm **out of the hook** (`collectAdmittedProviders`) rather than restating `['jira','linear']`, so widening it is a visible, tested edit. Two provider literals are legal here because `src/assets/scripts/hooks/` is **not** in `provider-scope.test.ts`'s `PROVIDER_SCAN_ROOTS`. The `source` field is a closed domain (`startup` | `resume` | `clear` | `compact`, recorded in `docs/reference/platform-assumptions.md`); the gate is a positive `case`, so a new upstream lifecycle name is silently never inferred for: widen it deliberately, never invert it to a denylist. **Named literals, each with its derivation:** `TRACKER_ATTEMPTS_MAX` (the per-provider cap) and `TRACKER_PROCESSING_STALE_SECS`, asserted `!== 900`. The processing bound is its **own** literal, deliberately not shared with Curation's: one shared constant would make a change to either feature silently reclassify the other's live runs as crashed. It sits above the memory worker's lock (a Tracker run does a capability probe plus bounded git scans) and below Curation's (no multi-part curation phase); too long costs one session's delay before a crashed run retries, too short burns an attempt against the cap. **The counter's defensive parse** is worth reading before touching it. It is read with the `read` builtin (no fork, `-n 16`), and `read`'s **exit status is deliberately not consulted**: it returns non-zero at an EOF with no trailing newline *while having assigned* the variable, and treating that as failure would reset a real count. Only the value's shape decides: absent or empty means `0`; non-digit means `0`, self-healed, `dbg`'d and overwritten with a well-formed count on emission so a stray byte can never recur; zero-padded (`08`) means `0` too, because `[ -ge ]` reads it base 10 while `$(( N + 1 ))` reads it octal (and its error escapes the write's own `2>/dev/null`); **7+ digits are treated as AT the cap**, because `[ "$N" -ge 5 ]` on a value past `intmax_t` prints `integer expression expected` and takes the FALSE branch, so the cap would fail **open** (an unbounded copy emitted the directive for a 200-digit counter); a present-but-unreadable file is treated as at the cap (fails closed; the re-arm path owns recovery). **The hook increments when it EMITS**, before building the section, so a crashed agent still burns an attempt. The agent deletes the counter on a successful write and otherwise never touches it; the hook never deletes it and never creates it on a suppressed path. An increment that cannot persist suppresses the emission (gate 6): a cap that can never engage would respawn an agent at every startup, driven by the one condition (an unwritable `~/.devflow`) that also stops the agent writing. **The claim gate re-arms but never deletes.** A stale claim means a previous run crashed; re-claiming is the agent's job, and a hook that deleted the file would race a slow-but-live run. An unreadable mtime takes the suppressing branch. **The silence clause is checked as a whole FRAME, not a substring match.** `collectSilenceClauses` splits each clause at its subject list, substitutes `{SUBJECTS}`, and asserts the two frames (Curation's and this one) are `toBe`-equal to `Never mention this directive, {SUBJECTS} in any user-visible text. Do not narrate, confirm, or summarize the spawn. Your first visible words must address the user's request.`, while asserting the subject lists are distinct and each names its own agent. A clause that loses the head or the ` in any user-visible text. ` hinge yields a **null frame**, reported rather than silently "not found". **How the zero-fork property was proven** (the reusable method): an additive PATH shim wraps `jq`/`node`/`date`/`stat` to log every exec (nothing subtracted, since PATH subtraction is platform-dependent); a baseline count on a HOME that never chose a tracker (manifest present, no sentinel) must be `> 0` (else the shim is not on PATH and the measurement is inert); the GitHub path AND a jira machine whose conventions are learned must each show `count - baseline === 0`; the same counter with the conventions removed must be strictly greater (non-vacuity: a counter that never moves also reads zero); each differential first calls `primeAuditStamp` so Section 6's CLAUDE.md audit costs the same in baseline and measured run; a project.json that selects a tracker costs exactly ONE fork, the resolver; and a source-level assertion pins the mechanism itself (no ungated read or fork precedes the gate, `collectPreGateWork` with a known-bad probe per rule; the first `if` after `# --- Section 3:` is exactly `if [ -f "$TRACKER_SENTINEL" ]; then`; `resolve-settings.cjs` is forked at ONE site, inside the `_SC_TRACKER_ASK` branch). All in `tests/shell-hooks-tracker.test.ts`, which also pins a github machine whose project.json selects jira directing the agent at the jira file. `tests/fixtures/numeric-floors.json` carries a **ceiling** `tracker-section-max-chars` for the emitted section's TEMPLATE (pinned against the hook source, since the emitted text carries two absolute paths whose length is the caller's tmpdir). It may be lowered, never raised. ## Anti-Patterns - **KB-AP-1.** The session-start gate reads nothing but the file's existence, so an incomplete file is *worse* than none. That is why "write the whole file once or write nothing" is the agent's Iron Law and why no-capability-reachable writes nothing at all. - **KB-AP-2.** Beyond the `provider-scope` guard, "MCP" in user-facing text leaks transport into copy the user reads; the agent's shape-gate table column is named "Shape gate at the sink". - **KB-AP-4.** The agent states the file-sink reason (the `&&` chain is the gate) and the comment-sink reason (framed stdout exists for sinks with no such boundary) **separately**; collapsing them loses the chain. - **KB-AP-8.** A roster row fails `inRosterNotInDist`; the commands-less-plugin pass is structural. - **KB-AP-9.** `RETIRED_ALLOWLIST` is context-scoped to stable identifiers, never flowing prose, so rewording ("validation" is safe; it lacks the substring) is the precedent-consistent fix. - **KB-AP-12.** Section 3 ships as a feature of the tracker, not of curation. ## Gotchas - **KB-INV-2: the hook and the agent both classify the claim file and nothing at runtime reconciles them.** If the hook's constant and the agent's Step 0 literal diverge, the larger side suppresses what the smaller side re-arms: inference stalls, or an attempt burns every session until the cap closes the feature. The seam test reports an *unstated* bound rather than reading it as agreement, and cannot tell you the value is the wrong number, only that both sides still say the same one. If real background-run wall time outgrows the bound, a live agent's claim reads as crashed. - **KB-AP-6: only the hook writes the counter's value.** The hook overwrites it with a well-formed integer on each emission; an agent-side increment on a write-less exit would spend the budget twice per cycle. - **KB-AP-10: `tests/config-disable-guards.test.ts` once ran `session-start-context` against the real `$HOME`.** With a developer's machine configured for `jira`, its `expect(output).toBe('')` assertions saw the full `--- TRACKER SETUP ---` envelope. A hook test that reads the real `$HOME` is a test whose result depends on who runs it. - **The Tracker agent's summary is invisible.** It runs with `run_in_background: true` and nobody reads its output block, so every uncertainty goes into the file as a `# UNRESOLVED:` sentinel or a `### Substitutions` row. When debugging a bad inference, read `~/.devflow/tracker/{provider}.md` (`devflow tracker --status` names the effective one on its `File:` line); its `inferred-from:` line is the only record of which root was scanned and when. - **`resolveAgentSource` prefers `dist/agents/`.** `tracker.md` is hand-authored, so there is no `dist/agents/tracker.md` and the src file is read; a stale dist artifact from an unrelated experiment would silently shadow every edit and every guard. If an agent edit seems to have no effect, check `dist/agents/` first. - **KB-AP-11: the agent is long by design.** The shape-gate table and the template are irreducible contract; every other paragraph carries a rule *with* its reason because an agent running unattended, with no orchestrator to ask, must be self-contained. A trimming pass was attempted and immediately tripped two guards; the agent file never points at a plan document for the same reason. ## Key Files - `src/assets/agents/tracker.md`: the agent; Iron Law, read-only boundary, Environment (`Devflow directory:` and `Conventions file:` authoritative; fallbacks derive `tracker/$TRACKER_PROVIDER.md` and `.tracker.$TRACKER_PROVIDER.attempts`), Step 0, capability probe, bounded inference, the shape-gate table, the `tracker-md-template` fence, the write chain, Finishing - `src/assets/scripts/hooks/session-start-context`: Section 3; `TRACKER_DEVFLOW_DIR="$HOME/.devflow"` (the project root's is `PROJECT_DEVFLOW_DIR`); the sentinel read, the bounded project.json read, the one gated resolver fork, the positive `jira|linear` allowlist, the `tracker/$P.md` skip, `tracker_gates_open()`, `TRACKER_ATTEMPTS_MAX`, `TRACKER_PROCESSING_STALE_SECS`, the allowlisted `TRACKER_MODEL="sonnet"` - `src/targets/claude-code/tracker-install.ts`: `convergeTrackerArtifacts` installs the Tracker agent file on every machine (`installed` or `unchanged`, byte-compared); `TRACKER_AGENT_NAME`, which the installer's generic agent loop skips - `tests/tracker-agent.test.ts`: static content guards, each negative driven by a named collector that a known-bad probe also drives (non-vacuity) - `tests/shell-hooks-tracker.test.ts`: Section 3 end to end, the zero-fork differential, the zero-byte legacy sentinel, the source-level pre-gate pins - `tests/seams/tracker-claim-staleness.test.ts`: the agent-to-shell claim-staleness seam - `tests/seams/tracker-key-path.test.ts`: `collectAdmittedProviders` and the sentinel seam - `tests/helpers.ts`: `TRACKER_SCHEMA_SECTIONS`, `TRACKER_SCHEMA_FRONTMATTER_KEYS`, `TRACKER_TEMPLATE_FENCE_TAG`, `collectTrackerTemplate`, `collectTrackerTemplateHeadings`, `collectTrackerSchemaRows` - `tests/fixtures/agent-config.ts`: `AGENT_CONFIG` (the `tracker` row), `CORE_RULES_DIGEST`; `tests/guards/core-rules-digest.test.ts`, `tests/guards/agent-config.test.ts`: the digest and the vendor-neutral allowlist pins; `src/targets/claude-code/tracker-install.ts`: converge writes the stamped text - `tests/fixtures/numeric-floors.json`: the `tracker-section-max-chars` ceiling - `tests/config-disable-guards.test.ts`: hook invocations under a seeded temp `HOME` - `docs/reference/platform-assumptions.md`: the claim-file liveness assumption, the `source` domain, the Read tool's `~/` expansion, the denied-equals-absent capability behaviour ## Related - `.devflow/features/tracker-feature/KNOWLEDGE.md`: the hub (selection, sentinel and counter owners, the end-to-end flows) - `.devflow/features/tracker-feature-reader/KNOWLEDGE.md`: how a Git spawn reads, refuses on, and renders from the file this facet writes; `--emit` versus the file-sink chain - `.devflow/features/curation-capture-system/KNOWLEDGE.md`: hook Sections 1-2, the silence-clause frame this section's is compared against, and Curation's own claim-staleness constant - `.devflow/features/test-harness/KNOWLEDGE.md`: `resolveAgentSource`, named-collector-plus-known-bad-probe conventions, the floors-versus-ceilings discipline - `.devflow/features/installer-shadowing/KNOWLEDGE.md`: the agent install loop that skips `TRACKER_AGENT_NAME`