Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/odysseus-propagation-freshness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@schlessera/brain": minor
"@schlessera/brain-ui-server": minor
---

Add opted-in diff-assisted propagation acknowledgements, configurable confidence/cross-check policies defaulting to balanced (0.7 with both checks), dry-run inspection and a separate scheduled prepass without changing document dates.
20 changes: 20 additions & 0 deletions api-report/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,23 @@ signatures (every public export and the types it is made of)
hooks: z.ZodOptional<z.ZodObject<{
embedOnCommit: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strict>>;
hygiene: z.ZodOptional<z.ZodObject<{
propagation: z.ZodOptional<z.ZodObject<{
budgetMs: z.ZodOptional<z.ZodNumber>;
crossChecks: z.ZodOptional<z.ZodBoolean>;
enabled: z.ZodOptional<z.ZodBoolean>;
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
maxFiles: z.ZodOptional<z.ZodNumber>;
maxInputChars: z.ZodOptional<z.ZodNumber>;
minConfidence: z.ZodOptional<z.ZodNumber>;
profile: z.ZodOptional<z.ZodEnum<{
balanced: "balanced";
conservative: "conservative";
permissive: "permissive";
}>>;
timeoutMs: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
}, z.core.$strict>>;
instructions: z.ZodOptional<z.ZodObject<{
maxTokens: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
Expand Down Expand Up @@ -1782,6 +1799,7 @@ signatures (every public export and the types it is made of)
}, z.core.$strict>>>;
propagation: z.ZodOptional<z.ZodArray<z.ZodObject<{
derivatives: z.ZodString;
scope: z.ZodOptional<z.ZodString>;
severity: z.ZodOptional<z.ZodEnum<{
error: "error";
info: "info";
Expand Down Expand Up @@ -1923,6 +1941,7 @@ signatures (every public export and the types it is made of)
propagationRuleSchema (packages/core/src/lib/config.ts)
const propagationRuleSchema: z.ZodObject<{
derivatives: z.ZodString;
scope: z.ZodOptional<z.ZodString>;
severity: z.ZodOptional<z.ZodEnum<{
error: "error";
info: "info";
Expand Down Expand Up @@ -2082,6 +2101,7 @@ signatures (every public export and the types it is made of)
}, z.core.$strict>>>;
propagation: z.ZodOptional<z.ZodArray<z.ZodObject<{
derivatives: z.ZodString;
scope: z.ZodOptional<z.ZodString>;
severity: z.ZodOptional<z.ZodEnum<{
error: "error";
info: "info";
Expand Down
10 changes: 10 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ See the [schedule contract](integration-contract/package-api.md#scheduled-tasks-

### Preview and confirm a hygiene repair

For opted-in propagation automation, `brain hygiene propagation --dry-run --json`
shows the actual source diffs, typed JEV answers and threshold sensitivity. It
may call the provider but writes no Markdown. Without `--dry-run`, it records
separate freshness judgments; source/derivative content and dates stay unchanged.
The normal reconcile/next paths use matching receipts automatically. All
non-current, uncertain, below-floor and unavailable cases remain reviewable.
See [configuration](configuration.md#hygienepropagation) for owner opt-in,
confidence presets, extra veto-only questions and hosted scheduling. This is
separate from applying a bounded content repair below.

Use `brain hygiene next --json` to discover the selected finding's complete
`handlers` array, including each choice's input schema, effect and post-check.
Broken links offer a note picker and text-only choice, plus a suggestion only
Expand Down
75 changes: 75 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,81 @@ taxonomy: {
| `source` | `string` | Exact path of the canonical source document. |
| `derivatives` | `string` (glob) | Glob for documents that derive from the source. |
| `severity` | `"error" \| "warning" \| "info"` | Optional finding severity. |
| `scope` | nonempty `string`, up to 4000 characters | Declared purpose and required coverage of the derivatives, used by opted-in freshness review. A document's `propagation_scope` overrides it. |

### `hygiene.propagation`

Optional automatic propagation review, **off until `enabled: true`**. It keeps
complete current/reference source texts and an explicit source diff. Only a
positive currency judgment meeting the owner's policy can acknowledge freshness.
Source and derivative content, `created` and `updated` stay byte-identical; the
receipt lives in `context/hygiene/propagation-reviews.md`. Missing context,
provider failure and every other judgment remain for the owner.

```ts
hygiene: {
propagation: { enabled: true, profile: "balanced" },
},
taxonomy: {
propagation: [{
source: "notes/voyage-plan.md",
derivatives: "notes/command-summary.md",
scope: "Current ship commander only; omit provisions.",
}],
},
```

| Setting | Default | Meaning |
| --- | --- | --- |
| `enabled` | `false` | Persistent owner authorization for this automation. A key or CLI flag cannot turn it on. |
| `profile` | `"balanced"` | `conservative`: floor 0.9 plus cross-checks; `balanced`: 0.7 plus cross-checks; `permissive`: floor 0, currency question only. |
| `minConfidence` | From profile | Optional 0–1 override; every required answer must meet it. This is answer concentration, **not** a probability of correctness. |
| `crossChecks` | From profile | Also require positive answers on support for all included assertions and sufficient in-scope coverage. They can only veto the currency answer; confidence is never averaged or multiplied. |
| `maxFiles` | `10` | At most 1–100 uncached model judgments per invocation. Cached negatives do not consume the quota. |
| `timeoutMs` | `5000` | Per-request deadline, 100–30000 ms, bounded by the remaining run budget. |
| `budgetMs` | `10000` | Run dispatch budget, 100–60000 ms, shared by history/diff preparation and provider calls. |
| `maxInputChars` | `40000` | Complete request character bound, 1000–80000. Oversize inputs are left for review, never clipped. Provider context limits can still refuse a request. |
| `exclude` | `[]` | Additional contained paths/prefixes/globs never sent to the provider. Taxonomy exclusions also apply, including canonical symlink targets. |

The presets are policy choices, not calibrated correctness guarantees. Start
with `brain hygiene propagation --dry-run --json`: it reports individual
judgments and acceptance at several floors, both currency-only and cross-checked,
without extra calls for that sensitivity table. It replays the saved answers;
changing the question bundle on a fresh request may also change the primary
answer. The [measured tradeoff](decisions/propagation-triage.md#user-selected-confidence-and-cross-checks)
is from short authored examples, not an expected production error rate.
The distinction follows [TypeSafe's confidence definition](https://docs.typesafe.ai/confidence):
it summarizes the answer distribution, not independently verified correctness.

Scope must be explicit, in a matching propagation rule or the derivative's
nonempty `propagation_scope` frontmatter. `propagation_reference` may name the
full Git commit ID of a known reference source snapshot. Otherwise review uses
the commit recording the exact current derivative bytes. That is a recorded
content version, **not** an inferred generation time. An uncommitted derivative
without an explicit reference, missing historical source, historical symlink,
unclear scope or unavailable source stays for review. Dates alone never select
history. All configured sources plus a Markdown `generated_from` are consulted.

The concrete model is pinned to the evaluated `jev-1.13.0`; `TYPESAFE_API_KEY`
authenticates it. Successful typed judgments, including those left for humans,
are cached by source/derivative bytes, scope and model/question version. Changing
a threshold re-applies the policy locally to those answers. The UTC observation
day is part of the evidence: time-dependent judgments expire on a new day, even
when files did not change. Unseen/oldest-reviewed paths go first so bounded runs
can advance through a backlog. Enabling additional
checks asks again only if their answers are missing. Source, derivative or
scope changes invalidate the evidence; model/question upgrades require review
again. Disabling the feature stops using its acknowledgements. Deleting the
disposable index does not lose the Markdown receipts.

Ordinary `hygiene reconcile` and non-preview `hygiene next` run the prepass when
enabled and credentials are available. `audit` only reads receipts and never
calls a model; `next --dry-run` never starts provider work. Hosted interactive
review remains credential-free. For hosted scheduling, opt into
`BRAIN_UI_CRON_PROPAGATION=on` as well: the generated daily 05:45
`hygiene-propagation` job runs through credentialed, exclusive maintenance,
separately from the credential-free weekly hygiene job. It also requires core
0.45.0+ and the brain's persistent opt-in; it is never an unwrapped trusted job.

### `taxonomy.facts`

Expand Down
1 change: 1 addition & 0 deletions docs/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ somebody already learn the hard way?*
| [audit-repair-suggestions.md](audit-repair-suggestions.md) | Why `audit --fix` suggestions should come from registered repair capabilities: the current completion prompt scored below the providerless text and never recognized a repairable finding. |
| [candidate-extraction.md](candidate-extraction.md) | Why code plus Jev does not replace research extraction: it invents event-end field values and the calibrated floor drops announced contacts. |
| [mechanical-hygiene.md](mechanical-hygiene.md) | Why conservative date and Status-table repairs belong in CLI code: the lean skill/code/Jev comparison, source-byte quality, vetoes and limits. |
| [propagation-triage.md](propagation-triage.md) | Why Jev can filter propagation review on supplied source context in the authored comparison, with and without explicit diffs, while uncertainty labels and date-only acknowledgements remain separate. |
| [smart-capture.md](smart-capture.md) | What the lean comparison supports for bounded capture routing, vocabulary tags and literal writes, and where the small authored sample stops. |
| [routing-only-capture.md](routing-only-capture.md) | Why the routing-only smart-capture split is a no-go as frozen: code plus Jev made no wrong-target append but fell below the shipped skill on type and target, and the tool-less tag step over-tagged within the vocabulary. |
| [import-enrichment.md](import-enrichment.md) | Why import Stage 3 retains the combined skill call: Jev's tag F1 and damaged-input safety gains do not offset lower type accuracy and accepted coverage at the measured input framing and floor. |
Expand Down
4 changes: 2 additions & 2 deletions docs/decisions/audit-markers.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ first three markers as `examples`, in source order. Severity stays the only
classification: must-fix means errors plus warnings, informational means
infos, and `brain audit` and `brain maintain` report both totals beside the
severity counts, computed by one function (`auditTotals`,
`packages/core/src/lib/auditor.ts:642-647`).
`packages/core/src/lib/auditor.ts:647-652`).

`brain briefing` shows that must-fix total in Upkeep even without hygiene logs.
It uses the same current audit pipeline, including enabled modules' hygiene
Expand Down Expand Up @@ -61,7 +61,7 @@ rather than silently read as one.

The same change added `broken-link` warnings to the audit. They come from the
`links` rows the indexer wrote with no target (`findBrokenLinks`,
`packages/core/src/lib/auditor.ts:614-626`), and the indexer resolves each
`packages/core/src/lib/auditor.ts:619-631`), and the indexer resolves each
link with the resolver and alias fallback `brain validate` uses
(`function rebuildLinks`, `packages/core/src/lib/indexer/persist.ts:293-313`).
The message comes from one describer that both commands call
Expand Down
4 changes: 2 additions & 2 deletions docs/decisions/claude-code-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ next to it.
`/usr/local/bin/claude` and resolved with
`env.CLAUDE_CODE_PATH || "/usr/local/bin/claude"`. Since #213 it has no
default (`name: "CLAUDE_CODE_PATH"`,
`packages/ui-server/src/config/env.ts:550-550`) and is null when unset
(`claudeCodePath`, `packages/ui-server/src/config/env.ts:1151`). The whole `agent` block is copied into the backend's module
`packages/ui-server/src/config/env.ts:584-584`) and is null when unset
(`claudeCodePath`, `packages/ui-server/src/config/env.ts:1200`). The whole `agent` block is copied into the backend's module
config (`config: { ...agent }`,
`packages/ui-server/src/agent/backend.ts:505`), read back as a string
(`const claudeCodePath`, `packages/ui-backend-claude/src/module.ts:266-270`)
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/deterministic-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ version.
- **The container cron wrapper reads a result only from its own sync job.**
It parses stdout when the job is `sync` and its argv is exactly what the
crontab emitter writes (`isSyncJob`,
`packages/ui-server/src/cron/emit.ts:79-85`), and passes every other job's
`packages/ui-server/src/cron/emit.ts:81-87`), and passes every other job's
stdout through untouched. A new wrapper flag would have done the same, but
the wrapper command is deployment configuration, and a wrapper that did not
know the flag would have broken the nightly sync.
Expand Down
8 changes: 4 additions & 4 deletions docs/decisions/governed-writable-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ their own, keep repository-controlled code off the host
Each case below was reproduced on a disposable fixture:

- **The config's dependencies.** The host imports `brain.config.ts`
(`export async function loadUserConfig`, `packages/core/src/lib/config.ts:644`).
(`export async function loadUserConfig`, `packages/core/src/lib/config.ts:660`).
The config can import local helpers and local module entries, and those
files are not on any fixed list.
- **Bun startup.** A newly created `bunfig.toml` preload runs before any
Expand Down Expand Up @@ -543,7 +543,7 @@ maintenance worker no longer receives the keys the provider relay carries
(`GEMINI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` and keys the operator
lists for it), and the brain's `.env*` files are masked as they are for a
credential-free worker. Its `brain` CLI reaches those providers through its own
relay (`providerRelayFor`, `packages/ui-server/src/brain/host-boundary.ts:422-429`).
relay (`providerRelayFor`, `packages/ui-server/src/brain/host-boundary.ts:426-433`).
What remains is narrower and stated in the status: keys the relay does not
carry (the `jev` reranker's, a `brain sync` agent runner's login) and every
key on a host without managed native storage, where there is no relay.
Expand Down Expand Up @@ -4218,9 +4218,9 @@ files, `.claude/`, `.agents/`, `.pi/`, `.mcp.json`, and
`context/scheduled-tasks/`. The finite configuration seed mapping is consumer-qualified:

- The core CLI loads `brain.config.ts` or `brain.config.json` at the canonical
brain cwd (`loadUserConfig`, `packages/core/src/lib/config.ts:644-678`).
brain cwd (`loadUserConfig`, `packages/core/src/lib/config.ts:660-694`).
Host commands bind that cwd to the selected brain (`function hostSpawn`,
`packages/ui-server/src/brain/host-boundary.ts:514-525`).
`packages/ui-server/src/brain/host-boundary.ts:518-529`).
- Bun startup uses root `bunfig.toml` and `package.json`; retained literal
preload/module inputs can identify a nested module's nearest package scope.
The inventory walks parent directories only within the originating journal
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/hygiene-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ already carries category, path and stable evidence (`HygieneCandidate`,
(`hygieneId`, `packages/core/src/lib/hygiene.ts:182-185`). Those primitives do not
by themselves supply validation-to-hygiene equivalence, priority selection or
review dispositions. The CLI exposes reconciliation, listing and deterministic selection
(`hygieneCommand`, `packages/core/src/cli/commands/hygiene.ts:257-259`).
(`hygieneCommand`, `packages/core/src/cli/commands/hygiene.ts:275-277`).

## Selection: severity and known urgency, then age and identity

Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/index-query-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ options and later context-root mutation. Each operation retains its own
core-owned read snapshot/native lifetime. There is no persistent handle,
transaction spanning callbacks, consumer-supplied provider, SQL callback or
prepare/execute escape. Keep awaited sync/async callback execution and existing
failed-check reporting (`const found = await check`, `packages/core/src/lib/auditor.ts:1089-1102`).
failed-check reporting (`const found = await check`, `packages/core/src/lib/auditor.ts:1099-1112`).
Typed failure remains distinct from an empty valid result or successful check.
The current raw context stays in source until #699 migrates every callback,
fixture and author guide together; the ruling approves removal in that change,
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/module-mcp-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ hygiene checks, index rules, excludes and cron, but no tools
- **Unload or hide a tool when its module goes dormant, mid-process.** #527
excludes runtime unloading. `brain.config.ts` is loaded with a dynamic
`import()` (`const mod = await import(tsPath)`,
`packages/core/src/lib/config.ts:657`), and a process caches that import,
`packages/core/src/lib/config.ts:673`), and a process caches that import,
so a running server cannot reliably see a config change anyway. Promising
it would be promising something the loader cannot deliver.

Expand Down
Loading
Loading