feat(gbrain-sync): preamble block — privacy gate + boundary sync

scripts/resolvers/preamble/generate-brain-sync-block.ts emits bash that
runs at every skill invocation:
- Detects ~/.gstack-brain-remote.txt on machines without local .git
  and surfaces a restore-available hint (does NOT auto-run restore).
- Runs gstack-brain-sync --once at skill start to drain any pending
  writes (and at skill end via prose instruction).
- Once-per-day auto-pull (cached via .brain-last-pull) for append-only
  JSONL files.
- Emits BRAIN_SYNC: status line every skill run.

Also emits prose for the host LLM to fire the one-time privacy
stop-gate (full / artifacts-only / off) when gbrain is detected and
gbrain_sync_mode_prompted is false. Wired into preamble.ts composition.
This commit is contained in:
Garry Tan
2026-04-22 13:47:12 -07:00
parent f088fe96f8
commit a2aa8a07d4
2 changed files with 128 additions and 0 deletions

View File

@@ -37,6 +37,9 @@ import { generateWritingStyleMigration } from './preamble/generate-writing-style
// Host-specific instructions
import { generateBrainHealthInstruction } from './preamble/generate-brain-health-instruction';
// GBrain cross-machine sync (runs at skill start; end-side handled in completion-status)
import { generateBrainSyncBlock } from './preamble/generate-brain-sync-block';
// Behavioral / voice
import { generateVoiceDirective } from './preamble/generate-voice-directive';
@@ -84,6 +87,7 @@ export function generatePreamble(ctx: TemplateContext): string {
generateVendoringDeprecation(ctx),
generateSpawnedSessionCheck(),
generateBrainHealthInstruction(ctx),
generateBrainSyncBlock(ctx),
generateModelOverlay(ctx),
generateVoiceDirective(tier),
...(tier >= 2 ? [