Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

dream, verbs: land the wave 14 PR3 hunks now that wave 13 PR3 (#6446) is on master

garrytand00b3969c80d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c49b1e245f..00809249bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,7 @@ Twenty-one issues and three contributor PRs, mostly about the brain quietly doin
- **`code-callers` lists callers inside top-level `describe`/`it` blocks and other module-level statements** (#5001). A top-level statement containing a call in a JS/TS/TSX/Python/Ruby file is chunked as `module` / `__module__` (`<file-basename>::__module__`), so its calls get edges; both edge writers share `mapCodeEdges`. *Things to watch:* the next `gbrain sync` re-chunks and re-embeds those files once (priced as `grammar_drift`; `CHUNKER_VERSION` stays 8). Attribution follows @nikolai-vysotskyi's suggestion.
- **A 403 model-access denial classifies `model_not_found`, not `auth`** (#5394). The model-not-found phrases are tested before the status map; a plain 401/403 stays `auth`.
- **A write naming no `expected_revision` for an existing page is `revision_required`** (#5385), with `get_page` as the fix; a wrong revision stays `revision_conflict`; `force` and `revision_backfill_pending` are unchanged. `remember` and `add_tag` on an existing page still converge through the semantic retry.
+- **`propose_takes` skips atoms and every dream-written page** (#5211). New atoms carry `dream_generated: true` next to `extracted_by`, so facts extraction, the chronicle and transcript discovery skip them like other derived pages; `listCandidatePages` also drops legacy `type: atom` pages that carry neither stamp. The source page an atom was extracted from is still a candidate.
- **Every `recall` hit names its `source_id`** (#4830), falling back to the scope's single source; a federated read with no row source leaves it absent rather than guessing.
- **`think` bounds its evidence to the one explicit date a question names** when the caller passes no window (PR #5086). ISO day, ISO month or English month + year; a bare year, two distinct dates, an invalid date or a relative phrase leaves the window open. `window_source` and a `WINDOW_FROM_QUESTION` warning say when it applied. Contributed by @tarush1989. Supersedes #5086.
- **Matryoshka models that answer at their native width are fitted to the brain's width** (PR #5921). A recipe that declares `matryoshka: { native, prefixes }` for a model (NVIDIA's Nemotron-3-Embed-8B at 4096 with 1024/2048) has its native-width response sliced and L2-normalized before the dimension check; every other vector is untouched. Contributed by @abudhi19. Supersedes #5921.
diff --git a/scripts/check-orphan-modules.mjs b/scripts/check-orphan-modules.mjs
index 3f19960e60..4fd946fb5b 100644
--- a/scripts/check-orphan-modules.mjs
+++ b/scripts/check-orphan-modules.mjs
@@ -53,7 +53,6 @@ const ALLOWLIST = new Map([
// string in a reviewer-visible edit. Modules reached from `scripts/**` carry
// reason 'script-reachable', which the guard verifies.
const PERMITTED_TEST_ONLY = [
- { path: 'src/core/cycle/propose-takes-attribution.ts', reason: 'held: #5425 [UC4] mechanical holder check; its one call in propose-takes.ts is a wave 14 PR3 stack hunk behind wave 13 PR3 #6446 (remove this entry when it lands)' },
{ path: 'src/core/bootstrap/template-repo.ts', reason: 'script-reachable' },
{ path: 'src/eval/longmemeval/diagnostics.ts', reason: 'script-reachable' },
{ path: 'src/eval/longmemeval/evidence-brief.ts', reason: 'held: eval-only wave 1 brief builder (10x memory advantage plan A3), loaded by path from gbrain-evals eval/runner/pilot; product wiring is plan item A8, conditional on the A5 pilot' },
diff --git a/scripts/function-size-baseline.tsv b/scripts/function-size-baseline.tsv
index 43ea8dd3cf..03108e734d 100644
--- a/scripts/function-size-baseline.tsv
+++ b/scripts/function-size-baseline.tsv
@@ -34,7 +34,7 @@ src/core/cycle.ts runCycle 1279 seed: W5 baseline, refactor wave 1 (decompositio
src/core/cycle/extract-atoms.ts runPhaseExtractAtoms 790 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +12 #5809/#5832: hard/soft stop checks, chat-call signal, abortable pacing, no post-stop writes; +1 #5856: one BudgetTracker per drain attempt (reuse the attempt's tracker); +2 fix wave 9 lane P (#5041): opt-in write-through hook creation and its per-item call (derived-write-through.ts); +1 #5031: per-run page-atom title memo for the case-insensitive adoption fallback
src/core/cycle/extract-facts.ts runExtractFacts 381 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); -129 wave 9 follow-ups (receipts): the page reconcile plan and writes moved into planFenceReconcile/reconcileWrites/writeFenceReconcile, shared with the managed preparer; +2 #6264 (landed alongside): ontology observations never gate the unfenced-rows count; +2 #6259 (landed alongside): a quarantined page projects no fence facts; +1 #5575 I2 (L1a-taint): the run result sums the write-gate tally each page reconcile returns
src/core/cycle/grade-takes.ts GradeTakesPhase.process 402 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
-src/core/cycle/propose-takes.ts ProposeTakesPhase.process 429 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +2 #5958 (issue #5874): call_timeout_ms read and its per-page bound (phaseBoundedCallTimeout)
+src/core/cycle/propose-takes.ts ProposeTakesPhase.process 430 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +2 #5958 (issue #5874): call_timeout_ms read and its per-page bound (phaseBoundedCallTimeout); +1 #5425 [UC4]: the one attribution-check call after the extractor returns (logic in propose-takes-attribution.ts)
src/core/cycle/synthesize-concepts.ts runPhaseSynthesizeConcepts 490 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +4 #5490 review: a narrative a chat_fallback_chain model wrote is hashed under that model so the next cycle re-synthesizes it; +13 fix wave 9 lane P (D-N3): fence-stripped member hash with legacy-hash grandfathering, and the classic write moved to publishClassicConcept (concept-publication.ts); +3 (#5041): opt-in concept write-through hook and the import callback publishClassicConcept runs under the page lock; +6 #4907 (issue #4906): configured budget read, budget-capped counter, summary clause and details.warnings (message text in budgetWarnings); +4 fix wave 11 #6161: concept redirects in grouping and the skipped_deleted pre-check (logic in cycle/concept-redirects.ts); +13 fix wave 12 #6260: a narrative stopped before the end is a counted failure, and the per-member-hash retry bound (state in cycle/concept-retry-bound.ts)
src/core/cycle/synthesize.ts runPhaseSynthesizeInner 1048 +1 #5575 I2: output refs take their transcript taint before the provenance stamp (the stamp line stays the signal-guarded literal cycle-abort pins); seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +3 #5854: publish_pending from postprocess, a pending summary publish deferred instead of failing the phase; +1 fix wave 11 #6160: oneshot_task_prefixes on the child job data
src/core/facts/backstop.ts runPipelineBodyInner 358 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
diff --git a/src/commands/dream.ts b/src/commands/dream.ts
index 12ff2929bb..0d1f915004 100644
--- a/src/commands/dream.ts
+++ b/src/commands/dream.ts
@@ -852,6 +852,8 @@ export async function runDream(engine: BrainEngine | null, args: string[]): Prom
const report = await runCycle(engine, {
brainDir,
+ // #6023: the local CLI sees private fact text in the consolidate dry-run preview.
+ remote: false,
dryRun: opts.dryRun,
pull: opts.pull,
phases,
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 30f5eff8df..7464f2143f 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -381,6 +381,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: '0.60.159.0', text: 'On OpenClaw 2026.9.x, which no longer passes a session file to the context engine, compaction now banks a gbrain checkpoint segment again by reading the transcript through the host\'s session-transcript runtime. Each compaction leaves an `openclaw-compact` entry in the hooks heartbeat, and `gbrain doctor` warns when a week of compactions banked nothing.' },
{ since: '0.60.159.0', text: 'Transcript pages now keep every message whole: a message longer than 4,000 characters was cut there, and now continues in the next block under the same speaker. Re-ingesting a transcript or export re-imports the pages that had long messages (and re-extracts their facts if fact extraction is on). Chat connector syncs also keep retrying a conversation that failed until it imports and report `partial` with `unresolved` meanwhile (`gbrain doctor` warns the archive is incomplete). Conversations synced earlier are not repaired on their own: after asking the user, run `gbrain connectors sync <provider> --full` once.' },
// Wave 14 PR3 (GBRA-79); `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
+ { since: '0.60.157.0', text: 'Dream `propose_takes` no longer proposes takes from atom pages (`type: atom`) or from any page the dream cycle wrote and stamped `dream_generated`; the source page an atom was extracted from is still a candidate, so nothing a person wrote stops being graded. New atoms now carry `dream_generated: true`, so facts extraction, the chronicle and transcript discovery skip them like other derived pages. Expect fewer proposals per cycle on brains with many atoms.' },
{ since: '0.60.157.0', text: 'The dream `consolidate` phase no longer merges two facts that differ in a negation, number, date or amount ("Invoice A due Monday" and "Invoice B due Tuesday" stay two facts), and facts without a typed metric now need a 0.95 embedding match (the explicit-duplicate bar) instead of the 0.85 `cycle.consolidate.cluster_threshold`, which keeps governing typed metric facts. Expect fewer takes from untyped event facts. `gbrain dream --phase consolidate --dry-run` lists the clusters it would write under `details.clusters`. Facts an earlier run wrongly merged keep the `valid_until` that run stamped: previous intervals were not retained, so there is no exact undo; `gbrain recall` still returns the facts, and `remember … replaces` records a correction.' },
{ since: '0.60.157.0', text: 'A write tool call (`add_timeline_entry`, `put_page`, `remember`, every tool marked mutating) that names a parameter the tool does not declare is now refused `invalid_params` with nothing written, in every `mcp.strict_params` mode; the suggestion names the submitted key and the declared one (`content` → `detail` on `add_timeline_entry`). Before, the default warn mode committed the row with the misnamed field dropped. Reads keep the warn grace period.' },
{ since: '0.60.157.0', text: 'A `remember` (or any single-fact write) that repeats a fact already stored word for word for the same entity, or with no resolved entity at all, now returns the existing fact (`status: duplicate`) instead of inserting a second row, including on brains without an embedding key; a remote or unattributed caller never dedups against a fact that came from a private source. A write whose entity could not be resolved and fell back to slugifying the name now stores the fact with no entity instead of minting a placeholder entity slug, so the stub guard no longer refuses later writes about that name; search and `recall` still find the fact by its text.' },
diff --git a/src/core/cycle.ts b/src/core/cycle.ts
index 59ba24580b..b6c240d917 100644
--- a/src/core/cycle.ts
+++ b/src/core/cycle.ts
@@ -490,6 +490,12 @@ export interface CycleReport {
export interface CycleOpts {
/** If true, no writes to filesystem or DB. All phases honor this. */
dryRun?: boolean;
+ /**
+ * #6023: caller trust for the consolidate dry-run preview. Only the local
+ * CLI (`remote: false`) sees private fact text in `details.clusters`;
+ * minion handlers and anything else leave it unset (fail-closed).
+ */
+ remote?: boolean;
/** Defaults to ALL_PHASES. Pass a subset for --phase lint etc. */
phases?: CyclePhase[];
/**
@@ -2637,6 +2643,7 @@ export async function runCycle(
const { runPhaseConsolidate } = await import('./cycle/phases/consolidate.ts');
const { result, duration_ms } = await racedTimePhase(() => runPhaseConsolidate(engine, {
dryRun,
+ remote: opts.remote,
sourceId: cycleSourceId,
// W0 (Tier-1 #1): wrap the caller hook so this phase ALSO refreshes
// the cycle lock (pre-fix these sites passed the raw — in production
diff --git a/src/core/cycle/extract-atoms.ts b/src/core/cycle/extract-atoms.ts
index f0c55192ea..d49b60b8d2 100644
--- a/src/core/cycle/extract-atoms.ts
+++ b/src/core/cycle/extract-atoms.ts
@@ -1252,6 +1252,7 @@ export async function runPhaseExtractAtoms(
...(atom.emotional_register && { emotional_register: atom.emotional_register }),
extracted_at: new Date().toISOString(),
extracted_by: 'extract_atoms-v0.41.2.1',
+ dream_generated: true, // #5211: the flag every anti-loop guard keys on
},
atom.body,
'',
diff --git a/src/core/cycle/propose-takes.ts b/src/core/cycle/propose-takes.ts
index ef410f7ee9..993ac91c74 100644
--- a/src/core/cycle/propose-takes.ts
+++ b/src/core/cycle/propose-takes.ts
@@ -55,6 +55,8 @@ import { GBrainError } from '../types.ts';
import { isConfigTruthy } from '../config.ts';
import { matchingCloseBracket } from '../llm-json.ts';
import { TAKE_KIND_VALUES } from '../takes-fence.ts';
+import { attributionChecksEnabled } from './attribution-checks.ts';
+import { downgradeAssistantOnlyHolders } from './propose-takes-attribution.ts';
import type { OperationContext } from '../operations.ts';
import type { BrainEngine } from '../engine.ts';
import type { PhaseStatus, CyclePhase } from '../cycle.ts';
@@ -296,6 +298,8 @@ async function listCandidatePages(
const where = [
'deleted_at IS NULL',
"type IS DISTINCT FROM 'extract_receipt'",
+ // #5211: an atom is a fragment of a page that is itself a candidate; a legacy atom carries no writer stamp.
+ "type IS DISTINCT FROM 'atom'",
// #5212: never propose takes from the dream cycle's own output.
"COALESCE(frontmatter->>'dream_generated', '') <> 'true'",
"COALESCE(frontmatter->>'extracted_by', '') NOT LIKE 'extract_atoms%'",
@@ -756,7 +760,7 @@ class ProposeTakesPhase extends BaseCyclePhase {
}
const extractor = opts.extractor ?? defaultExtractor;
- const { attributionRules, dateGrounding } = await takesPromptFlags(engine);
+ const [{ attributionRules, dateGrounding }, attributionChecks] = await Promise.all([takesPromptFlags(engine), attributionChecksEnabled(engine)]);
const promptVersion = opts.promptVersion ?? `${PROPOSE_TAKES_PROMPT_VERSION}${attributionRules ? PROPOSE_TAKES_ATTRIBUTION_PROMPT_SUFFIX : ''}`;
const pageLimit = opts.pageLimit ?? 100;
const skipPagesWithFence = opts.skipPagesWithFence ?? false;
@@ -1000,6 +1004,7 @@ class ProposeTakesPhase extends BaseCyclePhase {
}
result.llm_calls_succeeded += 1;
llmHalt.reset();
+ if (attributionChecks) proposals = downgradeAssistantOnlyHolders(proposals, body);
// Write proposals to take_proposals. #2138: the idempotency key is
// per-CLAIM — take_proposals_idempotency_idx folds md5(claim_text) into
diff --git a/src/core/cycle/synthesize-postprocess.ts b/src/core/cycle/synthesize-postprocess.ts
index f9cfdf9568..1e8585ad5f 100644
--- a/src/core/cycle/synthesize-postprocess.ts
+++ b/src/core/cycle/synthesize-postprocess.ts
@@ -16,6 +16,7 @@ import type { DiscoveredTranscript } from './transcript-discovery.ts';
import { transcriptDerivation } from './dream-taint.ts';
import { declareDerivation, readDerivationDeclaration } from '../trust/taint.ts';
import { emptyQuoteVerifyStats, groundSource, isDreamOwnedPage, resolveVerifyPrior, verifyDreamPage, type GroundedSource, type GroundingPass } from './synthesize-verify.ts';
+import { attributionChecksEnabled } from './attribution-checks.ts';
interface OutputRef { slug: string; source_id: string; raw_source?: string; seat?: string; first_write_at?: Date; }
interface RetainedOutput { job_id: number | bigint; job_key: string; request: WriteRequest; }
@@ -62,6 +63,7 @@ export async function postprocessManagedSynthesis(
let pending = 0;
if (!refs.length) return { writtenRefs, finalizedRefs, stats, pending, conflicts };
const reported = await readReportedConflicts(engine);
+ const supersession = opts.quoteVerify ? await attributionChecksEnabled(engine) : false; // #5425 [UC4], default off
const outputs = await engine.executeRaw<RetainedOutput>(
`SELECT t.job_id,j.idempotency_key AS job_key,row_to_json(p) AS request
FROM subagent_tool_executions t JOIN minion_jobs j ON j.id=t.job_id
@@ -147,7 +149,7 @@ export async function postprocessManagedSynthesis(
else {
if (prior) stats.preexisting_diffed++;
const source = grounded?.path === transcript.filePath ? grounded : (grounded = groundSource(transcript.filePath, transcript.content));
- const mechanical = verifyDreamPage(page, [source], { prior, checkedAt: opts.cycleDate }, stats);
+ const mechanical = verifyDreamPage(page, [source], { prior, checkedAt: opts.cycleDate, supersession }, stats);
const verified = opts.grounding ? await opts.grounding.apply(mechanical, [source], `page:${ref.source_id}:${ref.slug}`, opts.cycleDate) : mechanical;
if (verified.changed) stats.pages_repaired++;
page = { ...page, compiled_truth: verified.compiled_truth, timeline: verified.timeline, frontmatter: verified.frontmatter as typeof page.frontmatter };
diff --git a/src/core/verbs.ts b/src/core/verbs.ts
index da688fa60b..c0088f18bd 100644
--- a/src/core/verbs.ts
+++ b/src/core/verbs.ts
@@ -517,6 +517,7 @@ export const RESPONSE_SCHEMAS: Record<VerbName, Record<string, unknown>> = {
evidence: { type: 'string', enum: EVIDENCE_ENUM },
create_safety: { type: 'string', enum: CREATE_SAFETY_ENUM },
provenance: { type: 'string', description: 'Origin page slug.' },
+ source_id: { type: 'string', description: 'The source the hit came from (#4830; absent only when a federated read cannot name one).' },
},
},
},
diff --git a/test/extract-atoms-dream-generated-stamp.test.ts b/test/extract-atoms-dream-generated-stamp.test.ts
index 5eb15aa5d7..8160e89444 100644
--- a/test/extract-atoms-dream-generated-stamp.test.ts
+++ b/test/extract-atoms-dream-generated-stamp.test.ts
@@ -6,7 +6,7 @@
//
// The stamp is one additive line in `src/core/cycle/extract-atoms.ts`, a wave
// 13 hot file: the hunk lives in `~/.capy/work/w14/pr3/stack-hunks/` and
-// stacks behind wave 13 PR3 (#6446). Flip `test.todo` to `test` when it lands.
+// landed with wave 13 PR3 (#6446) on master.
//
// Protects: the written atom's frontmatter. Fails when: the write site drops
// the flag. Why not existing coverage: no test reads `dream_generated` off an
@@ -43,7 +43,7 @@ const SOURCE = ['Meeting notes, 12 March.', 'The budget is a ceiling and not a t
.join('\n').padEnd(600, ' .');
describe('extract_atoms stamps its atoms dream_generated (#5211, P3.8)', () => {
- test.todo('P3.8: a written atom carries dream_generated: true next to extracted_by', async () => {
+ test('P3.8: a written atom carries dream_generated: true next to extracted_by', async () => {
await runPhaseExtractAtoms(engine, {
sourceId: 'default',
_transcripts: [{ filePath: '/tmp/dg1.txt', content: SOURCE, contentHash: 'c3'.repeat(8) }],
diff --git a/test/propose-takes-atom-candidates.test.ts b/test/propose-takes-atom-candidates.test.ts
index 374b8908f5..12f70131f8 100644
--- a/test/propose-takes-atom-candidates.test.ts
+++ b/test/propose-takes-atom-candidates.test.ts
@@ -3,9 +3,7 @@
// (`dream_generated`, `extracted_by: extract_atoms…`, `synthesized_by:
// synthesize_concepts…`); the remaining gap is a legacy `type = 'atom'` page
// that carries neither stamp. The one-line `type IS DISTINCT FROM 'atom'` arm
-// is a stack hunk on `src/core/cycle/propose-takes.ts` (wave 13 hot file) in
-// `~/.capy/work/w14/pr3/stack-hunks/`. Flip `test.todo` to `test` when both
-// #6446 and the hunk land.
+// in `src/core/cycle/propose-takes.ts` closes it (landed after #6446 merged).
//
// Protects: the candidate list of `listCandidatePages`. Fails when: an atom,
// a page stamped `dream_generated` or an unstamped legacy atom reaches the
@@ -36,7 +34,7 @@ const put = (slug: string, type: string, frontmatter: Record<string, unknown>) =
});
describe('propose_takes candidate filter excludes atoms and dream output (#5211, P3.8)', () => {
- test.todo('P3.8: a stamped atom, a legacy unstamped atom and a dream_generated page are not candidates; a note is', async () => {
+ test('P3.8: a stamped atom, a legacy unstamped atom and a dream_generated page are not candidates; a note is', async () => {
await put('wiki/essays/thesis', 'analysis', {});
await put('atoms/stamped-claim', 'atom', { dream_generated: true, extracted_by: 'extract_atoms-v0.41.2.1' });
await put('atoms/legacy-claim', 'atom', {});
diff --git a/test/propose-takes-attribution-callsite.test.ts b/test/propose-takes-attribution-callsite.test.ts
index 49049313a3..3ceb48720b 100644
--- a/test/propose-takes-attribution-callsite.test.ts
+++ b/test/propose-takes-attribution-callsite.test.ts
@@ -1,9 +1,7 @@
// #5425 [UC4] (wave 14 PR3 row P3.9): the one call from `propose-takes.ts`
// into `propose-takes-attribution.ts`, behind `dream.attribution_checks`.
-// The call site is a stack hunk on a wave 13 hot file
-// (`~/.capy/work/w14/pr3/stack-hunks/propose-takes.ts.p3.9.patch`, behind
-// #6446); flip `test.todo` to `test` when it lands. The helper itself is
-// pinned by test/propose-takes-attribution.test.ts.
+// The call site landed in `propose-takes.ts` after #6446 merged. The helper
+// itself is pinned by test/propose-takes-attribution.test.ts.
//
// Protects: with the switch on, a person-holder proposal whose numbers only
// assistant turns of the page state is stored with holder `brain`; with the
@@ -44,7 +42,7 @@ describe('propose_takes calls the mechanical holder check (#5425 [UC4], P3.9)',
expect(await storedHolders()).toEqual(['people/alice-example']);
});
- test.todo('P3.9: switch on: an assistant-only person attribution is stored as brain', async () => {
+ test('P3.9: switch on: an assistant-only person attribution is stored as brain', async () => {
await engine.setConfig(ATTRIBUTION_CHECKS_KEY, 'true');
expect(await storedHolders()).toEqual(['brain']);
});