mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-27 22:15:33 +00:00
814258dda67945ffec9457a1e73980e947b7e462
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c2ae4dbfc5 |
v0.25.1 feat: book-mirror flagship + 8 research skills + skillpack uninstall + post-install advisory (#566)
* v0.25.1 foundation: scaffolds + manifests + filing-doctrine update
Foundation commit for v0.25.1 skills wave (book-mirror flagship + 8 research
pairings). All content is scaffold-stage; subsequent commits port wintermute
SKILL.md content into pure gbrain idiom.
Version bumps:
- VERSION 0.24.0 -> 0.25.1
- package.json: version + engines.bun >= 1.3.10 (D14 PTY harness)
- openclaw.plugin.json inner version 0.19.0 -> 0.25.1
- bun.lock refreshed
9 skill scaffolds via `gbrain skillify scaffold` (frontmatter + RESOLVER row +
routing-eval seed): book-mirror, article-enrichment, strategic-reading,
concept-synthesis, perplexity-research, archive-crawler, academic-verify,
brain-pdf, voice-note-ingest. Stub .mjs scripts and stub .test.ts files
deleted; these are pure-markdown skills, not deterministic-script skills.
Real tests will return when src/commands/book-mirror.ts and the other
runtime pieces land.
skills/manifest.json + openclaw.plugin.json skills[]: 9 new entries
(codex T6 fix; required by test/skillpack-sync-guard.test.ts).
D13 filing-doctrine update:
- skills/_brain-filing-rules.md: carve out media/<format>/<slug> as a
sanctioned exception for sui-generis synthesized output.
- skills/_brain-filing-rules.json: add media/books/ and media/articles/
as `synthesis-output` kind, distinct from raw-ingest filing.
- skills/media-ingest/SKILL.md: refine anti-pattern callout to clarify
that format-prefixed paths are anti-pattern for raw ingest only,
sanctioned for one-of-one synthesis.
Privacy guard hardening (codex T7):
- scripts/check-privacy.sh: extended for /data/brain/ and
/data/.openclaw/ wintermute-specific path patterns. 7 historical
files allow-listed (frozen migrations, test fixtures, env-var
fallbacks). PRIVACY OK passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 book-mirror: trusted CLI with read-only subagent fan-out
Implements `gbrain book-mirror` per the locked v0.25.1 plan (D2/α + codex
HIGH-1 fix). Closes the prompt-injection vector codex flagged on the
earlier `allowedSlugPrefixes: ['media/books/*', 'people/*']` design by
narrowing the trust contract at the tool-allowlist layer instead.
Trust contract:
- Each chapter is analyzed by a separate subagent with allowed_tools
restricted to ['get_page', 'search'] — read-only. Subagents cannot
call put_page or any mutating op. Untrusted EPUB/PDF content cannot
prompt-inject any people/* page because subagents lack write access
entirely.
- Subagents return markdown analysis text via final_message
(SubagentResult.result). The CLI reads each child's job.result and
assembles the final two-column page itself.
- The CLI calls put_page once at the end with operator-level trust
(no viaSubagent flag, no allowedSlugPrefixes). Operator can write
anywhere; the namespace check doesn't fire for direct CLI calls.
Architecture:
- `--chapters-dir` is the input contract. The skill (which has shell +
python access) handles EPUB/PDF extraction; the CLI takes pre-extracted
.txt files. Separation of concerns: skill prepares inputs, CLI is the
trusted runtime.
- Cost-estimate prompt before launching: ~$0.30/chapter × N at Opus,
~$0.06/chapter at Sonnet. Refuses to spend in non-TTY without --yes.
- Idempotency keys on each child: `book-mirror:<slug>:ch-<N>`. Re-running
on same input dedups against the queue; failed chapters retry.
- Partial-failure handling: assembled page renders with completed
chapters and a `## Failed chapters` section listing retries needed.
Exit 1 on any failure; exit 0 only on full success.
- 30-min default per-child timeout (override with --timeout-ms).
CLI wiring:
- `book-mirror` added to CLI_ONLY set in src/cli.ts.
- Lazy-imports src/commands/book-mirror.ts to keep cold-start fast.
Out of scope for this commit (filed for v0.25.1 follow-ons):
- skills/book-mirror/SKILL.md content port (replaces the foundation
scaffold stub).
- test/book-mirror.test.ts (will test arg parsing, validation, mock
fan-out, cost-estimate gating, partial-failure assembly).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 book-mirror: port SKILL.md content + routing-eval
Replaces the foundation scaffold stub with the full ported book-mirror
SKILL.md, pointing the agent at the new `gbrain book-mirror` CLI as the
trusted runtime.
skills/book-mirror/SKILL.md:
- Drops wintermute_only frontmatter; uses gbrain frontmatter shape
(mutating + writes_pages + writes_to: media/books/).
- Documents the trust contract: subagents are read-only, the CLI does
the put_page write itself with operator trust. Closes the codex
HIGH-1 prompt-injection vector at the tool-allowlist layer.
- Replaces /data/brain/ absolute paths with $BRAIN_DIR resolution from
gbrain config.
- Replaces brain-commit-link.sh / direct shell-script writes with the
CLI's single put_page call.
- Documents EPUB/PDF extraction via the agent's shell + python access
(BeautifulSoup4 for EPUB, pdftotext for PDF). The skill prepares
inputs; the CLI is the trusted runtime.
- Privacy scrub clean — no real names, no /data/brain/, no .openclaw/,
no Wintermute literals.
skills/book-mirror/routing-eval.jsonl:
- 5 paraphrased intents per D-CX-6 rule (intent paraphrases the
trigger, doesn't copy it).
- 3 adversarial intents that pattern-match media-ingest's "process
this book" trigger (IRON RULE regression test for the
media-ingest <-> book-mirror routing conflict flagged in R1+R2).
These assert that book-mirror should NOT win on generic ingest
phrasing.
skills/_brain-filing-rules.json: 4 new directory kinds added so
check-resolvable's filing audit passes for the new skills' writes_to
declarations:
- idea (ideas/) — generative ideas to act on later (voice-note-ingest,
archive-crawler).
- research (research/) — web-research deltas, citation-checked claims
(perplexity-research, academic-verify).
- original (originals/) — user-authored thinking the user originated
(voice-note-ingest, archive-crawler, signal-detector).
- voice-note (voice-notes/) — random-thought audio capture pages
(voice-note-ingest).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 ports: article-enrichment + strategic-reading + voice-note-ingest
Replaces SKILLIFY_STUB scaffolds with content-ported SKILL.md files in
pure gbrain idiom:
skills/article-enrichment/SKILL.md:
- Drops wintermute-specific scripts/enrich-article.mjs reference; the
skill is markdown agent instructions, not a deterministic script
pipeline.
- Replaces /data/brain/ paths with relative brain-dir paths.
- Documents the structured output contract (Executive Summary,
Quotable Lines verbatim, Key Insights, Why It Matters, See Also,
details-block source preservation).
- Sonnet by default, Opus for high-value content.
skills/strategic-reading/SKILL.md:
- Generic problem-lens reading flow (book/article/case study x specific
strategic problem -> applied playbook with do/avoid/watch-for).
- Drops Garry-specific oppo example ("Tyler Law/Han Zou gatekeeper
fight"); uses generic "gatekeeper-vs-incumbent fight" framing.
- Files to projects/<slug>/playbook.md (problem-tied) or
concepts/<slug>.md (general strategy) per primary-subject filing rule.
- Cross-references book-mirror as the whole-life-personalization
counterpart.
skills/voice-note-ingest/SKILL.md:
- Iron Law: exact phrasing preserved, never paraphrased. Block-quoted
transcript is sacred; analysis is interpretive.
- 7-step decision tree (originals -> concepts -> people -> companies
-> ideas -> personal -> voice-notes catch-all) per
_brain-filing-rules.md.
- Replaces wintermute's brain-commit-link.sh + Supabase Storage helper
with gbrain transcription + storage interface (pluggable per
src/core/storage.ts).
Each skill ships routing-eval.jsonl with 5 paraphrased intents per
D-CX-6 (intent paraphrases trigger, doesn't copy it). The literal
"please <trigger> for me now" stubs from gbrain skillify scaffold are
replaced with realistic user phrasings.
Privacy scrub clean — no real names, no /data/brain/, no .openclaw/,
no Wintermute literals.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 ports: concept-synthesis + perplexity-research + brain-pdf
Replaces SKILLIFY_STUB scaffolds with content-ported SKILL.md files in
pure gbrain idiom:
skills/concept-synthesis/SKILL.md:
- 4-phase pipeline: dedup -> tier (T1 Canon to T4 Riff) -> synthesize
T1/T2 -> cluster + intellectual map.
- Generic across any concept-stub source (signal-detector,
voice-note-ingest, idea-ingest, archive-crawler).
- Drops wintermute-specific X-pipeline framing (9051 stubs from x-deep-enrich,
scripts/x-concept-compiler.mjs); skill is markdown agent instructions
using gbrain query + put_page.
- Output format: T1 gets full synthesis with evolution table + best
articulation + related-concepts cross-links; T3/T4 stay as stubs.
- Cluster map at concepts/README.md as the master intellectual fingerprint.
skills/perplexity-research/SKILL.md:
- Brain-augmented web research: sends brain context as part of the
Perplexity prompt so the search focuses on what's NEW vs already-known.
- Output structure: Executive Summary + Key New Developments + Confirming
Signals + Contradictions or Updates + Recommended Brain Updates +
Citations.
- Uses Perplexity sonar-pro by default (~$0.04/query); sonar for bulk.
- Drops wintermute-specific scripts/perplexity-research.mjs and
/data/.env path; documents PERPLEXITY_API_KEY in agent env.
- Cross-references academic-verify (which wraps this skill for
citation-checked claim verification per D7/alpha) and enrich (entity
enrichment loop).
skills/brain-pdf/SKILL.md:
- Documents gstack make-pdf as soft prereq with absent-binary detection.
- 4-step workflow: resolve -> strip frontmatter -> render -> deliver.
- Defaults: NO --cover, NO --toc (look corporate and waste space).
- Mandatory CONTAINER=1 for Playwright sandboxing.
- Anti-pattern callout: never use raw MEDIA: tags for Telegram delivery
(they fail silently); use message tool with filePath= attachment.
Each ships routing-eval.jsonl with 5 paraphrased intents per D-CX-6.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 ports: archive-crawler + academic-verify (final SKILL.md batch)
Replaces the last two SKILLIFY_STUB scaffolds. All 9 new skills now
have ported content; `gbrain check-resolvable` reports zero
skillify_stub_unreplaced warnings.
skills/archive-crawler/SKILL.md (D3 + D12):
- Hard safety gate: refuses to run unless `archive-crawler.scan_paths:`
is set in gbrain.yml. Closes the codex HIGH-4 footgun where 'trust
the prompt' was not a control.
- Schema-generic port (D3 user constraint): no hardcoded era folders
(no archive/, post-stanford/, posterous-era/, initialized-era/,
yc-era/). Reads filing rules from _brain-filing-rules.json at
runtime; agent decides per-page filing within sanctioned dirs.
- Drops wintermute-specific scripts and brain-commit-link.sh; uses
gbrain operations for inventory + put_page for ingest.
- File-type handlers preserved (.mbox, .doc/.docx, .pst, .zip, images)
with the exact same shell + python recipes.
- Manifest tracks per-item triage status + exact user reactions per
conventions/quality.md exact-phrasing rule.
skills/academic-verify/SKILL.md (D4 + D7/alpha):
- Drops ALL the wintermute-specific oppo / adversarial framing: no
Goff/Solomon, no CPE, no '48 Hills', no fabrication-detection,
no 'oppo research where the target relies on academic credentials'.
This is the public skillpack — research-not-adversarial bar.
- Pure-routing implementation per D7/alpha: skill is a thin
orchestrator that scopes the claim, invokes
perplexity-research with citation-mode prompt, and formats results
as a verdict-shaped brain page. Zero new infrastructure.
- 5 verdict states (verified / partial / unverifiable / misattributed
/ retracted) replace the 'fabrication suspected' / 'methodologically
flawed' classifications that read like takedown rubric.
- Documents Retraction Watch / PubPeer / OSF / Semantic Scholar /
OpenAlex / Many Labs as the databases the agent uses via
perplexity-research, but doesn't ship its own API integrations.
Each ports a routing-eval.jsonl with 5 paraphrased intents per D-CX-6.
Privacy scrub clean. typecheck OK. Remaining check-resolvable warnings
are routing_miss on the substring matcher (paraphrased intents don't
exact-match the RESOLVER triggers); the LLM tie-break layer is a
v0.26+ enhancement per CLAUDE.md routing-eval section. Warnings are
advisory, not errors.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 drift backports: citation-fixer + testing + cross-modal-review
Pulls the wintermute drift improvements identified by R1's quick audit
into the public skillpack, in pure gbrain idiom (no real names, no
/data/brain/ paths, no Wintermute literals — privacy guard passes).
skills/citation-fixer/SKILL.md (PORT, version 1.0 -> 1.1):
- Adds tweet/post URL resolution: scans pages for broken tweet
references (no x.com URL) and resolves them via the host's X API
integration.
- 5-step pipeline: identify broken refs -> extract searchable content
(handle/quote/date) -> X API search -> verify + extract metadata
-> patch the page with deterministic URL.
- Batch-mode pattern with priority order (recently changed pages
first), rate-limit guidance (~50 pages/run), batch-commit cadence.
- Integration callout: enrich + media-ingest can call
citation-fixer pre-commit to validate output.
- Anti-pattern: never compose tweet URLs by guessing the id;
deterministic links only (per _output-rules.md).
skills/testing/SKILL.md (PORT, version 1.0 -> 1.1):
- Splits into TWO modes: skill conformance validation (original 1.0
scope) AND project test-suite health (v0.25.1 extension).
- Test tiers: unit (<2s, every commit), evals (~60s, daily),
integration (~5m, pre-ship + nightly), system health (<10s).
- Daily run protocol: unit -> evals -> system -> git diff analysis
for regression intelligence.
- Failure classification: REGRESSION / STALE / FLAKE / NEW / INFRA
with markers (red / yellow / warning / green / wrench).
- Auto-fix protocol: explicit DO and DO NOT lists. Security-test
failures always escalate, never auto-fix.
- State tracking at ~/.gbrain/test-state.json for trend analysis,
flake detection, regression velocity.
skills/cross-modal-review/SKILL.md (PORT, version 1.0 -> 1.1):
- Adds explicit "When to invoke" gating (significant code changes 5+
files / 100+ lines, security-sensitive, architecture, churning,
pre-bulk, skill creation, brain-page quality) vs DO NOT invoke
(simple memory writes, typo fixes, routine cron, post-review
commits).
- Adds code-review handoff section: knows WHEN to recommend gstack's
/codex review (independent diff review from a different AI) and how
to frame the cross-model output.
- Adversarial Challenge sub-mode: red-team prompt for security-
sensitive changes; output adds exploitability rating
(CRITICAL/HIGH/MEDIUM/LOW) + mitigations.
- Iron Law: user-sovereignty rule explicitly captured. Reviewer
findings are informational until the user explicitly approves;
cross-model consensus is signal, not permission.
All three pass scripts/check-privacy.sh (no Wintermute literals, no
/data/brain/, no /data/.openclaw/). typecheck OK.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 skillpack uninstall: D6 + D8 + D11 content-hash guard
Implements `gbrain skillpack uninstall <name>` per the locked
v0.25.1 plan. Inverse of install with symmetric data-loss posture:
refuses if the slug isn't in the managed-block's cumulative-slugs
receipt (D8) or if any installed file diverges from the bundle
original (D11). Same --overwrite-local escape hatch as install.
src/core/skillpack/installer.ts:
- New UninstallError class (mirrors InstallError shape) with codes:
lock_held, bundle_error, target_missing, unknown_skill,
user_added_slug (D8), locally_modified (D11), managed_block_missing.
- New types: UninstallFileOutcome, UninstallFileResult,
UninstallResult, UninstallOptions.
- New applyUninstall() function. Steps:
1. Acquire workspace lockfile (same gate as install).
2. D8 check: read managed block; verify slug is in cumulative-slugs
receipt. If user-added or unknown, throw user_added_slug.
3. Enumerate bundle entries scoped to the skill (NOT shared_deps —
other installed skills depend on them).
4. D11 check: hash each existing target file vs bundle original.
Skip removal for divergent files unless --overwrite-local.
5. Atomic: if ANY file would be skipped due to local-mod and the
user did not pass --overwrite-local, refuse the WHOLE uninstall
(no half-uninstall — would desync managed block from filesystem).
6. Rebuild managed block via applyManagedBlockUninstall() (drops
slug from cumulative-slugs, preserves other rows + user-added
unknown rows with stderr warning, atomic write via writeAtomic).
7. Release lock.
src/commands/skillpack.ts:
- Wire `gbrain skillpack uninstall` subcommand. Flags mirror install:
--dry-run, --overwrite-local, --force-unlock, --skills-dir,
--workspace, --json, --help.
- Exit codes: 0 success, 1 refused due to local-mod (recoverable
with --overwrite-local), 2 setup error (slug not in receipt, no
workspace, lock held, etc.).
- Help text documents the symmetric trust contract explicitly.
D6 test slot is filled (smoke test t2 "uninstall changes routing"
will use this command). Per the plan, no `--all` uninstall in v0.25.1
(scope-narrowing; renaming a skill in the bundle should still be the
install --all path that prunes).
Typecheck passes. Privacy guard passes. `gbrain skillpack uninstall
--help` renders correctly.
Out of scope for this commit (next):
- test/skillpack-uninstall.test.ts (D8 + D11 cases, multi-arg,
fail-loud-under-lock, idempotent-when-absent).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 archive-crawler safety gate (D12 + codex HIGH-4 fix)
Adds the gbrain.yml `archive-crawler.scan_paths:` allow-list contract
that closes the codex HIGH-4 finding. The archive-crawler skill
refuses to run unless the user has explicitly listed paths the agent
is permitted to scan.
src/core/archive-crawler-config.ts (NEW, 263 lines):
- Sibling to storage-config.ts (separate concern: archive scanning,
not storage tiering; same gbrain.yml file shape).
- Hand-rolled parser for the `archive-crawler:` section (mirrors
storage-config's parsing pattern; same trade-off — narrow-but-
predictable, zero-dep).
- Accepts both `archive-crawler:` and `archive_crawler:` spellings.
- ArchiveCrawlerConfig: { scan_paths: string[]; deny_paths: string[] }
— both normalized to absolute trailing-slashed paths.
- Validation:
* scan_paths MUST be non-empty (D12 contract)
* Every path absolute after ~ expansion (rejects relative)
* Path-traversal rejected (`..` literal in path → invalid_path)
* Trailing-slash normalized for unambiguous prefix matching
- isPathAllowed(candidate, config) helper for runtime per-file gate:
prefix-match against scan_paths, deny_paths overrides. Directory-
boundary safe — /writing/ does NOT match /writing-stuff/.
- ArchiveCrawlerConfigError class with discriminated codes:
missing_section / empty_scan_paths / invalid_path / parse_error.
test/archive-crawler-config.test.ts (NEW, 19 tests):
- D12 missing_section gates: null repoPath, missing gbrain.yml, no
archive-crawler section.
- D12 empty_scan_paths: scan_paths omitted or empty array.
- D12 invalid_path: relative path, ".." traversal in scan_paths,
".." traversal in deny_paths.
- Happy path: normalized paths, ~ expansion, deny_paths optional,
both archive-crawler and archive_crawler key spellings.
- Direct API validation (normalizeAndValidateArchiveCrawlerConfig).
- isPathAllowed: scan_path match, scan_path miss, deny_path override,
directory-boundary correctness (writing/ vs writing-stuff/),
relative-path rejection.
19/19 pass in 17ms. Privacy guard passes. Typecheck OK.
The skills/archive-crawler/SKILL.md (already shipped in earlier
commit) documents the contract; this commit lands the runtime
that enforces it. The skill's safety claim is no longer aspirational.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* v0.25.1 PTY harness port from gstack (D14/C-prime)
Ports gstack's claude-pty-runner.ts (~1300 lines) as a generalized
gbrain harness (~470 lines after trimming gstack-specific
orchestrators). Used by the smoke test E2E to drive interactive
openclaw sessions; future: any CLI command that grows interactive
prompts becomes testable without a refactor.
test/helpers/cli-pty-runner.ts (NEW, 470 lines):
- launchPty(opts): generic CLI spawner via Bun.spawn `terminal:` mode.
Drops gstack's launchClaudePty's --permission-mode plan default;
takes any binary + args.
- resolveBinary(name, override?): finds CLI binaries on PATH with
homebrew/local/bun fallbacks.
- stripAnsi: standard CSI + OSC + charset + DEC-special escape
stripping (verbatim port).
- isNumberedOptionListVisible: cursor + numbered list detection.
- parseNumberedOptions: extracts cursor-anchored numbered AUQ options
(1-based indices, sequential block only). Handles cursor-on-non-1
(user pressed Down) and box-layout AUQs (cursor mid-line after
dividers). Reads only last 4KB to avoid matching stale lists.
- optionsSignature: stable hash for "is this AUQ the same as last
poll?" detection.
- isTrustDialogVisible: matches Claude Code's "trust this folder"
dialog so launchPty can auto-handle it.
- PtyOptions / PtySession types + send / sendKey / mark / visibleSince
/ waitFor / waitForAny primitives.
- launchPty internals: terminal: mode, exit tracking, wall-clock
timeout, autoTrust polling watcher (15s window), graceful close
with SIGINT then SIGKILL fallback.
DROPPED from the gstack original (gstack-specific):
- runPlanSkillObservation, runPlanSkillCounting, invokeAndObserve
(Claude-Code plan-mode test orchestrators).
- isPlanReadyVisible, isPermissionDialogVisible (Claude-Code-specific
dialog detection).
- ceoStep0Boundary, engStep0Boundary, designStep0Boundary,
devexStep0Boundary (per-skill /plan-* boundary predicates).
- MODE_RE, COMPLETION_SUMMARY_RE, parseQuestionPrompt, auqFingerprint,
assertReviewReportAtBottom (gstack plan-review specifics).
- classifyVisible (plan-mode outcome classifier).
If the smoke test ever needs Claude-Code-specific dialog detection,
add a thin wrapper in test/e2e/ — keeping the harness generic.
test/cli-pty-runner.test.ts (NEW, 24 tests, all pass):
- stripAnsi: 6 cases (CSI, OSC-BEL, OSC-ST, charset, DEC-special, plain)
- isNumberedOptionListVisible: 4 cases (match, no-cursor, single-opt,
TTY collapsed-whitespace)
- parseNumberedOptions: 7 cases (3-opt, no-list, single-opt, prose-
gating-pattern, gap-truncation, cursor-on-non-1, last-4KB-only)
- optionsSignature: 2 cases (order-independence, label-changes-sig)
- isTrustDialogVisible: 2 cases (canonical phrase, non-match)
- resolveBinary: 3 cases (override, missing, sh-on-path)
24/24 pass in 14ms. Privacy guard passes. Typecheck OK.
Bun version requirement (D14): engines.bun >= 1.3.10 (set in commit
|