Skip to content

Commit 7208eb6

Browse files
docs(plan-integration): item 6 — the two written proposals (D-D, D-E); tick T6.4
Two proposals under docs/architecture/plan-integration/proposals/, no code (HANDOFF §3 item 6). Each quotes the owner's decision verbatim, states what the engine and store do today from the tree at a5b9f90 rather than from the design text, then the proposal, its constraints, what is out of scope, and the acceptance the issue will carry. 2026-09-16-context-derived-plan-bias.md (D-D): replace the single PLAN_RELATED_BIAS = 12 with a derived, bounded bias from three deterministic inputs — today's plan relevance (5a), prerequisite order from list_dependencies' `relation_type == "prerequisite"` edges, which weak_links_for_topic already reads (5b), and per-item energy demand, taking item 5's definition rather than inventing a second (5c). No model call in ranking (unauditable; defeats D-16); an absent edge is no signal; the golden and the three rule-5 pins stay green; the concept-store read is budgeted and measured on a real sessions.db before it ships, as item 4's preview read was. 2026-09-16-overdue-nudge-and-retire.md (D-E): a due row is a study_progress row whose last_seen has reached a REVIEW_INTERVALS step; there is no next_review column and no "not due" state, so a row stays a candidate until studied again, and at 100 + min(days_ago, 30) an unrelated overdue item silently overtakes the +12 plan bias after ~12 days. Proposed: an age-aware nudge line on an unrelated due candidate past a threshold derived from the constants (so it moves with D-D), and learner-issued retire/snooze states on the row through the seam (CLI verb, Today control, one MCP tool — the mirror of record_topic_progress(confidence="resolved"), which today resolves only parked topics). History kept; never inferred from age; excluded from every consumer of spaced_repetition_due (now, recap, `studyloop review`, the plan evaluation); flashcards' SM-2 store is a separate ticket. mkdocs --strict exit 0; the six docs guard modules 211/211 with the new files in place. tasks.md T6.4 ticked; the two issues are item 7 step 4. .gitignore: docs/architecture/plan-integration/* is an allowlist (council/, receipts/, the archify spec, top-level .md); proposals/ was never on it, so the first `git add` was refused. Added in the same shape, Markdown only.
1 parent 87d6739 commit 7208eb6

4 files changed

Lines changed: 229 additions & 2 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ docs/architecture/session-memory/*
530530
docs/architecture/plan-integration/*
531531
!docs/architecture/plan-integration/council/
532532
!docs/architecture/plan-integration/receipts/
533+
# Un-ignored 2026-09-18 — item 6's written proposals (D-D, D-E), Markdown only.
534+
!docs/architecture/plan-integration/proposals/
533535
!docs/architecture/plan-integration/*.architecture.json
534536
!docs/architecture/plan-integration/*.md
535537

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Proposal: a context-derived plan bias (D-D)
2+
3+
**Status:** written proposal, no code (plan-integration follow-on item 6, T6.4). Becomes a
4+
`ready-for-agent` issue at the push step (HANDOFF §3 item 7, step 4). Written 2026-09-18 against
5+
`main` at `a5b9f903`; every code fact below was read from that tree.
6+
7+
## The owner's decision, verbatim
8+
9+
> **D-D** | **F2 → open a ticket, don't park:** a context-derived plan bias (prerequisite edges from the
10+
> concept store via `get_concept_context`, milestone order; per-item energy demand from struggle state)
11+
> — deterministic and rubric-testable. Not an LLM tie-break (unauditable; defeats D-16). Scenario 1's
12+
> "the logical step before" was the first evidence.
13+
>
14+
> — `HANDOFF-2026-09-16.md` §2, owner, 2026-09-16
15+
16+
The evidence it names: rubric row 1 (`receipts/now-rubric-2026-09-16.md`), owner's verdict **yes** with
17+
the line *"window function is the logical step before decorating it"* — a prerequisite-order argument the
18+
engine did not make. The engine ranked the plan-matching due item first because it carried the plan
19+
bias; the owner ranked it first because of what depends on it. Same answer, different reason, and the
20+
reason is the one that generalises.
21+
22+
## What the engine does today (`studyloop/learning/decision.py`)
23+
24+
- **Rule 5, one constant.** `PLAN_RELATED_BIAS = 12`, added to a candidate's score when it carries a
25+
`plan_ref` or its concept/topic keys intersect a matchable plan's keys. The constant is sized to decide
26+
a near-tie *inside one urgency class* and to lose to a clearly more-urgent unrelated candidate
27+
(a struggling repair at +35, an overdue review whose base is `100 + min(days_ago, 30)`): a bias,
28+
never a filter. Review 3 F2 asked whether `now` should grow explicit urgency classes; the council kept
29+
the bias and pinned the constant to today's bands.
30+
- **Rule 3, one floor per plan.** `ENERGY_CAPABILITY = {"low": 3, "medium": 6, "high": 10}` is compared
31+
with the plan's `energy_floor` (1–10); below the floor *new* milestone work is deferred while
32+
plan-related due recall and struggle repair stay eligible, "because repair is cheaper than encoding".
33+
Rubric row 3 (owner: **no**) is the counter-example — a live-struggle repair on a low-energy day —
34+
and is item 5's subject, not this proposal's.
35+
- **Rule 6, milestone order by position.** A synthesised next-milestone candidate is the plan's first
36+
open milestone, base `MILESTONE_BASE_SCORE = 48` plus a target-urgency bonus. Milestone order is the
37+
document's order; nothing reads what a milestone's concepts require.
38+
- **What the concept store already knows.** `learning/mastery.py::list_dependencies(topic)` returns
39+
edges with `source_concept`, `target_concept`, `relation_type`; `weak_links_for_topic` already
40+
consumes `relation_type == "prerequisite"` to name struggling concepts that block downstream ones.
41+
`get_concept_context` (MCP) returns `mastery_graph_json`'s `edges` for a topic, with the same fields,
42+
capped at 32 KiB and explicit that omitted edges cannot support a claim that no alternative exists.
43+
44+
So the ingredients exist and are already read for another purpose; what is missing is a rule that turns
45+
them into a ranking signal for `now`.
46+
47+
## The proposal
48+
49+
Replace the single constant with a **derived bias** computed from three deterministic inputs, each a
50+
rule with its own rubric row. The total stays bounded so the "bias, never a filter" invariant holds:
51+
a clearly more-urgent unrelated candidate must still win.
52+
53+
| Rule | Input | Signal | Bound |
54+
|---|---|---|---|
55+
| 5a — plan relevance (today's rule 5) | plan refs / key intersection | the existing `+12` | as today |
56+
| 5b — prerequisite order | `list_dependencies(topic)` edges with `relation_type == "prerequisite"` | a candidate whose concept is a **prerequisite of an open milestone's concept** in a matchable plan gains a small bonus; a candidate whose concept **depends on** a concept the learner is `struggling` with loses the same amount ("the logical step before" comes first) | ± a value below the urgency-class gap, pinned like `PLAN_RELATED_BIAS` |
57+
| 5c — per-item energy demand | struggle state (`confidence`, `last_teachback_score`) and action type | a **demand** per candidate (repair of a live struggle is high demand; a recall of a `learning` concept is low) compared with `ENERGY_CAPABILITY[energy]`, so rule 3's floor stops being the plan's only energy fact | shared with item 5 (D-F); this proposal takes item 5's definition when it lands rather than inventing a second |
58+
59+
Design constraints, from the decision:
60+
61+
1. **Deterministic.** Every input is a stored fact (an edge, a confidence, a score); the bias for a
62+
fixed world is a pure function. No model call anywhere in ranking — an LLM tie-break is
63+
unauditable and defeats the D-16 rubric, which asks a human "would you do the primary?" and needs
64+
the answer to follow from stated rules.
65+
2. **Rubric-testable.** Each rule gets a D-16 rubric row with a planted world and an expected primary,
66+
scored by the owner before it ships: row 1 re-run under 5b should still be **yes** and now for the
67+
engine's reason; a new row plants a struggling prerequisite and expects the dependent milestone
68+
*not* to be primary.
69+
3. **Still a bias.** The golden `now_plan_no_active.json` stays byte-identical (no plan → no bias); the
70+
existing rule-5 pins (`test_matching_due_concept_outranks_unrelated_same_urgency`,
71+
`test_unrelated_more_urgent_due_outranks_new_milestone`, `test_weak_due_still_beats_overdue_synthesised_milestone`)
72+
stay green with the derived value in place of the constant.
73+
4. **Partial knowledge is not knowledge.** `get_concept_context` is explicit that omitted edges cannot
74+
support "no alternative exists"; 5b must treat an absent edge as *no signal*, never as "not a
75+
prerequisite".
76+
5. **Read once, through the seam.** Edges are read in `_PlanContext.build` beside the plan read, so the
77+
rule-1 pin (no per-consumer plan reads, no checkpoint-history reads) holds; the concept store is a
78+
second read, budgeted and measured on the live database before it ships (the item-4 preview read was
79+
measured at ~320 ms on an 877 MB `sessions.db` and recorded; this must be too).
80+
81+
## Out of scope
82+
83+
- Item 5 (D-F) owns the energy-demand *definition* and the body-doubling floor; this proposal consumes
84+
it and must not define a second one.
85+
- No change to what a plan document stores. Prerequisite knowledge lives in the concept store; the
86+
plan keeps naming concepts per milestone.
87+
- No filter, no reordering of urgency classes (review 3 F2 stands).
88+
89+
## Acceptance (for the issue)
90+
91+
- `PLAN_RELATED_BIAS` is replaced by a derived value with a pinned upper bound; the three rule-5 pins
92+
above and the golden byte-identity stay green unchanged.
93+
- RED tests, one per rule: a prerequisite-of-open-milestone candidate outranks a same-class sibling;
94+
a candidate dependent on a struggling concept loses to that concept's repair; an absent edge changes
95+
no score.
96+
- A measured read cost on a real `sessions.db`, recorded beside the constant.
97+
- Rubric rows added and scored by the owner (D-16), row 1 re-run.
98+
- Docs: `docs/study-plans.md` "Plan-aware now" describes the derived bias in the eligibility terms the
99+
contract test pins.
100+
101+
## References
102+
103+
`HANDOFF-2026-09-16.md` §2 D-D; `receipts/now-rubric-2026-09-16.md` rows 1–3; `council/review-3-arbitration-2026-09-16.md`
104+
F2; `studyloop/learning/decision.py` (`PLAN_RELATED_BIAS`, `ENERGY_CAPABILITY`, `MILESTONE_BASE_SCORE`,
105+
rule 5 application site); `studyloop/learning/mastery.py` (`list_dependencies`, `weak_links_for_topic`,
106+
`agent_concept_context`).
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Proposal: an age-aware nudge and a retire/snooze door for an overdue item (D-E)
2+
3+
**Status:** written proposal, no code (plan-integration follow-on item 6, T6.4). Becomes a
4+
`ready-for-agent` issue at the push step (HANDOFF §3 item 7, step 4). Written 2026-09-18 against
5+
`main` at `a5b9f903`; every code fact below was read from that tree.
6+
7+
## The owner's decision, verbatim
8+
9+
> **D-E** | Scenario 2 note: an overdue item **unrelated** to the plan must not sit as an alternate
10+
> indefinitely. Fact: due score already grows `+1/day` (cap +30), so it overtakes the +12 bias in
11+
> ~2 weeks; missing are an **age-aware nudge line** and a **retire/snooze** action for a due card (only
12+
> backlog topics can be `resolved` today).
13+
>
14+
> — `HANDOFF-2026-09-16.md` §2, owner, 2026-09-16
15+
16+
The evidence it names: rubric row 2 (`receipts/now-rubric-2026-09-16.md`), owner's verdict **yes** —
17+
clear the overdue review first — with the note: *"an overdue item unrelated to the plan must not sit as
18+
an alternate indefinitely — propose it explicitly (age-aware nudge) or let the learner retire it."*
19+
20+
## What the engine and the store do today
21+
22+
- **A due item is a `study_progress` row whose `last_seen` is old enough.** `history/progress.py`
23+
computes `days_ago` from `last_seen` and marks the row due when it reaches an interval in
24+
`REVIEW_INTERVALS` — 1, 3, 7, 14, 30 days, each with a review type ("5-min recall quiz" …
25+
"Teach-back session"); a `struggling` row is always due as "Guided repair + tiny practice". There is
26+
**no `next_review` column** and no state that says "not due": a `mastered` row keeps coming back on
27+
the same intervals, and the only thing that moves `last_seen` is studying it again
28+
(`record_progress`). A row therefore stays due — and stays a `now` candidate — until it is studied
29+
or deleted.
30+
- **The score arithmetic the decision cites is right.** `learning/decision.py` scores a due candidate
31+
`100 + min(days_ago, 30)` (+35 if `struggling`, +15 if `learning`). A plan-related candidate adds
32+
`PLAN_RELATED_BIAS = 12` (rule 5). So an unrelated due item at *d* days beats a plan-related one at
33+
*d′* days once `d > d′ + 12`: roughly two weeks of sitting as an alternate, then it wins the primary
34+
on age alone — silently. The learner sees it move up; nothing tells them why, and nothing offers a
35+
way to say "I have moved on from this".
36+
- **`resolved` exists only for parked topics.** `record_topic_progress(confidence="resolved")` (MCP)
37+
calls `parking.resolve_parked_topic(topic_id)` — a *backlog* row, not a `study_progress` row. The
38+
Today card and CLI `now` have no control on a due item at all.
39+
40+
## The proposal
41+
42+
Two additions, both small, both on the existing candidate — no new ranking rule.
43+
44+
### 1. An age-aware nudge line
45+
46+
When an eligible due candidate is **unrelated to every matchable plan** and has been due long enough
47+
to have overtaken the plan bias — i.e. `days_ago ≥ threshold`, with the threshold **derived from the
48+
constants**, not a second number: the smallest `days_ago` at which `min(days_ago, 30) ≥ PLAN_RELATED_BIAS`
49+
plus the plan-related candidate's own age — the candidate carries a `nudge` line that says so in plain
50+
words: *"Overdue 16 days and unrelated to your plan — do it, or retire it: `studyloop review retire
51+
<topic> <concept>`."* Rendered where the completion review's evidence lines are rendered today (CLI
52+
`now` beneath the action, Today card beside it, MCP payload as an additive key). The line is a fact
53+
about age, not a proposal to rank differently.
54+
55+
### 2. A retire/snooze door for a due item
56+
57+
A `study_progress` row gains one of two learner-issued states, through the seam every surface uses:
58+
59+
| Door | Meaning | Mechanism | Undo |
60+
|---|---|---|---|
61+
| **retire** | "I am done with this concept for now" | a `retired_at` timestamp on the row (or a `confidence` value the due predicate excludes — decided at RED with the migration); the row is no longer due, keeps its history, and disappears from every consumer of `spaced_repetition_due` — `now` (CLI, Today, MCP `get_next_action`), recap, `studyloop review`, and the plan evaluation's due count | studying it again (`record_progress`) clears the state |
62+
| **snooze** | "not this week" | a `snoozed_until` date; the row is not due before it and returns to the normal intervals after | expiry, or an explicit un-snooze |
63+
64+
Exposed the same way the plan lifecycle is: a CLI verb (`studyloop review retire|snooze`), a Today-card
65+
control on the due item, and one MCP tool beside `record_study_progress` — the mirror of
66+
`record_topic_progress(confidence="resolved")` for cards that the decision asks for. The store writes
67+
one row; retire is never inferred from age (the decision says *let the learner* retire it).
68+
69+
Design constraints:
70+
71+
1. **Learner-issued only.** Nothing retires or snoozes on the learner's behalf — the RSD-safe framing
72+
the project keeps: the nudge proposes, the learner decides (same shape as item 4's consensual
73+
close).
74+
2. **History kept.** A retired row is excluded from the due set, not deleted; `get_study_history` and
75+
the plan evaluation's `unverified_milestones` still see it.
76+
3. **Plan-aware, not plan-bound.** The nudge fires only for items unrelated to every matchable plan;
77+
a plan-related overdue item is the plan's business (item 4's closing review already counts it).
78+
4. **Golden unchanged.** The no-plan golden holds a `source=starter` primary with no due items, so it
79+
is byte-identical by construction; the nudge is an additive key on a due candidate.
80+
5. **The threshold is derived, not a new constant** — so when D-D replaces `PLAN_RELATED_BIAS` with a
81+
derived bias, the nudge moves with it.
82+
83+
## Out of scope
84+
85+
- Any change to `REVIEW_INTERVALS` or to how `days_ago` is computed.
86+
- Reranking. The overtaking-on-age behaviour is correct (row 2: clear the overdue review first); what
87+
is missing is the *explanation* and the *exit*, not a different order.
88+
- Flashcard/quiz `card_reviews` — a different store with its own scheduler (a simplified SM-2 in
89+
`review_db.py`, read by `get_due_cards` through `review_service.due_cards`); a retire door for those
90+
is a separate ticket if wanted.
91+
92+
## Acceptance (for the issue)
93+
94+
- RED: a due unrelated item past the derived threshold carries the nudge line on CLI, Today and MCP;
95+
a plan-related one does not; one below the threshold does not.
96+
- RED: `retire` removes the row from the due set and from `now` candidates, keeps its history row,
97+
and `record_progress` on the same concept clears it; `snooze` excludes it until the date and not
98+
after.
99+
- The migration is in `agent_session_tools.migrations` and the clean-rebuild closure classifies the
100+
new column/state (the 2026-09-12 rebuild caught two tables the migrations did not create; do not
101+
repeat that).
102+
- Golden `now_plan_no_active.json` byte-identical; `test_docs_plan_integration_contract.py` green
103+
with the doc sentence added to `docs/study-plans.md` "Plan-aware now" and `docs/cli-reference.md`.
104+
- A D-16 rubric row: row 2's world advanced 16 days, the owner asked whether the nudge line is one
105+
they would act on.
106+
107+
## References
108+
109+
`HANDOFF-2026-09-16.md` §2 D-E; `receipts/now-rubric-2026-09-16.md` row 2; `studyloop/history/progress.py`
110+
(`REVIEW_INTERVALS`, `_review_type_for`, `_progress_review_due`, `spaced_repetition_due`,
111+
`record_progress`); `studyloop/learning/decision.py` (due scoring `100 + min(days_ago, 30)`,
112+
`PLAN_RELATED_BIAS`); `studyloop/mcp/tools.py` (`record_topic_progress`, `resolve_parked_topic`);
113+
`agent_session_tools/migrations.py` (`study_progress` columns: `id, topic, concept, confidence,
114+
first_seen, last_seen, session_count, notes, created_at, updated_at`).

‎openspec/changes/plan-integration-followons/tasks.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,13 @@ writer, through the existing gate, closes that. Kept out of item 3 so item 3's f
205205

206206
## Item 6 — proposals (no code)
207207

208-
- [ ] **T6.4** `docs/architecture/plan-integration/proposals/2026-09-16-context-derived-plan-bias.md` (D-D) and
209-
`…-overdue-nudge-and-retire.md` (D-E); both become issues at the push step.
208+
- [x] **T6.4** `docs/architecture/plan-integration/proposals/2026-09-16-context-derived-plan-bias.md` (D-D) and
209+
`…-overdue-nudge-and-retire.md` (D-E); both become issues at the push step. (Written 2026-09-18 against
210+
`main` `a5b9f903`: each quotes the owner's decision verbatim, states what the engine and store do today from
211+
the code (`PLAN_RELATED_BIAS = 12`, `ENERGY_CAPABILITY`, due score `100 + min(days_ago, 30)`,
212+
`REVIEW_INTERVALS`, `list_dependencies` prerequisite edges, `resolve_parked_topic` as the only `resolved`
213+
path), then the proposal, constraints, out-of-scope and issue acceptance. D-D consumes item 5's energy-demand
214+
definition rather than defining a second. The two issues are item 7 step 4.)
210215

211216
## Item 7 — push step (owner present; HANDOFF §3 item 7)
212217

0 commit comments

Comments
 (0)