Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs(questions): pinned-questions guide, KEY_FILES, tool catalog, error codes, spend controls, context_pack fields, benefit-gate README

garrytanab822b3c5808
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.md
index 25ff219388..82c5d59c2b 100644
--- a/docs/TOOL_CATALOG.md
+++ b/docs/TOOL_CATALOG.md
@@ -4,7 +4,7 @@
<!-- Regenerate: bun run scripts/generate-tool-catalog.ts -->
<!-- Freshness-guarded by scripts/check-tool-catalog-fresh.sh (bun run verify). -->
-Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **Starter** marks membership in the ~39-op `starter` surface (`src/mcp/surface.ts`); **Gate** names the config key that must be true before remote callers see/call the op (`gbrain config set <key> true`). What a given token actually sees is further filtered per request by scope, bound-client fence, publish gates, and the per-client surface — see `docs/operations/mcp-surface-runbook.md`. Area names are non-contractual groupings.
+Every non-localOnly operation on the MCP surface: 142 tools across 24 areas. **Starter** marks membership in the ~39-op `starter` surface (`src/mcp/surface.ts`); **Gate** names the config key that must be true before remote callers see/call the op (`gbrain config set <key> true`). What a given token actually sees is further filtered per request by scope, bound-client fence, publish gates, and the per-client surface — see `docs/operations/mcp-surface-runbook.md`. Area names are non-contractual groupings.
## admin
@@ -177,6 +177,16 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S
| `restore_page` | Restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). | write | | |
| `revert_version` | Restore a page to an earlier version from its history (a new revision; history is kept). | write | | |
+## questions
+
+| Tool | Description | Scope | Starter | Gate |
+|---|---|---|---|---|
+| `questions_list` | List pinned questions with freshness, blocked reason and next action, plus fresh/stale/pending counts. | read | | |
+| `questions_pin` | Pin a question: gbrain keeps a cited answer current from your notes and flags sentences whose evidence changed. | write | | |
+| `questions_refresh` | Refresh a pinned answer now (a paid model call): re-retrieves current evidence and edits the answer, or recomputes with full or after deletions. | write | | |
+| `questions_status` | One pinned question: the answer with per-sentence stale flags, evidence watermark, last refresh, blocked reason, next action and verify step. | read | | |
+| `questions_unpin` | Unpin a question: refreshes stop and its page is archived (your notes on it are kept). | write | | |
+
## schema
| Tool | Description | Scope | Starter | Gate |
diff --git a/docs/architecture/KEY_FILES.md b/docs/architecture/KEY_FILES.md
index 0a194b5b47..19d0670566 100644
--- a/docs/architecture/KEY_FILES.md
+++ b/docs/architecture/KEY_FILES.md
@@ -38,6 +38,7 @@ boundary and add its link here rather than raising the cap.
| [Commands (6/6)](key-files/commands-6.md) | `src/commands/sync.ts` through `src/commands/whoknows.ts` |
| [Core Ai](key-files/core-ai.md) | `src/core/ai/build-gateway-config.ts` through `src/core/ai/types.ts` |
| [Core Decide](key-files/core-decide.md) | `src/core/ai/decide/*`, `src/core/search/decide-stage.ts`, `gbrain decide`, `decide_health` (System One) |
+| [Core Questions](key-files/core-questions.md) | `src/core/questions/*`, `src/core/ops/questions.ts`, `gbrain questions`, the `standing_questions` phase (pinned questions) |
| [Core Cycle](key-files/core-cycle.md) | `src/core/cycle/anomaly.ts` through `src/core/cycle/phase-table.ts`: atoms, facts, drains, probes, phase scope |
| [Core Cycle (continued)](key-files/core-cycle-continued.md) | `src/core/cycle/` synthesis, patterns, consolidation, concept publication and `connector-atoms.ts` |
| [Core Minions (1/2)](key-files/core-minions-1.md) | `src/core/minions/` through `src/core/minions/rss-default.ts` |
diff --git a/docs/architecture/key-files/core-questions.md b/docs/architecture/key-files/core-questions.md
new file mode 100644
index 0000000000..11bf182936
--- /dev/null
+++ b/docs/architecture/key-files/core-questions.md
@@ -0,0 +1,33 @@
+# Key files: Core Questions (pinned questions)
+
+[Subsystem index](../KEY_FILES.md). Read only the entries relevant to your change.
+Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.
+User guide: [docs/guides/pinned-questions.md](../../guides/pinned-questions.md).
+
+- `src/core/questions/schema.ts` — DDL for `pinned_questions` (one row per pin: question, scope, state, publish mode, the answer as JSON sentences, watermark, durable lease, spend) and `question_evidence` (per-sentence pointers: kind `page|fact|timeline|take|owner`, page id, page generation and knowledge revision, item id, content hash). No foreign keys, so a hard delete or cascade leaves a dangling pointer that reads as stale. Fragment of `src/schema.sql` via `scripts/build-schema.ts`; applied by migration v205.
+
+- `src/core/questions/identity.ts` — Source-qualified ids (`<source_id>:questions/<slug>`) and deterministic slugs (kebab of the question plus a hash of the case-folded question, slug prefix and entity), so pinning the same question with the same scope is idempotent. `PINNED_QUESTION_MARKER` (`pinned_question` frontmatter key) and `sentenceId`. Pure; imported by the migration handler.
+
+- `src/core/questions/store.ts` — Row reads, idempotent `insertPin` (`ON CONFLICT DO NOTHING`), `updatePinState` (bumps `revision` so an in-flight refresh fails revalidation), and the durable lease (`acquireLease` takes a free or expired lease; `releaseLease` records the attempt's error and spend). Plain `executeRaw` on side tables the canonical writer guard does not cover.
+
+- `src/core/questions/freshness.ts` — Read-time staleness. `evaluateAnswer` joins the current answer's evidence pointers against `pages`, `sources`, `facts`, `timeline_entries` and `takes` on every read: missing row, soft delete, archived source, generation or knowledge-revision change, fact expiry by `valid_until` with no write, withdrawal (`expired_at`), supersession, content-hash change, inactive take and owner edits each mark the sentence stale; a sentence with no pointer or an unknown kind is stale (fail closed); a pointer outside the reader's sources hides the sentence. `needsFull` flags reasons an incremental edit cannot repair. Hash expressions (`FACT_HASH_SQL` etc.) are shared with capture and commit.
+
+- `src/core/questions/refresh.ts` — `refreshPin`: no-spend pre-checks (inactive, `no_model_key` via `probeChatModel`, `budget_exhausted` via the caller's `BudgetMeter`), lease, capture (pin revision, question page, global page-generation clock and newest fact id as the watermark), `retrieveEvidence` (hybrid retrieval with keyword fallback, plus facts, timeline rows and takes anchored to the retrieved pages; question and synthesis pages, marker pages and pages that repeat a published answer sentence after it was published are never evidence), one model call (incremental edit of the previous answer, or full recompute after deletions, withdrawals, conflicting corrections, non-monotonic questions or `full`), then one transaction that locks the pin and every cited row (`FOR UPDATE`/`FOR SHARE`), revalidates lease, revision and dependency revisions, writes the answer and replaces the evidence rows. A mismatch publishes nothing (`conflict`); any failure keeps the previous answer and records `refresh_failed:<stage>`. `RefreshHooks` are test-only injection points.
+
+- `src/core/questions/pages.ts` — The question page: question, scope and the owner's notes, never the answer. `syncQuestionPage` creates, archives or restores it through coordinated `put_page` (trusted local callers only). `ownerClaims` turns the body (minus heading and comments) into owner-attributed sentences, pinned to the body's hash.
+
+- `src/core/questions/receipt.ts` — `buildReceipt`: freshness (`fresh|stale|awaiting_refresh|refreshing|archived`), sentence counts, evidence watermark, last refresh, blocked reason (`awaiting_consent`, `no_model_key`, `budget_exhausted`, `refresh_failed`, `no_worker`), `next_action` (an agent-operator `Action` with a read-only `verify`) and the answer for owner-capable readers. `scheduledRefreshAvailable` (a `standing_questions` run in the last two days, or installed unpaused autopilot) decides `no_worker`.
+
+- `src/core/questions/service.ts` — The operations' behavior. `requireOwnerCapable` admits the trusted local CLI and remote grants that read private pages and are neither slug-fenced nor delegated; everyone else gets `question_owner_only` with the CLI equivalent. Consent: CLI pins are active; MCP pins are inactive (`awaiting_consent`) unless a paid preapproval exists; `pin --id` on the host activates. First answer is a bounded wait (`wait_ms`, abort releases the lease). `pinnedAnswersForPack` feeds context_pack's optional `pinned_questions` / `withheld` fields (published, active, entity-scoped pins; fresh sentences only). Emits the `pinned_answer_stale` notice.
+
+- `src/core/questions/phase.ts` — Cycle phase `standing_questions` (global, writes): syncs question pages, refreshes due active pins (never answered, then stale, then new evidence since the watermark; cooldown per pin or `cycle.standing_questions.cooldown_days`) under one `BudgetMeter` (`cycle.standing_questions.budget_usd`) and `max_per_cycle`, stops on `budget_exhausted` or `no_model_key`, and stamps `cycle.standing_questions.last_run_at`. Kill switch `cycle.standing_questions.enabled=false`.
+
+- `src/core/questions/auto-think-migration.ts` — Maps the seven `dream.auto_think` keys onto pins without creating consent (disabled or zero budget → inactive; `auto_commit=false` → draft; cooldown and model per pin; budget, max and allow_unpriced seed `cycle.standing_questions.*` only when unset). Config reads and inserts only; idempotent. `autoThinkReplacement` is what `gbrain config get|set` prints for an old key.
+
+- `src/core/ops/questions.ts` — `questions_pin`, `questions_refresh`, `questions_unpin` (write, `writeInference` `explicit_llm` / `none`) and `questions_list`, `questions_status` (read). Full surface only (not `STARTER_OPS`). CLI equivalents in `src/core/ops/cli-equivalent.ts`.
+
+- `src/commands/questions.ts` — `gbrain questions pin|list|status|refresh|unpin` through `handleToolCall` (trusted local); exit 1 when the answer is blocked or a refresh did not publish.
+
+- Privacy and retrieval seams: `src/core/search/private-visibility.ts` treats `type: question` without a visibility as private and any page with the `pinned_question` marker as private whatever its `visibility`; `buildVisibilityClause` (`src/core/search/sql-ranking.ts`) keeps marker pages out of every search arm for every caller.
+
+- Tests: `test/helpers/pinned-questions-scenarios.ts` (B5 safety gate, operator journeys, migration) runs on PGLite (`test/pinned-questions-safety.test.ts`) and Postgres (`test/e2e/pinned-questions-postgres.test.ts`); `test/questions-cli.test.ts`; `test/pinned-questions-benefit-gate.test.ts` (offline harness plumbing); the `standing_questions` row of `test/managed-phase-matrix.test.ts`.
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index c82d04de7e..b968316e74 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -1563,6 +1563,26 @@ More: [docs/guides/repair.md#projection-owner-resident](../../docs/guides/repair
|---|---|---|---|---|---|---|
| The catalog adoption is accepted but not fully committed. | A temporary condition (a lock, a pending write, a rate limit); the same request can succeed later. | Wait briefly, then retry the same request (writes: reuse the same request_id). | agent | `repeat the read that failed` | 1 | yes |
+### question_not_found
+
+<a id="question_not_found"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| No pinned question has this id in the caller's scope; ids are source-qualified (default:questions/<slug>). | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/pinned-questions.md#ids-and-scope](../../docs/guides/pinned-questions.md#ids-and-scope)
+
+### question_owner_only
+
+<a id="question_owner_only"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| Pinned questions are owner-private: this connection cannot read private pages (or is slug-fenced or delegated), so the owner runs the command on the brain host. | Only the operator of the brain host can change what blocks this. | Only the brain host's operator can resolve this. Tell the user the message and run `gbrain doctor --json` on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/pinned-questions.md#who-can-see-pinned-questions](../../docs/guides/pinned-questions.md#who-can-see-pinned-questions)
+
### queue_capacity
<a id="queue_capacity"></a>
diff --git a/docs/guides/pinned-questions.md b/docs/guides/pinned-questions.md
new file mode 100644
index 0000000000..27f126ecff
--- /dev/null
+++ b/docs/guides/pinned-questions.md
@@ -0,0 +1,176 @@
+# Pinned questions
+
+A pinned question is a question gbrain keeps answered. You pin it once; gbrain
+answers it from your notes with a citation behind every sentence, checks those
+citations on every read, and refreshes the answer when its evidence changes.
+A sentence whose evidence was edited, deleted, forgotten, superseded or has
+expired is flagged stale the moment you read it, and `context_pack` leaves it
+out.
+
+Pinned questions are private to the brain owner. Answers are paid model calls;
+reads are free.
+
+## Quick start
+
+```bash
+gbrain questions pin "Who leads acme-example engineering now?" --entity companies/acme-example
+gbrain questions status default:questions/who-leads-acme-example-engineering-now-1a2b3c4d
+gbrain questions refresh default:questions/who-leads-acme-example-engineering-now-1a2b3c4d
+gbrain questions list
+gbrain questions unpin default:questions/who-leads-acme-example-engineering-now-1a2b3c4d
+```
+
+`pin` prints the first answer (it waits up to 30 seconds; `--defer` skips it)
+and the question's id. Every subcommand takes `--json`, which returns the
+receipt described below. The command exits 1 when the answer is blocked.
+
+The same operations exist over MCP: `questions_pin`, `questions_list`,
+`questions_status`, `questions_refresh` and `questions_unpin`. They are on the
+full tool surface (not the starter surface).
+
+| Tool | Scope | What it does |
+|---|---|---|
+| `questions_pin` | write | Pins `question` (or re-pins / activates `id`); returns the first answer or `awaiting_refresh` with the next step |
+| `questions_list` | read | Every pin with freshness and blocked reason, plus fresh / stale / pending counts |
+| `questions_status` | read | One pin: answer sentences with stale flags, watermark, last refresh, next action |
+| `questions_refresh` | write | Refreshes now (`full: true` recomputes) |
+| `questions_unpin` | write | Stops refreshes and archives the page |
+
+## Ids and scope
+
+An id is source-qualified: `<source>:questions/<slug>`. The slug comes from
+the question and its scope, so pinning the same question with the same scope
+again returns the existing pin (`created: false`) and spends nothing.
+
+The scope says where evidence comes from. Over MCP it is an object:
+
+```json
+{ "question": "Where does acme-example build widgets?", "scope": { "source": "default", "entity": "companies/acme-example" } }
+```
+
+| Field | CLI flag | Meaning |
+|---|---|---|
+| `source` | `--source <id>` | The source the pin lives in and reads evidence from; default: the current source |
+| `slug_prefix` | `--prefix <p>` | Only pages under this prefix, for example `projects/` |
+| `entity` | `--entity <slug>` | The entity page the question is about; `context_pack` for that entity carries the answer |
+
+The same question in two sources is two pins with two ids.
+
+## What a receipt says
+
+Every pin, list, status and refresh returns the same fields:
+
+| Field | Meaning |
+|---|---|
+| `freshness` | `fresh`, `stale` (at least one sentence's evidence changed), `awaiting_refresh` (no answer yet), `refreshing` (a refresh holds the lease), `archived` |
+| `answer` | Sentences with `stale` and `reasons`, and `origin` (`model` or `owner`) |
+| `evidence_watermark` | The page-generation clock and newest fact id the answer was built from |
+| `new_evidence_since_watermark` | Pages or facts in scope changed after the answer; the next cycle refreshes it |
+| `last_refresh_at` | The last successful refresh |
+| `blocked_reason` | Why the answer cannot be refreshed right now (below), or null |
+| `next_action` | The step that fixes it: `argv`, `mcp`, `consent`, `actor`, `why` and a read-only `verify` |
+| `verify` | `gbrain questions status <id> --json` / `questions_status {id}` |
+
+| `blocked_reason` | Meaning | Next action |
+|---|---|---|
+| `awaiting_consent` | The pin was made over MCP (or imported from a disabled `dream.auto_think`) and is not active | The owner runs `gbrain questions pin --id <id>` |
+| `no_model_key` | No chat-model key is configured | The user adds an Anthropic or OpenAI key (`gbrain providers list` shows how) |
+| `budget_exhausted` | This run's refresh budget is spent | Raise `cycle.standing_questions.budget_usd`, or wait for the next run |
+| `refresh_failed` | The last refresh failed; the previous answer is kept with its stale flags | `questions_refresh {id, full: true}` |
+| `no_worker` | Nothing runs scheduled refreshes (no `standing_questions` phase in two days, no autopilot) | `questions_refresh {id}`; recurring refreshes need autopilot, which a pin never installs |
+
+A stale or blocked answer also adds a `pinned_answer_stale` notice to the
+response.
+
+## Freshness
+
+Staleness is computed when you read, not when something writes. Each answer
+sentence records what it cites: a page revision, a fact, a timeline entry or
+a take. On every read gbrain checks those against the current brain. A
+sentence is stale when its evidence:
+
+- was edited, renamed away or made private (the page's revision changed);
+- was soft-deleted or hard-deleted, or its source was archived;
+- was forgotten, superseded, or expired because its `valid_until` passed;
+- is a take that was deactivated or changed, or a timeline entry that was removed;
+- can't be found or verified (a sentence with no citation is always stale).
+
+`context_pack` returns only the fresh sentences of pinned answers for the
+entities you asked about, in an optional `pinned_questions` field, and counts
+the left-out sentences in an optional `withheld` field (with the refresh
+command). Both fields are outside `text` and the token budget.
+
+Refreshing re-retrieves evidence from the current brain and edits the
+previous answer. After a deletion, a withdrawal, a conflicting correction, or
+for a question about the latest or current state, it recomputes the answer
+from scratch. A refresh publishes only if nothing it cited changed while it
+ran; otherwise the previous answer stays, still flagged, and the next refresh
+tries again. A failed refresh never removes the previous answer.
+
+Question pages, synthesis pages and pages that copy a published answer are
+never used as evidence.
+
+## Your own notes
+
+Each pin has a page, `questions/<slug>`, holding the question. Write your own
+claims on it, below the heading. Every sentence you write there is part of the
+answer as your claim (`origin: owner`). When you edit the page, your claims
+read stale until the next refresh picks up the new text. The generated answer
+is never stored in the page or its file; read it with `gbrain questions
+status`.
+
+## Who can see pinned questions
+
+Pinned questions are owner-private:
+
+- The question page is private, and it never appears in search, query,
+ recall or think results, for anyone.
+- Answers are never written to pages, chunks, page history, exports or git.
+- The `questions_*` tools and the `context_pack` fields answer only the local
+ CLI and MCP connections that can read private pages (the operator set
+ `search.remote_private_pages=visible`) and are not slug-fenced. Any other
+ connection gets `question_owner_only` with the command the owner runs
+ instead, and `context_pack` shows it nothing.
+
+## Paid refresh and consent
+
+A pin made on the CLI is active: it answers now and refreshes when its
+evidence changes. A pin made over MCP is created inactive and spends nothing
+until the owner activates it with `gbrain questions pin --id <id>`, unless the
+owner has set a paid preapproval (`gbrain config set
+consent.preapprove.paid.max_usd_per_run <usd>`), which also caps each MCP
+refresh. Pinning never installs a scheduler.
+
+Scheduled refreshes run in the `standing_questions` cycle phase (part of
+`gbrain dream` and autopilot). Settings:
+
+| Key | Default | Meaning |
+|---|---|---|
+| `cycle.standing_questions.budget_usd` | `1.00` | Spend cap per run (`0` spends nothing) |
+| `cycle.standing_questions.max_per_cycle` | `5` | Refreshes per run |
+| `cycle.standing_questions.cooldown_days` | `1` | Minimum days between scheduled refreshes of one pin |
+| `cycle.standing_questions.allow_unpriced` | `false` | Let a model with no known price run uncapped |
+| `cycle.standing_questions.enabled` | `true` | `false` stops the phase |
+| `models.standing_questions` | deep tier | The answer model |
+
+A draft-only pin (`publish_mode: draft`) is refreshed but not served by
+`context_pack`; `gbrain questions pin --id <id> --publish` publishes it.
+
+## Coming from dream.auto_think
+
+The `dream.auto_think` settings became pins when this brain upgraded. Each
+saved question is a pin in the `default` source:
+
+| Old key | Now |
+|---|---|
+| `dream.auto_think.questions` | One pin per question (`origin: auto_think`) |
+| `dream.auto_think.enabled=false` | The pins are inactive until you run `gbrain questions pin --id <id>` |
+| `dream.auto_think.budget` | `cycle.standing_questions.budget_usd`; a zero budget leaves the pins inactive |
+| `dream.auto_think.auto_commit=false` | The pins are draft-only |
+| `dream.auto_think.cooldown_days` | Each pin's cooldown |
+| `dream.auto_think.max_per_cycle` | `cycle.standing_questions.max_per_cycle` |
+| `models.auto_think` / `dream.auto_think.model` | Each pin's model |
+
+The upgrade made no model call. `gbrain config get` or `set` on an old key
+prints its replacement, and `gbrain dream --phase auto_think` points to
+`gbrain questions list`.
diff --git a/docs/operations/spend-controls.md b/docs/operations/spend-controls.md
index fdcdb358df..ac4f482baf 100644
--- a/docs/operations/spend-controls.md
+++ b/docs/operations/spend-controls.md
@@ -108,7 +108,8 @@ The USD-limit knobs accept `off`, `unlimited`, or `none` (case-insensitive) to m
| Life Chronicle event extraction | `chronicle.job_budget_usd` (per page) / `chronicle.auto_daily_limit` (calls per rolling 24 h) | `0.25` / `200` | caps one extraction call; past the daily limit pending pages wait for a free slot | `gbrain config set auto_chronicle false` | **not** consulted |
| Dream `synthesize` per-run budget | `dream.synthesize.budget_usd` | `5` | defers the transcript and the rest of the run before submission (estimate: prompt size + child output cap, x `max_turns` in agentic mode) | `unlimited` (`0` = submit nothing) | **not** consulted |
| Dream `synthesize` daily submission cap | `dream.synthesize.max_submissions_per_source_per_day` | `0` (off) | skips whole files; a failed count query submits nothing that run | `0` | **not** consulted |
-| Dream `BudgetMeter` phases (auto_think, drift, propose/grade takes, calibration) | `dream.auto_think.budget`, `dream.drift.budget`, `cycle.<phase>.budget_usd` | per phase | refuses the next submit past the cap | `unlimited` (`0` = spend nothing) | **not** consulted |
+| Dream `BudgetMeter` phases (drift, propose/grade takes, calibration) | `dream.drift.budget`, `cycle.<phase>.budget_usd` | per phase | refuses the next submit past the cap | `unlimited` (`0` = spend nothing) | **not** consulted |
+| Pinned-question refreshes (`standing_questions` phase, `questions_pin`, `questions_refresh`) | `cycle.standing_questions.budget_usd`, `cycle.standing_questions.max_per_cycle`; an MCP refresh is also capped by `consent.preapprove.paid.max_usd_per_run` | per run | refuses the refresh before any model call (`blocked_reason: budget_exhausted`) | `$1.00`, 5 pins per cycle (`0` = spend nothing) | an MCP-created pin stays inactive until the owner activates it or this preapproval exists |
Dream `BudgetMeter` phases meter a model missing from the pricing table at a
Sonnet-tier fallback rate instead of letting it run uncapped; local model
diff --git a/docs/protocol/MEMORY_VERBS_v1.md b/docs/protocol/MEMORY_VERBS_v1.md
index a96efd0d8c..ee4068c7e7 100644
--- a/docs/protocol/MEMORY_VERBS_v1.md
+++ b/docs/protocol/MEMORY_VERBS_v1.md
@@ -542,6 +542,15 @@ degraded_reason?, budget_tokens?, budget_used?, dropped_count? }`. `text` is the
pre-rendered, envelope-wrapped injectable block; with `budget_tokens` it is
rendered from the packed sets and never exceeds the declared budget.
+Two optional fields carry pinned-question answers
+([pinned questions](../guides/pinned-questions.md)) for owner-capable callers
+(the local CLI, or a connection that reads private pages and is not
+slug-fenced): `pinned_questions[]` (`{ id, question, answer[], freshness }`,
+fresh sentences of published pins scoped to a packed entity) and `withheld`
+(`{ stale_sentences, question_ids[], refresh_command }`, the sentences left out
+because their evidence changed or is unreadable). Both are outside `text` and
+the budget; every other caller gets neither.
+
### delta(since?, entities?, budget_tokens?, session_id?, include_private?) — read, zero LLM
"What changed since T" for heartbeats — pages updated after
diff --git a/evals/pinned-questions/README.md b/evals/pinned-questions/README.md
new file mode 100644
index 0000000000..19361fd30c
--- /dev/null
+++ b/evals/pinned-questions/README.md
@@ -0,0 +1,39 @@
+# Pinned questions benefit gate (B5)
+
+Measures whether pinned questions pay for themselves: total lifecycle dollars
+per correct, fresh answer for three arms over one seeded workload, at frozen
+reads-per-write ratios (1 and 10).
+
+| Arm | Lifecycle cost counted |
+|---|---|
+| `pinned` | the initial pin, every refresh attempt (the `standing_questions` phase after each write batch), and the reader call over the delivered fresh sentences |
+| `query_reader` | `query` retrieval at the pinned answer's delivered-token budget, then one reader call per read |
+| `think` | one on-demand `think` per read |
+
+The report gives reads, correct answers, `stale_wrong` (an answer that states a
+superseded value), dollars and dollars per correct answer per arm, the pinned
+cost split (pin + refresh vs reads), and the break-even read count: the reads
+after which pinned is cheaper than `query_reader`.
+
+The workload (`generateWorkload(seed)`) gives each entity a factory city and
+corrects some of them in later write batches; the gold answer is the current
+city. It is byte-identical for a seed (`workload_hash`).
+
+## Modes
+
+```bash
+bun evals/pinned-questions/benefit-gate.ts --plan --json # size and cost estimate, spends nothing
+bun evals/pinned-questions/benefit-gate.ts --offline --json # stub models: a plumbing check, not evidence
+bun evals/pinned-questions/benefit-gate.ts --run --yes --max-usd <cap> \
+ --answer-model <provider:model> --reader-model <provider:model> # paid
+```
+
+`--run` refuses (exit 3) without `--yes` and a `--max-usd` at or above the
+plan's estimate. `--entities N` and `--batches N` size the workload; `--seed`
+fixes it. Paid runs follow the model-selection rules for gbrain evals (newest
+frontier models of each family) and are scheduled by the wave's owner;
+`test/pinned-questions-benefit-gate.test.ts` covers the offline plumbing.
+
+Pinned questions ship on by default only if this gate shows a win and the B5
+safety gate (`test/helpers/pinned-questions-scenarios.ts`) passes with zero
+leakage; with safety alone they ship opt-in.
diff --git a/llms-full.txt b/llms-full.txt
index a109dab739..49ea98ad4b 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -9065,6 +9065,15 @@ degraded_reason?, budget_tokens?, budget_used?, dropped_count? }`. `text` is the
pre-rendered, envelope-wrapped injectable block; with `budget_tokens` it is
rendered from the packed sets and never exceeds the declared budget.
+Two optional fields carry pinned-question answers
+([pinned questions](../guides/pinned-questions.md)) for owner-capable callers
+(the local CLI, or a connection that reads private pages and is not
+slug-fenced): `pinned_questions[]` (`{ id, question, answer[], freshness }`,
+fresh sentences of published pins scoped to a packed entity) and `withheld`
+(`{ stale_sentences, question_ids[], refresh_command }`, the sentences left out
+because their evidence changed or is unreadable). Both are outside `text` and
+the budget; every other caller gets neither.
+
### delta(since?, entities?, budget_tokens?, session_id?, include_private?) — read, zero LLM
"What changed since T" for heartbeats — pages updated after
diff --git a/llms.txt b/llms.txt
index 8cfb4af6a1..f9db5e1bd7 100644
--- a/llms.txt
+++ b/llms.txt
@@ -35,6 +35,7 @@ Repo: https://github.com/garrytan/gbrain
- [docs/what-schemas-unlock.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/what-schemas-unlock.md): Why schemas matter: 7 killer use cases (4000 invisible meetings, founder ops brain, research brain, legal brain, team brain, agent-as-co-curator) + the structural argument for typed page kinds. Read this before pitching schema authoring.
- [docs/schema-author-tutorial.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/schema-author-tutorial.md): 5-minute walkthrough: fork the bundled pack, add a custom `researcher` type, backfill existing pages via `gbrain schema sync --apply`, prove the T1.5 wiring via `gbrain whoknows`.
- [docs/guides/system-one.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/system-one.md): System One decision support (TypeSafe Jev or an llm: provider): every slot off or on, executed quickstart (`gbrain decide probe`, `probe --query`, `enable --recommended`, `status`), each slot in plain words, calibration and qualification, fail directions, egress rules, reading status/doctor, receipts, troubleshooting by refusal reason.
+- [docs/guides/pinned-questions.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/pinned-questions.md): Pinned questions: cited answers kept current from your notes (`gbrain questions pin|list|status|refresh|unpin`, `questions_*` MCP tools), read-time staleness, receipts and blocked reasons, owner-private visibility, consent for paid refresh, the standing_questions phase and the dream.auto_think migration.
- [docs/guides/live-sync.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/live-sync.md): Incremental markdown sync setup.
- [docs/guides/cron-schedule.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/cron-schedule.md): Recurring job scheduling.
- [docs/guides/minions-deployment.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/minions-deployment.md): Deploying the gbrain jobs worker: crontab + watchdog, inline --follow, systemd/Procfile/fly.toml, upgrade checklist.
diff --git a/scripts/llms-config.ts b/scripts/llms-config.ts
index ad4b9d4d84..f5767c4826 100644
--- a/scripts/llms-config.ts
+++ b/scripts/llms-config.ts
@@ -149,6 +149,13 @@ export const SECTIONS: DocSection[] = [
path: "docs/guides/system-one.md",
includeInFull: false,
},
+ {
+ title: "docs/guides/pinned-questions.md",
+ description:
+ "Pinned questions: cited answers kept current from your notes (`gbrain questions pin|list|status|refresh|unpin`, `questions_*` MCP tools), read-time staleness, receipts and blocked reasons, owner-private visibility, consent for paid refresh, the standing_questions phase and the dream.auto_think migration.",
+ path: "docs/guides/pinned-questions.md",
+ includeInFull: false,
+ },
{
title: "docs/guides/live-sync.md",
description: "Incremental markdown sync setup.",