mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-28 14:59:47 +00:00
v0.41 added extract_atoms + synthesize_concepts to ALL_PHASES.
Three existing tests pinned the count at 17 via load-bearing
regression assertions:
test/phase-scope-coverage.test.ts:48-49
expect(ALL_PHASES.length).toBe(17)
expect(Object.keys(PHASE_SCOPE).length).toBe(17)
test/core/cycle.serial.test.ts:393
expect(hookCalls).toBe(17) // yieldBetweenPhases hook fires per phase
test/core/cycle.serial.test.ts:406
expect(report.phases.length).toBe(17)
test/e2e/cycle.test.ts:110
expect(report.phases.length).toBe(17)
These are the correct fix: the assertions exist precisely to catch
this case (a PR that adds a phase without updating downstream
consumers). The wave's v0.41 commit (T9) updated ALL_PHASES but
missed these three sites. Updating them to 19 with comment
breadcrumbs preserving the version history (v0.26.5 → 9,
v0.29 → 10, v0.31 → 11, v0.32.2 → 12, v0.33.3 → 13,
v0.36.1.0 → 16, v0.39.0.0 → 17, v0.41.0.0 → 19).
Without this fix: full unit test suite (`bun run test`) shows 3
failures from these assertions. Underlying v0.41 logic was already
green; this is pure pin-bumping.
After fix: 9059 unit tests pass. 0 actual test failures. (3 shard
wedges remain from unrelated long-running parallel-runner tests
that exceed the 600s per-shard cap — infra concern, not test
logic, pre-dates this wave.)
Plan: ~/.claude/plans/system-instruction-you-are-working-toasty-milner.md
Wave gate: all 13 plan tasks done; all v0.41 tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
/**
|
|
* v0.38 PHASE_SCOPE coverage regression.
|
|
*
|
|
* The phase-scope taxonomy in `src/core/cycle.ts` is documentation, not
|
|
* runtime enforcement (deferred TODO per plan). This test guards the
|
|
* static contract:
|
|
*
|
|
* 1. Every `ALL_PHASES` entry has a `PHASE_SCOPE` entry. New phases
|
|
* added without taxonomy declaration fail this test.
|
|
* 2. No extra `PHASE_SCOPE` entries beyond `ALL_PHASES`. Stale entries
|
|
* from removed phases fail this test.
|
|
* 3. Every value is one of 'source' | 'global' | 'mixed' (type check).
|
|
*
|
|
* Future fan-out wave consumes PHASE_SCOPE directly; this test makes
|
|
* the contract enforceable at the unit-test layer.
|
|
*/
|
|
import { describe, test, expect } from 'bun:test';
|
|
import { ALL_PHASES, PHASE_SCOPE, type PhaseScope } from '../src/core/cycle.ts';
|
|
|
|
const VALID_SCOPES: ReadonlyArray<PhaseScope> = ['source', 'global', 'mixed'];
|
|
|
|
describe('PHASE_SCOPE coverage', () => {
|
|
test('every ALL_PHASES entry has a PHASE_SCOPE entry', () => {
|
|
const missing = ALL_PHASES.filter(p => !(p in PHASE_SCOPE));
|
|
expect(missing).toEqual([]);
|
|
});
|
|
|
|
test('no extra PHASE_SCOPE entries beyond ALL_PHASES', () => {
|
|
const all = new Set<string>(ALL_PHASES);
|
|
const extra = Object.keys(PHASE_SCOPE).filter(p => !all.has(p));
|
|
expect(extra).toEqual([]);
|
|
});
|
|
|
|
test('every PHASE_SCOPE value is source | global | mixed', () => {
|
|
const invalid: string[] = [];
|
|
for (const [phase, scope] of Object.entries(PHASE_SCOPE)) {
|
|
if (!VALID_SCOPES.includes(scope)) {
|
|
invalid.push(`${phase}: ${scope}`);
|
|
}
|
|
}
|
|
expect(invalid).toEqual([]);
|
|
});
|
|
|
|
test('all 19 phases covered (regression on accidental omission)', () => {
|
|
// Pin the count so a future PR that adds a phase to ALL_PHASES
|
|
// without updating PHASE_SCOPE notices here too. The v0.39.1.0
|
|
// master merge brought in the 17th phase (`schema-suggest`); v0.41
|
|
// adds 'extract_atoms' + 'synthesize_concepts' for a total of 19.
|
|
expect(ALL_PHASES.length).toBe(19);
|
|
expect(Object.keys(PHASE_SCOPE).length).toBe(19);
|
|
});
|
|
|
|
test('embed remains global (the headline brain-wide phase)', () => {
|
|
// Pin embed specifically — codex r1 P0-1 called this out as the
|
|
// canonical reason per-source locks aren't sufficient for true
|
|
// fan-out. If future code makes embed source-scopable, this fails
|
|
// and forces a corresponding lift in the fan-out wave.
|
|
expect(PHASE_SCOPE.embed).toBe('global');
|
|
});
|
|
|
|
test('sync remains source-scoped (the headline per-source phase)', () => {
|
|
expect(PHASE_SCOPE.sync).toBe('source');
|
|
});
|
|
});
|