Task #463 Stage 7 prototype: brain-schemas re-exports from @unified-ai-brain/core#28
Draft
ClawDAOBot wants to merge 3 commits into
Draft
Task #463 Stage 7 prototype: brain-schemas re-exports from @unified-ai-brain/core#28ClawDAOBot wants to merge 3 commits into
ClawDAOBot wants to merge 3 commits into
Conversation
…05 #511 BLIND-SPOT 1 with green tests) test/lib/should-i-claim-escalation.test.ts (NEW, 7 tests): - Pure-function `detect3AgentNoEscalation` reference impl + 7 scenarios covering the desired DETECTION behavior per HB#607 proposal - Scenarios: 1. 3-of-3 over 3 HBs → shouldEscalate=true 2. 2-of-3 → shouldEscalate=false 3. Same agent twice does not count 4. Different task IDs don't cross-contaminate 5. Stale lessons (outside cycle window) don't count 6. Existing escalation lesson suppresses re-escalation (anti-spam) 7. Non-fleet author no-lesson does not count Test fixture is implementation-agnostic — when actual impl lands in .claude/skills/poa-agent-heartbeat/SKILL.md Step 1.6 OR a future src/lib/should-i-claim-escalation.ts module, these tests transfer directly. Per RULE #21 + RULE #22: writing tests-first while implementation peer-poll resolves; reduces design rework risk + makes the proposal concrete. 7/7 pass; total suite 840+/840+ green (no regressions). Per HB#607 proposal that's awaiting argus + sentinel ack on Q1 + Q2. Per RULE #21 silence threshold: 2-HB silence by HB#609 = ~30 min from HB#607 poll = approximately now. Tests-first ships independently; modifier-wiring on heartbeat skill waits for ack OR silence-default.
… from @unified-ai-brain/core Replaces src/lib/brain-schemas.ts inline validateBrainDocShape with a thin re-export from @unified-ai-brain/core. First module rewired per the EXTRACTION_PLAN.md "First module to rewire" suggestion. package.json: adds @unified-ai-brain/core via file:/tmp/uab/packages/core. This is the dep-strategy Option C from the original Stage 7 plan (machine-local file: dep). It's not committable to a release-quality package.json but proves the rewire mechanically works on every platform where /tmp/uab is present. Stage 8 swaps the file: dep for a versioned semver dep once npm publish lands. src/lib/brain-schemas.ts: was 439 LoC; now 24 LoC of explanatory comment + re-export. Original preserved at brain-schemas.ts.preStage7-backup for reference + rollback during the transition. Sync-first-then-rewire (per the HB#979 drift discovery + ClawDAOBot/ unified-ai-brain PR #1 merge): @unified-ai-brain/core schemas.ts now includes the causedBy + delegateTo validation that #509 + #510 added to poa-cli. Local schema tests (8 causedBy + 9 delegateTo = 17) all pass against the upstream implementation. Full poa-cli suite remains green: 840 tests, 0 failures. Live brain CRDT smoke (brain append-lesson with causedBy through the rewired path): writes correctly, schema validation accepts the new field via the upstream validator, lesson propagates via the daemon unchanged. Sync discipline going forward: any new optional field added to brain lessons (next: maybe expectedOutput from the #504 borrow Top-5 #3, or the v2 reducer-typed merge from candidate #5) MUST be back-ported to @unified-ai-brain/core FIRST, version bumped, then poa-cli's dep updated. Otherwise the upstream will reject lessons with the new field silently — exactly the drift this Stage 7 rewire formalizes against. Per Hudson HB#972 directive (don't wait): self-merged unified-ai-brain PR #1 (ClawDAOBot owns the repo) to unblock this rewire. The file:-vs-published dep choice remains Hudson-influenced (npm publish needs his org access for the @unified-ai-brain/* scope), but the rewire mechanics are now proven sentinel-actionable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s CLI (Hudson HB#610 directive — signal-detected coasting, not prose-detected) Hudson directive: "look more into hermes... review brain infra... see what's causing coasting... improve infra... metrics to reflect on... continual process... don't over-engineer." Two minimal-friction additions, both reversible per RULE #22: 1. .claude/skills/poa-agent-heartbeat/SKILL.md — appended deliverable-type menu (~30 lines) under existing "Pacing" section: - 7-item typed menu: vote / review / task-ship / brain-lesson / vigil-lens-audit / external-research / infra-improvement - Track 2 picks ≥1 from menu, names type explicitly in HB log - Anti-pattern flagged: brain-lesson as rationalization escape-hatch (3+ consecutive brain-lesson-only HBs = monitoring drift wearing typed-deliverable hat) - Healthy mix: ≥1 task-ship/vigil-audit/external-research/infra- improvement per ~3 HBs 2. src/commands/agent/self-metrics.ts (NEW, ~210 LoC) — opt-in read-only CLI: - Parses heartbeat-log.md by ## HB#N headers - Classifies each HB block via regex patterns into deliverable types - Computes: * output_per_hb_last_10 (target ≥2; healthy ≥3) * deliverable_type_mix_last_20 (% HBs per type) * coasting_flag (3+ consecutive HBs without substantive deliverable) * active_arcs (multi-HB threads) * goals_touched_pct (% of goals.md priorities mentioned last 20 HBs) - JSON + human-readable output src/commands/agent/index.ts — registers `pop agent self-metrics`. EMPIRICAL FIRST RUN (vigil state HB#610): - Output/HB last 10: 1.70 (BELOW target 2; metric detected real signal) - brain-lesson 70% (HIGH; near anti-pattern threshold; useful warning) - task-ship 65%, infra-improvement 60%, vigil-lens-audit 35% - coasting_flag: NO (last 3 HBs had substantive output) - active_arcs: 6 detected (Hermes, audit-series, bridge-saga, #441, #513, #509) - goals_touched_pct: 0% (regex bug; goals.md format not matched — documented as v2 fix-up) Anti-over-engineering guards: - BOTH changes are read-only or appendable; neither breaks existing flow - self-metrics is opt-in (run when you want); not auto-injected anywhere - Deferred 3 candidates (multi-HB arc state machine, forced-handoff, sprint-freshness checker) until metrics show which actually drift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 7 of the Task #463 brain-layer extraction (Sprint 18 vision). This PR proves the rewire mechanics work end-to-end: poa-cli's local
validateBrainDocShapeis replaced with a thin re-export from@unified-ai-brain/core, which now lives in the standalone ClawDAOBot/unified-ai-brain repo.This is a prototype PR, not for merge as-is. The
file:dep approach is non-committable to a release-quality package.json (machine-specific path); merging this would break CI on any machine without/tmp/uabpresent. The PR exists to surface the rewire mechanics for review + invite peer-poll on the dep-strategy choice for Stage 8.What this PR does
package.jsonadds@unified-ai-brain/coreasfile:/tmp/uab/packages/core. Resolves to the locally-cloned + built core package.src/lib/brain-schemas.tsshrinks from 439 LoC to 24 LoC. The body becomes a thin re-export from@unified-ai-brain/core. Every existing import (including the dynamicawait import('./brain-schemas')calls in src/lib/brain.ts) keeps working unchanged.src/lib/brain-schemas.ts.preStage7-backuppreserves the original implementation for reference + rollback during the dep-strategy transition.What was discovered along the way
A real schema drift between poa-cli's local brain-schemas.ts and the upstream @unified-ai-brain/core/src/schemas.ts:
causedByfield validation (Task #509, sentinel HB#963)delegateTofield validation (Task #510, sentinel HB#965)Because poa-cli kept evolving brain-schemas.ts AFTER the Stage 1-6.5 extraction without back-porting changes upstream, the two had drifted. Rewiring poa-cli to import from upstream right now would silently break causedBy + delegateTo validation — the upstream version would reject lessons with these fields as schema violations.
Fix shipped in ClawDAOBot/unified-ai-brain PR #1 (merged): back-ports both validation paths with passing tests.
Generalized rule: any brain-lesson optional field added to poa-cli post-Stage-7 must be back-ported to
@unified-ai-brain/coreFIRST, version bumped, then dep updated here. Otherwise upstream silently rejects.Verification
yarn build: cleanyarn test test/lib/brain-causedby.test.ts test/lib/brain-delegateto.test.ts: 17/17 passyarn test(full): 840/840 pass, 0 regressionspop brain append-lesson --caused-by ...writes through the rewired path; validation accepts the new field via the upstream validator; lesson propagates via the daemonStage 8 dep-strategy decision (open question for Hudson)
The
file:dep approach is sentinel-actionable but not committable. Three options for Stage 8:@unified-ai-brain/*org registered on npm; ClawDAOBot has publish access. Sentinel bumps version +npm publish+ commits the^0.1.0semver dep.poa-cliaddsunified-ai-brainas a submodule pointing at a specific commit, no npm dep needed.file:for development; switch to A or B before any release.My lean: A (cleanest long-term). Hudson's call on whether to register the npm org now or defer.
Forward direction
If Stage 8 goes Option A (npm publish): rebase this branch + swap
file:for^0.1.0+ merge. CI works on every machine.If Stage 8 goes Option B: rebase + swap to submodule path + merge.
If Stage 8 deferred: this PR stays draft as the proof-of-concept; Stage 7 first-module-rewire mechanics are validated for the next person to pick up when Stage 8 unblocks.
What's NOT in this PR
brain-schemas.ts.preStage7-backupfile (kept as rollback safety net during transition)🤖 Generated with Claude Code