feat(memory): procedural derived-stats compat helper + shadow-read drift#38
Merged
stackbilt-admin merged 1 commit intomainfrom Apr 24, 2026
Merged
feat(memory): procedural derived-stats compat helper + shadow-read drift#38stackbilt-admin merged 1 commit intomainfrom
stackbilt-admin merged 1 commit intomainfrom
Conversation
…ift (closes #30) Moves the aegis#564 Phase 2 compat helper down from the daemon into core so the public /procedures + /dashboard readers actually exercise it. Daemon's shadowed duplicates were dead code (core mounts first in Hono), so drift samples only came from the router hot path at 10% sampling — effectively blinding the Phase 3 readiness gauge. ## Added - `episodic_memory.complexity_tier TEXT` column (aegis#563 prerequisite — the compat helper queries by it) - `shadow_read_drift` table + index — Phase 2 drift log - `getEpisodeStatsByComplexity`, `getAllEpisodeStatsByComplexity`, `EpisodeStatsAggregate` in `kernel/memory/episodic.ts` - `DriftLogOpts`, `getProcedureWithDerivedStats`, `getAllProceduresWithDerivedStats` in `kernel/memory/procedural.ts` (plus internal `logDriftSingle` / `logDriftBulk` / helpers) ## Swapped - `dashboard.ts` → `getAllProceduresWithDerivedStats(db, { reader: 'dashboard' })` - `routes/observability.ts /procedures` → `getAllProceduresWithDerivedStats(c.env.DB, { reader: 'observability' })` ## Scope note This picks up a slice of aegis#563 as prerequisite — only the `complexity_tier` column on `episodic_memory`, which the compat helper queries. Other aegis#563 columns (`executor_config`, `court_card`) are not touched here; they can land independently if needed. Not in scope. ## Generic-library delta from daemon Dropped daemon's `DERIVED_CUTOFF = '2026-04-22'` date guard. That cutoff is daemon-specific (when its migration ran); core is generic and any other consumer migrates on a different day. Rows with `complexity_tier IS NOT NULL` are treated as derivable; consumers wanting stricter protection against retroactive backfills can wrap with their own time filter. ## Test plan - [x] Core typecheck: clean - [x] Core tests: 1474 passed, 1 skipped (observability.test.ts mock updated to match new export) - [x] Daemon typecheck against this branch: clean - [ ] Consumers need to rerun `schema.sql` — adds one column + one table - [ ] Daemon follow-up PR: collapse `dashboard.ts` shadow + remove v2.1.6 `drift-probe` cron workaround Refs: aegis#564 Phase 2, aegis#563 (prereq), aegis-oss#35 Resolves-Request: aegis-oss#30
f55078f to
9864728
Compare
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
Moves the aegis#564 Phase 2 compat helper down from the daemon into core so public `/procedures` + `/dashboard` readers actually exercise it. Daemon's shadowed duplicates were dead code (Hono first-match-wins, core mounts first), so drift samples only came from the router hot path at 10% sampling — effectively blinding the Phase 3 readiness gauge. Closes #30.
Added
Swapped
Scope note (partial aegis#563)
This picks up a slice of aegis#563 as prerequisite — only the `complexity_tier` column on `episodic_memory`, which the compat helper queries. Other aegis#563 columns (`executor_config`, `court_card`) are not touched here; they can land independently if needed.
Generic-library delta from daemon
Dropped daemon's `DERIVED_CUTOFF = '2026-04-22'` date guard. That cutoff is daemon-specific (when its migration ran); core is generic, any other consumer migrates on a different day. Rows with `complexity_tier IS NOT NULL` are treated as derivable; consumers wanting stricter protection against retroactive backfills can wrap with their own time filter.
Test plan
Refs aegis#564 Phase 2, aegis#563 (prereq), #35