* fix: dream --source/--source-id plumbs sourceId to runCycle (supersedes #1559)
Closes the silent-no-op class where `gbrain dream --source <id>` ran
the cycle but never wrote `last_full_cycle_at`, leaving
`gbrain doctor`'s cycle_freshness check stuck red forever.
Changes to src/commands/dream.ts:
- DreamArgs.source field; parseArgs recognizes --source <id> AND the
--source-id alias (matches v0.37.7.0 #1167 naming across
import/extract/graph-query)
- Argv validation: missing value → exit 2; repeated different values
→ exit 2; --source X --source-id Y conflict → exit 2; same-value
repetition → accepted
- --help short-circuit ordering preserved with IRON-RULE comment +
structural test guard
- runDream engine-null guard: --source requires a connected brain
- runDream resolveSourceId → archived-source guard via fetchSource
from src/core/sources-load.ts (single-row SELECT that projects
archived + handles pre-v0.26.5 schema via isUndefinedColumnError)
- Typed-error try/catch via isResolverUserError predicate: only
swallows known resolver-user errors; TypeError / postgres errors
propagate uncaught with stack trace so genuine programmer bugs
aren't hidden behind operator-error UX
- Forwarded sourceId to runCycle; existing v0.38 writeback at
cycle.ts:1947-1967 now actually fires
- --help text documents both flag names
Tests:
- test/dream-cli-flags.test.ts: structural assertions for new flags,
help text, IRON-RULE comment guard, resolver/predicate wiring
- test/dream.test.ts: 13 PGLite integration cases covering happy
path (the regression that closes PR #1559), back-compat, alias
equivalence, all argv edge cases, engine-null, archived,
--help short-circuit ordering, T3 typed-error propagation, and
D5 end-to-end dream→checkCycleFreshness column-name drift guard
Plan + 11 decisions: ~/.claude/plans/system-instruction-you-are-working-starry-papert.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: judgeSignificance uses canonical safeSplitIndex (closes #1559/#1561 emoji crash)
Closes the 2026-05-24 production SYNTH_PHASE_FAIL: 🤖 (U+1F916,
surrogate pair U+D83E U+DD16) at offset 3999 in a long telegram
transcript made the raw 4000-char slice produce a lone high
surrogate; Anthropic's JSON parser rejected the payload with "no
low surrogate in string"; the synthesize phase failed.
Changes to src/core/cycle/synthesize.ts:
- judgeSignificance head+tail slice routed through safeSplitIndex
from src/core/text-safe.ts (already imported)
- Did NOT introduce safeSliceEnd from PRs #1559+#1561 — that helper
re-introduces the case-3 bug src/core/text-safe.ts:18-21 documents
- Did NOT touch findBoundary — master already routes through
safeSplitIndex per the v0.42.0.0 wave
Tests in test/cycle-synthesize.test.ts:
- New describe('judgeSignificance — UTF-16 safety') block
- test.each over head boundaries (offsets 3998-4001) AND tail
boundaries (offsets 3999-4002) for an 8001-char content with
the robot emoji placed at each
- Primary assertion: explicit unpaired-surrogate scan over the
captured prompt (NOT JSON.stringify per codex C-11 — V8/JSCore
do not throw on lone surrogates, so that assertion was weak)
- Sub-8000 short-content branch case: no slicing, emoji passes
through unchanged
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: expand error_page_title + add cloudflare_challenge_title (supersedes #1561)
Closes the bug class where scraper error pages with titles like
"Forbidden", "Access Denied", "Service Unavailable", "Robot Check",
and "Just a moment..." were slipping through the ingest gate
because the matcher only caught bare numeric codes (403/404/500...)
and "page not found". 232+ pages observed (202+ from straylight-
brain) were inflating page counts and tripping
content_sanity_audit_recent on every doctor run.
Changes to src/core/content-sanity.ts BUILT_IN_JUNK_PATTERNS:
- Expanded error_page_title regex to also catch forbidden,
access denied, service unavailable, robot check, verify you are
human (case-insensitive, anchored — so long-form essays about
these topics still ingest fine)
- New cloudflare_challenge_title pattern with DISTINCT name from
error_page_title (PR #1561 collapsed both into one name and lost
audit signal — the new name preserves diagnosability in
~/.gbrain/audit/content-sanity-YYYY-Www.jsonl and doctor's
content_sanity_audit_recent aggregation)
- Dropped PR #1561's bare-`error` matcher — too aggressive on
legitimate concept/taxonomy pages titled exactly "Error"
Tests:
- test/content-sanity.test.ts: pattern-count locked at 7, new
matches via test.each, over-match regression guard (legitimate
prose titled "How to Handle Access Denied Errors" / "Error
Boundary in React" etc. must pass), audit-name distinctness
pinned
- test/import-file-content-sanity.test.ts: end-to-end
ContentSanityBlockError via importFromContent for each new
pattern family (D6 — assessor wiring coverage, not just regex)
Out of scope, filed in TODOS.md as TODO-V13-C: gbrain pages
audit-junk-titles legacy-cleanup command. Dropped from this PR
per codex outside-voice tension (T1) for ship-and-validate-
matchers-first discipline. The 200+ pre-existing scraper pages
already in the DB will get the destructive-cleanup operator
surface after ~1 week of production observation against this
matcher.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: bump v0.41.23.0 + CHANGELOG + follow-up TODOs
VERSION + package.json bump to 0.41.23.0.
CHANGELOG voice: ELI10 lead naming the bug ("`gbrain dream --source
<id>` finally counts as a cycle"), then per-fix detail, then a
"To take advantage of v0.41.23.0" operator-action block and itemized
changes.
TODOS.md v0.41.23.x follow-ups:
- TODO-V13-A (P2): --max-pages plumbing (PR #1559's flag, deferred
because CycleOpts has no maxPages field today)
- TODO-V13-B (P3): --source vs --source-id flag-name unification
across all CLI commands
- TODO-V13-C (P2): gbrain pages audit-junk-titles legacy cleanup
(deferred for ~1 week of matcher production observation)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: bump v0.41.25.0 → v0.41.26.0 (leave headroom for in-flight PR)
Master shipped v0.41.23.0 + v0.41.24.0 mid-review; this branch
originally bumped to v0.41.25.0 post-merge. User flagged v0.41.26.0
to leave a slot open for another in-flight PR. No code changes;
VERSION + package.json + CHANGELOG header + "To take advantage"
section updated in lockstep.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>