Skip to content

feat: hibernation_score + activation_condition columns (#196 storage half) - #282

Merged
robotrocketscience merged 1 commit into
mainfrom
feat/issue-196-hibernation-activation
Apr 29, 2026
Merged

feat: hibernation_score + activation_condition columns (#196 storage half)#282
robotrocketscience merged 1 commit into
mainfrom
feat/issue-196-hibernation-activation

Conversation

@robotrocketscience

Copy link
Copy Markdown
Owner

Refs #196 — does not close it. Substrate decision is ratified (Option B); issue stays open until hibernation behavior also ships.

This PR is the storage half only.

What lands

  • beliefs.hibernation_score REAL (nullable) and beliefs.activation_condition TEXT (nullable, JSON-encoded when set), per docs/substrate_decision.md ratification asks ci: history-scan should see all branches #3 (hibernation: yes) and feat: add Belief/Edge dataclasses and config module #4 (predicate language: JSON).
  • Idempotent ALTER TABLE … ADD COLUMN for both, inserted into the existing _MIGRATIONS tuple. Legacy DBs gain the columns on next open; existing rows return NULL.
  • Belief.hibernation_score: float | None = None and Belief.activation_condition: str | None = None. Defaults preserve every existing call site.
  • insert_belief writes the new fields. _row_to_belief reads them. get_belief and get_belief_by_content_hash both surface them (verified by test).

What does NOT land

  • Hibernation lifecycle behavior — when to set hibernation_score, what wakes a belief, the predicate evaluator. That's a follow-up issue. The columns are nullable precisely so this PR doesn't pin behavior down.
  • Any retrieval-path consumer of these fields. Locked beliefs / scoring / wonder are untouched.

Tests

tests/test_hibernation_columns.py (5 tests):

  • defaults are NULL on a fresh insert
  • non-null round-trip (hibernation_score=0.42, JSON activation_condition)
  • 0.0 / 1.0 boundary values
  • get_belief_by_content_hash returns the new fields
  • pre-v2.0 substrate decision: multi-axis vs single-axis uncertainty #196 legacy DB (raw sqlite, only v1.2 column set) gains the columns on next MemoryStore open; second open is idempotent; legacy rows return NULL

Full suite: 1833 passed, 8 skipped.

Why this size

Per Kulili session triage (2026-04-29): the substrate_decision.md ratification recommended hibernation but didn't spec the behavior. Splitting the column add (mechanical) from the behavior (queen-scoped) lets downstream issues — #195 (already merged scalar uncertainty_score), wonder/reason ports — depend on the column shape without waiting for the behavior debate to close.

…#196)

Storage half of the v2.0 hibernation lifecycle ratified in
docs/substrate_decision.md. Both columns nullable; `None` means the
belief is active. activation_condition is JSON-encoded TEXT (predicate
language locked in at ratification ask #4).

Behavior — when to set hibernation_score, the predicate evaluator,
sweeper integration — is intentionally deferred to a follow-up issue.
This commit is round-trip only: schema, idempotent ALTER for legacy
DBs, Belief dataclass fields, insert_belief/_row_to_belief plumbing,
and tests covering default-NULL, round-trip, get_belief_by_content_hash,
and legacy-DB migration idempotency.
@robotrocketscience robotrocketscience added the author-Kulili PR coordination mutex label Apr 29, 2026
@robotrocketscience
robotrocketscience merged commit ceb67bd into main Apr 29, 2026
8 checks passed
@robotrocketscience
robotrocketscience deleted the feat/issue-196-hibernation-activation branch April 29, 2026 01:41
robotrocketscience added a commit that referenced this pull request Apr 29, 2026
## Summary

Spec memo for the v2.0 #196 behavior half. Storage half (PR #282) added
the columns; this memo proposes the rules that consume them. **Doc-only
— no code change. Posted for ratification.**

Three open questions resolved:

1. **Trigger.** Candidate A: conjunction of *unlocked +
retrieved-and-cold (30d) + demotion_pressure ≥ 1 + posterior_mean <
0.6*. The conjunction is what keeps it safe — old-and-quiet beliefs
(probably true, just off-topic) don't hibernate; new beliefs (α=β=1.0,
posterior 0.5) don't hibernate (no last_retrieved_at);
user-flagged-wrong beliefs go through deletion, not hibernation.
2. **Predicate grammar.** Closed three-clause JSON object:
\`keywords_any\` (substring match), \`source_kind\` (equality),
\`after_ts\` (ISO-8601). Implicit AND, no nesting, no expressions.
Widening is additive; narrowing later would break beliefs in the wild.
3. **Sweeper.** New \`aelfrice.hibernation\` module. \`score_pass\`
invoked from \`aelf doctor --hibernate\` (opt-in in v2.0); \`wake_pass\`
runs automatically on \`UserPromptSubmit\` before the L0/L1/L2.5 search
so woken beliefs are eligible same-turn. Hibernated beliefs filter out
of L1/L2.5 retrieval; locked beliefs cannot hibernate.

## Decision asks (four)

Bottom of the memo. Trigger conjunction shape, grammar closure, sweeper
placement, retrieval-filter semantics.

## What ships if ratified

Three follow-up PRs:

1. \`aelfrice.hibernation\` module (pure functions + pytest coverage).
2. Doctor flag + retrieval filter + hook \`wake_pass\` invocation.
3. \`LIMITATIONS.md\` / \`PHILOSOPHY.md\` / README updates.

## Test plan
- [x] Memo cross-references substrate_decision.md and PR #282
- [x] No code change; nothing to test
- [ ] Ratification or override comment from maintainer

Refs #196
yoshi280 pushed a commit that referenced this pull request May 15, 2026
The hibernation_lifecycle memo describes a trigger / predicate-grammar
/ sweeper design that has never been implemented. Storage half (#196
/ PR #282 — hibernation_score + activation_condition columns) sits
unused on github/main; no scorer populates the score column, no
list_hibernated / hibernate_eligible function exists, and the original
trigger spec keyed off demotion_pressure which was removed by #814 /
PR #820.

Operator decision on #825 (option A): rewrite the doc to current
reality rather than implement the eligibility surface (option B) or
delete the file (option C).

Changes:
- Rewrite Status section with an UNIMPLEMENTED banner that names the
  empty src/ surface and points at the column-only state.
- Replace the SQL block in Candidate A with a paragraph noting that
  the original demotion_pressure-based trigger no longer applies and
  no replacement signal has been chosen.
- Update the Decision ask to mark ratification as deferred until an
  implementation pass is scheduled.
- Drop the TODO(#825) marker that PR #824 left behind; this commit
  IS the disposition.

Net effect: the memo no longer claims any behavior that exists in
src/; remaining references to demotion_pressure are historical context
explaining why each section is unimplemented, not claims about
current behavior.

Closes #825.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-Kulili PR coordination mutex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant