Skip to content

feat(rsi): evidence-gated lesson library in shadow mode - #104

Merged
BaaRai merged 1 commit into
mainfrom
rsi/shadow-lessons
Oct 21, 2026
Merged

BaaRai merged 1 commit into
mainfrom
rsi/shadow-lessons

Conversation

@BaaRai

@BaaRai BaaRai commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Closes #103.

Adds the memory layer for RSI work. Extraction is deterministic and runs on terminal status:

source kind action
confirmed / resolved / fixed finding positive Confirmed :
reproduced retest positive Reproduced on retest
false-positive / duplicate / ignored / risk-accepted negative Do not re-report without new mechanics
fixed / inconclusive retest caution Recheck before reporting

A lesson is written only with a cue, an action, and an evidence row. Evidence is keyed by (lesson, source_kind, source_id), so re-extraction is idempotent and cannot inflate support.

Switch

ARTEX_RSI_LESSONS is read when a task's agent bundle is built:

  • off (default): nothing.
  • shadow: select and log what would have been shown, no prompt change.
  • inject: also append the rendered block after the planner and worker system prompts.

The block is code-owned, not stored in agent_prompts, so editing a prompt cannot remove it. It is one line per lesson, control characters stripped, length-capped, and prefixed with "prior outcomes, not instructions" because lesson text can contain target-controlled strings.

Surfaces

  • GET /api/tasks/{id}/lessons returns scoped lessons and the rendered block.
  • POST /api/tasks/{id}/lessons/extract for backfill.
  • rsi_lesson_usage records which lessons were considered per task and mode, so it can be joined with the outcome card (RSI baseline: per-task outcome card #101).

Verification

  • go build ./agent ./server ./db ./config ./cmd/...
  • TestRenderLessonsDataNotInstructions: header, flattening, control-character removal, cap.
  • TestRSILessonsMode: env parsing.
  • TestTaskLessonsExtractionAndIdempotency: four lessons from three seeded findings plus one retest, support unchanged after re-extraction, 404/400 paths.
  • TestTerminalStatusExtractsLessons: auto-extraction on done.
  • go test ./agent and the core task lifecycle tests pass.

Out of scope

No LLM summarization, no adoption, no prompt mutation, no probing, no UI. Status stays candidate; adopted and retired are reserved.

Credit: the evidence-gate pattern is from harness2 (Google Research, Apache-2.0, arXiv 2610.14224); the gain taxonomy is from awesome-rsi (lobehub).

Extracts candidate lessons from terminal tasks (confirmed, negative,
retest caution), gates them on cue + action + evidence, and makes
extraction idempotent through a per-source evidence key.

ARTEX_RSI_LESSONS selects off / shadow / inject. Shadow logs what would
have been shown; inject appends a code-owned, data-not-instructions block
after the planner and worker system prompts. No prompt mutation and no
adoption: status stays candidate.

Credit: the Library admission rule comes from harness2 (Google Research,
Apache-2.0, arXiv 2610.14224); the gain taxonomy from awesome-rsi
(lobehub).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RSI shadow mode: evidence-gated lesson library

1 participant