Skip to content

feat: pin a lesson a person taught to the chat they taught it in - #47068

Open
buluoray wants to merge 4 commits into
crew/slack/pinned-upkeep-reminderfrom
crew/slack/pinned-autopin
Open

buluoray wants to merge 4 commits into
crew/slack/pinned-upkeep-reminderfrom
crew/slack/pinned-autopin

Conversation

@buluoray

@buluoray buluoray commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: With pinned memory on, a rule a person teaches in a chat is pinned to that chat on its own, so it comes back whole after every compaction.

With memory.pinned_memory on, a lesson the agent saves when a person corrects it is still only ranked after a compaction: nothing pins it unless the agent chooses to, and an agent rarely acts unprompted. This is part 4 of pinned memory; it stacks on #47044 (tell and remind), which stacks on #46364 (it now also carries what was #46450).

Why it matters

What a person told the bot to remember is the memory they most expect to survive a compaction. Leaving it to the agent's judgement at the moment of the save is the weak point the earlier recall rounds measured.

Not a goal

  • Pinning lessons from turns no person is in (worker hand-offs, nudges, cron wakes, other sessions).
  • Changing which pins the 30,000-character guard keeps, or adding a mark of who made a pin.
  • Any new setting or UI: it rides memory.pinned_memory.

What changed (motivation → approach → change)

Goal → pin at the save, through the existing pin path, only when a person is in the turn → dashboard/handlers/cron_lesson_autopin.py (new) decides; handlers/pinned_memory.pin_lesson pins.

  • When. The lessons route asks for the pin when every one of these holds:

    • the agent's own learn_add, with internal auth and a session key the transport attests;
    • a person is in the turn: its frozen opener (slot._turn_row) is a person's by memory_origin_gate.classify_turn, or a person's message was steered into it;
    • a key: the row the save wrote, or the stored row that already holds the lesson;
    • that stored row is a standing rule: its own applies is unstated or always, so an on_topic finding is not pinned.

    remember_and_pin (pin_follows) pins on its own and is not asked.

  • Which row. LessonWriteResult.match_key (new) names the stored row on an exact repeat (unchanged) and on a lesson a stored one covers (deduped), so "I told you before" in another chat pins too. key keeps meaning "the row this call wrote".

  • One chat row. A new pin draws the "Pinned: …" row, and the lessons route then draws no "Lesson saved" row. Otherwise the lesson row stays.

  • What the agent is told. learn_add adds what the pin did: pinned, already pinned, or not pinned and why. A covered lesson says the covering one was pinned. The reply is built by _learn_add_reply, moved out unchanged.

  • A correction. When the store replaces a lesson and the replacement is already pinned in its current life, the old pin is dropped with no notice (pinned_memory._settle). Without that, the person who corrected a rule would read that a pinned memory was deleted.

Docs: memory-skills-hooks.md (Pinned memory). The design and its whole-class table (repeats, corrections, other chats, "forget that", tidying) went through two second-model reviews before code.

Backwards compatibility

Compatible: with memory.pinned_memory off (the default) nothing is asked and no answer changes. match_key is a new field with a default; no caller compares whole results.

Removes nothing: the "Lesson saved" row is replaced by a "Pinned" row only for a save that the pin row covers.

Tests

  • test/test_pinned_memory.py:
    • TestAutoPin: pin_lesson pins then answers already_pinned; a repeat names the stored row; a replacement already pinned drops the old pin quietly.
    • TestAutoPinDecision: each condition; a person's steer into an automatic turn counts; the tier is read from the stored row; the answer says what the pin did, and a covered lesson names the covering one.
  • test/test_lesson_saved_card.py: one row whether the pin is pinned, already_pinned or not asked.

Proof: not provable -- other: a new feature with no fix to revert; mutation-checked instead (the person-turn check, the row skip and the quiet drop each turn a test red).

Manual verification

Pending: a pod with pinned memory on, teaching a rule in a chat and reading the row and the pin list.

Real-machine verification

Pending, with the manual verification above.

Screenshots / video

N/A -- no frontend file changes; the row is the existing "Pinned: …" row.

Related Issues

Part of #46328

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision a497f7d69f16fb07861d8533ae1a6497641f0804 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a497f7d69f16fb07861d8533ae1a6497641f0804 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level blocker: the auto-pin goes through the existing pin route, only fires when a person is in the turn and the tier is a standing rule, and is off by default behind memory.pinned_memory.

Notes

  • The description contradicts the diff on covered lessons. It says match_key names the stored row "on a lesson a stored one covers (deduped), so 'I told you before' in another chat pins too" and "A covered lesson says the covering one was pinned". The code, the field's docstring and test_a_lesson_a_stored_one_contains_names_no_row all do the opposite: DEDUPED carries no match_key and pins nothing. Fix the description's "Which row" and "What the agent is told" bullets so reviewers and release notes don't promise behaviour that isn't there.
  • The _settle quiet-drop applies to every superseded directive pin whose successor is already pinned, not only to auto-pins. That is probably right, but the spec text ties it to a person's correction. Say there that it is general.
  • Manual and real-machine verification are still "Pending". That is fine for this design gate, but PR readiness still needs them.

[DESIGN-REVIEWED] a497f7d

Description read

[DESCRIPTION-READ] 32e2fa1b1a02acde36c684ea19f111298cf3c05fd6e481b012e4e093f8993c02

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a497f7d69f16fb07861d8533ae1a6497641f0804 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The base RFC rfc-pinned-memory.md (in-progress) covers this shape and names #47068 for it, and the change rides the existing pin path behind the off-by-default switch.

Notes

  • Item 2 — undeclared: the description says match_key "names the stored row … on a lesson a stored one covers (deduped)" and that "A covered lesson says the covering one was pinned". The diff does the opposite: "None on every other outcome, DEDUPED included", and test_a_lesson_a_stored_one_contains_names_no_row pins that. Subtraction: delete the deduped and "covered lesson" claims from ## What changed and ## Tests so the description matches what ships.

What this change ships

Inventory (7 items) — 7 justified

Intent: when a person teaches the bot a rule in a chat with pinned memory on, that rule survives every compaction without the agent having to choose to pin it. This is an ADDITION.

  1. A standing-rule lesson saved by learn_add on a turn a person opened or steered into (steer consumed) is pinned to that dashboard chat automatically — justified
  2. Re-teaching a rule that is already stored pins the existing row (match_key on unchanged) — justified
  3. A new auto-pin shows the single "Pinned: …" row instead of the "Lesson saved" row — justified
  4. The learn_add reply now says whether the lesson was pinned, already pinned, or not pinned and why — justified
  5. The lessons route response carries a new pin outcome field — justified
  6. A pin whose lesson was replaced by one already pinned in this chat is dropped without a "deleted" notice — justified
  7. A spec paragraph in memory-skills-hooks.md (Pinned memory) describes the auto-pin — justified

[FIRST-PRINCIPLES-REVIEWED] a497f7d

Description read

[DESCRIPTION-READ] 90a52ff11964ea8c0e9132eebf3359a037dd950ed5dcaf87b7273795d21588b8

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed a497f7d69f16fb07861d8533ae1a6497641f0804 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] a497f7d

Verdict parsed from the review's SHA-scoped output markers for commit a497f7d69f16fb07861d8533ae1a6497641f0804.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a497f7d69f16fb07861d8533ae1a6497641f0804 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a497f7d69f16fb07861d8533ae1a6497641f0804 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a497f7d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a497f7d69f16fb07861d8533ae1a6497641f0804 false-positive: <reason, 20 to 500 characters>

@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from 0b1c0db to b6e9d2c Compare December 4, 2026 07:04
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from b6e9d2c to e1286bd Compare December 4, 2026 07:08
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from 1793f39 to 688c5cc Compare December 4, 2026 07:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from 688c5cc to da196f2 Compare December 4, 2026 10:34
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch 2 times, most recently from 95ecfe4 to 05b04eb Compare December 4, 2026 11:04
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from da196f2 to 9eb15e0 Compare December 4, 2026 11:04
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from 05b04eb to c07551b Compare December 4, 2026 17:50
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from 9eb15e0 to 8e68d39 Compare December 4, 2026 17:50
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from c07551b to f870e85 Compare December 4, 2026 18:32
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from 8e68d39 to 58601fb Compare December 4, 2026 18:32
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Dec 4, 2026
buluoray added a commit that referenced this pull request Dec 4, 2026
* docs(rfc): propose pinned memory, with pinning onto workers

Pinned memory is built across open PRs #46364, #46450, #47044 and
#47068, but has no RFC. This one records what that stack builds, and
proposes one addition: a chat that starts workers pins memories of its
own store onto them, so a worker keeps its starter's rules after a
compaction. The reading surface (a side-panel item) is in progress.

* docs(rfc): name the pull request that carries the pinned memory rfc

* docs(rfc): deliver a mid-run pin to the worker at once

Record the maintainer's rulings of 2026-12-04 as settled rules and
empty the open questions. A pin made while a worker runs now reaches it
at once as one gateway prompt of a new `pin` kind, queued behind a
running turn, instead of waiting for the next compaction. Drop the
byline for a starter chat that no longer exists.
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from f870e85 to 85aadfb Compare December 4, 2026 19:08
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from 58601fb to 1e4b873 Compare December 4, 2026 19:08
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners December 5, 2026 08:12
@buluoray
buluoray requested review from dodgeblaster and removed request for a team December 5, 2026 08:12
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Dec 5, 2026
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from 0d28ae4 to 4432ba2 Compare December 5, 2026 08:56
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from b08766f to ea1b974 Compare December 5, 2026 08:56
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Dec 5, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Dec 5, 2026
@buluoray
buluoray force-pushed the crew/slack/pinned-upkeep-reminder branch from 4432ba2 to 6429a0f Compare December 5, 2026 11:16
@buluoray
buluoray force-pushed the crew/slack/pinned-autopin branch from d37eaa0 to 167ef28 Compare December 5, 2026 11:17
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Dec 5, 2026
@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for Opus 5.5 Review on 6bbe08c7fa1. The new head is 5d76cb1b214.

Finding Verdict What happened
A lesson that a stored one contains or resembles auto-pins the stored row, which can say the opposite (cron_lessons.py:840, lesson_write.py:473, :512) Fixed The substring_covered and semantic_similarity DEDUPED returns no longer set match_key. maybe_pin gets stored=False there and pins nothing. Only an exact repeat (UNCHANGED) names the row that already holds the rule. The learn_add note about a "covering" lesson could no longer fire, so it was removed. The spec, the match_key field note and the module docstring now say this. Test: test_a_lesson_a_stored_one_contains_names_no_row uses Opus's own case ("Never use tabs for indentation" stored, then "Use tabs for indentation"). Putting match_key back turns it red. The semantic branch needs real embeddings, so no unit test covers it; it is the same one-line removal.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for GPT 6.1 Review on 5d76cb1b214. The new head is 76bb5e17f85.

Finding Verdict What happened
A pin of a lesson deleted and taught again answers already_pinned, and the next send drops the old life (dashboard/handlers/pinned_memory.py:162, :367) Fixed In the shared _pin, already_pinned now needs the existing pin to match the live record's life (_same_life). Otherwise the live life replaces the old pin in place, so the explicit pin, remember_and_pin and the lessons route's auto-pin all get it. Test: test_a_lesson_taught_again_after_its_delete_is_pinned_as_it_is_now (pin, delete, save the same rule again, pin_lesson answers pinned, and the block sends it). Dropping the life check turns it red. The spec's life-id paragraph says it.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for GPT 6.1 Review on 76bb5e17f85. The new head is e8308cde6fe.

Finding Verdict What happened
A steer the turn has not read (written, later requeued) counts as a person in the turn (cron_lesson_autopin.py:55) Fixed _person_in_turn now counts a steer row only when its steerState is consumed, which steer_queue sets once the turn reads it. A person's turn opener and non-steer rows count as before. Test: test_a_steer_counts_only_once_the_turn_read_it (consumed counts; written, requeued and retracted do not). Counting every steer again turns three of its cases red. The spec sentence says it. #47415's unpin on a person's turn uses the same helper, so it gets the same rule.

With pinned memory on, a lesson the agent saved when a person corrected
it was still only ranked after a compaction: nothing pinned it unless
the agent chose to.

The lessons route now pins a lesson saved by the agent's own learn_add
on a turn a person opened, through the pin route's own path. It asks
only for an attested session key, a turn whose frozen opener is a
person's, a standing rule (not an on_topic finding), and a key: the row
the save wrote, or on an exact repeat or a covered lesson the stored
row that already holds it (LessonWriteResult.match_key, new). A new pin
draws the one Pinned row instead of the Lesson saved row, and learn_add
says what the pin did. remember_and_pin pins on its own and is not
asked. A pin whose lesson was replaced by one the chat already pins is
dropped with no notice, so a person who corrects a rule is not told it
was deleted.
A withdrawn steer keeps its user role and human marker with its text
cleared, so _person_in_turn read an automatic turn as one a person was
in and auto-pin could pin a lesson nobody taught. Skip withdrawn steers.
A lesson a stored one contains or resembles was pinned as the stored
row, but containment and similarity can match the opposite rule ("Never
use tabs" contains "use tabs"). DEDUPED no longer names a row, so only
an exact repeat pins the row that already holds it.
A steer still written, requeued or taken back counted as a person in
the turn, so an automatic turn's lesson could be pinned on a steer the
turn never read. A steer now counts only when its state is consumed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant