Skip to content

Route restated existing rules to already-covered, not automate-me - #1324

Merged
mergify[bot] merged 3 commits into
mainfrom
stack/EdbertChan/reflect/lesson-route-already-covered/route-restated-existing-rules-already-covered--bb2d3e90
Oct 11, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
stack/EdbertChan/reflect/lesson-route-already-covered/route-restated-existing-rules-already-covered--bb2d3e90

Conversation

@EdbertChan

@EdbertChan EdbertChan commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reflect turns a chat into lasting lessons for later agents. Before this change, when a person reminded the agent of a rule it had already skipped, Reflect treated that reminder as a new personal preference to capture. The real lesson was that the rule already existed and was not followed. This change adds a small router that picks the lesson bucket before any preference skill is invoked: a restated existing rule is rejected as already covered, and only a true preference with no home becomes preference capture.

Review Claim

A restated existing rule is rejected as already covered and does not open a preference capture; a preference with no existing skill still routes to preference capture.

Review Lane

behavior

Review Unit

engine-runtime

Safety Invariant

Does not change live hooks at install time beyond phrase text for the restated-rule judge; lesson routing is a reflect-step script and skill prose. No merge. No production deploy. Assumptions: Safety Invariant unconfirmed by the user in chat; proceeding with this text.

Slice Rationale

Single claim: the lesson bucket for a restated existing rule. Mechanism, phrase on_hit, skill prose, and tests land together so the gate cannot be skipped by prose alone.

Non-goals

  • Does not remove the intervention detector or soften frustration ranking
  • Does not change the preference-capture skill itself
  • Does not change poteto or pstack reflect
  • Does not auto-merge

Architecture

Before

flowchart TD
  audit["intervention flag"]
  auto["Route to preference capture"]
  audit --> auto
Loading

After

flowchart TD
  audit["intervention flag orders pass"]
  gate["lesson_route bucket"]
  audit --> gate
  gate -->|"already covered"| rejected["Rejected"]
  gate -->|"preference no skill"| auto["Route to preference capture"]
  gate -->|"durable new"| accepted["Accepted"]
Loading

Measured

Command: git show origin/main:engine/hooks/llm-judge/phrases/restated-rule.json | python3 -c 'import json,sys; print(json.load(sys.stdin)["on_hit"])'

  • base: restated-rule: the person had to restate a rule or skill that already exists. Count it as an intervention; a restated rule the agent should already follow is automate-me evidence.
  • head: restated-rule: the person had to restate a rule or skill that already exists. Count it as an intervention signal that orders the reflect pass. Default lesson bucket is already-covered (execution miss on an existing skill) via engine/skills/reflect/scripts/lesson_route.py — do not invent a new preference or call automate-me for this hit alone.

Command: python3 engine/skills/reflect/scripts/lesson_route.py --from-transcript engine/skills/reflect/scripts/tests/fixtures/restated_rule/fires.jsonl

  • base: fatal: path 'engine/skills/reflect/scripts/lesson_route.py' exists on disk, but not in 'origin/main' (from git cat-file -e origin/main:engine/skills/reflect/scripts/lesson_route.py; exit 128)
  • head: already-covered / action: reject / do not route to automate-me

Command: python3 -m unittest engine.skills.reflect.scripts.tests.test_lesson_route

  • base: none: router and its tests are part of this slice; merge-base has no module to import
  • head: Ran 10 tests / OK

Test Plan

Test Plan
  • python3 engine/skills/reflect/scripts/lesson_route.py --from-transcript engine/skills/reflect/scripts/tests/fixtures/restated_rule/fires.jsonl → already-covered
  • preference quote with no skill → automate-me
  • skill never opened → skill-not-used
  • python3 -m unittest engine.skills.reflect.scripts.tests.test_lesson_route → 10 OK
  • grounding tests call the router on fires.jsonl and assert already-covered
  • make-pr preflight --commit-only / Review Unit engine-runtime

Revert Plan

Revert Plan

Revert the two commits on this branch. Restores prior restated-rule phrase text and removes the lesson router; Reflect again treats restated rules as preference-capture evidence.


Note

Medium Risk
Changes reflect workflow routing and judge phrase guidance; behavior is gated by tests and script output, but mis-routing could skip legitimate preferences or accept wrong lessons if heuristics misfire.

Overview
Adds lesson_route.py so reflect synthesis picks a lesson bucket before Accepted or automate-me routing. Restated existing rules, admitted skips, and skill text that already covers the quote map to already-covered (Rejected), not new preference capture.

intervention-must-automate and frustration signals still order the reflect pass; they no longer imply an automate-me row by themselves. Reflect skill prose, cost-audit.md, and the Frustration lens now require running the router; only bucket automate-me invokes the preference sibling.

The restated-rule llm-judge phrase on_hit text is updated to point at already-covered and lesson_route.py instead of “automate-me evidence.”

The no-comments hook allows trailing text-match-decision-warn: directives so router regex lines stay compliant. Tests and the restated_rule/fires.jsonl fixture assert transcript routing → already-covered.

Reviewed by Cursor Bugbot for commit cfbdf1a. Bugbot is set up for automated code reviews on this repo. Configure here.

Reflect was writing a new preference whenever someone reminded the agent of a skill it had already skipped. Add lesson_route.py so that signal stays an intervention for ordering, and the lesson bucket is already-covered unless no skill states the preference yet.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: Ibb2d3e90a7cf01987aeb14b71e9413d7cec536c3
@EdbertChan EdbertChan changed the title Route restated existing rules to already-covered, not automate-me. Route restated existing rules to already-covered, not automate-me Oct 11, 2026
@cursor

cursor Bot commented Oct 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: b3cc23cd-c8bc-42eb-a6c2-02dcb6c09638)

@mergify

mergify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

The boundary-parser allow mark stays, and the comment checker treats that mark as a machine directive so the two gates agree.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: I0a048d4d387df53de81d2638521a5198de499b36
@EdbertChan

Copy link
Copy Markdown
Owner Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 Route restated existing rules to already-covered, not automate-me #1324 👈
2 Drop the lesson-router comments that failed the comment gate. #1330

…son-route-already-covered/drop-lesson-router-comments-failed-comment-gate--0a048d4d

Drop the lesson-router comments that failed the comment gate.
@cursor

cursor Bot commented Oct 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 7e3d7ee2-2373-4ccc-9aea-a0c190c5cecb)

@EdbertChan

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 59 seconds in the queue, including 59 minutes 58 seconds running CI.

Required conditions to merge
  • check-success = lint
  • check-success = test
  • check-success = validate

@mergify mergify Bot added the queued label Oct 11, 2026
@mergify
mergify Bot merged commit a9995b3 into main Oct 11, 2026
6 checks passed
@mergify mergify Bot removed the queued label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant