Skip to content
Back to skills

Rule Daemon Lessons

ASecurity

Lessons — reflection runs, the segments runner, proposals, the lessons check and its spend. A repository rule for apps/daemon/src/v1/lessons/**, apps/daemon/src/v1/agents/**/extract-lessons*, apps/daemon/src/v1/agents/**/host-analysis*, apps/daemon/src/v1/mcp/tools/propose-lessons/**, apps/daemon/src/v1/mcp/tools/check-lessons/**, apps/daemon/src/v1/mcp/tools/hidden-lessons-gate*; read it before editing a file there.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 17, 2026
ai-agentsrustgoshell

Works with

  • cursor
  • cli
  • mcp

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add geniro-io/geniro-app --skill rule-daemon-lessons --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rule Daemon Lessons?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rule Daemon Lessons
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/geniro-io-rule-daemon-lessons/badge)](https://www.skillsdirectory.com/skills/geniro-io-rule-daemon-lessons)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rule-daemon-lessons
description: "Lessons — reflection runs, the segments runner, proposals, the lessons check and its spend. A repository rule for apps/daemon/src/v1/lessons/**, apps/daemon/src/v1/agents/**/extract-lessons*, apps/daemon/src/v1/agents/**/host-analysis*, apps/daemon/src/v1/mcp/tools/propose-lessons/**, apps/daemon/src/v1/mcp/tools/check-lessons/**, apps/daemon/src/v1/mcp/tools/hidden-lessons-gate*; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/daemon-lessons.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->

# Lessons

Automatic on archive, plus "Reflect now" (`POST /v1/chats/:runId/lessons/reflect`): `v1/lessons`.

- A lessons reflection is a thread analysis with `Run.analysisPurpose = 'lessons'`; its optional second-model check is `'lessons_check'` (null or `review` is the user's own "Analyze thread"). Both share the analysis machinery — hidden from every listing, deleted with their source, read through `read_analyzed_thread` — but never replace, hide or are read as the review: `RunDao.listReviewAnalysesOf` is what `findAnalysis`, a start's replace list and `teamLedgerChats` read, and `listAnalysesOf` (every purpose) only the source's delete.
- Stretches (`LessonSegmentService`): archiving a thread (`runs_changed` with `archivedAt`) closes its stretch past `Run.reflectedThroughSeq` and queues it as a `queued` segment when it holds a learning signal (`utils/lesson-signals.fold.ts`, model-free: a user's push-back after a finished turn, a declined approval, a tool that failed then succeeded, a `failed` / `partial` outcome, a reopened stage, a review finding, a `pitfall` team note, and a goal closed `not_achieved` or `dropped` — read from `run_goals` by `utils/read-lesson-signals.ts` and placed at the newest stretch row of ANY kind written by its `closedAt` (`ItemDao.newestSeqAtOrBefore`, one read per unmet goal; the fold's own kinds would miss a close after a sub-agent or shell row); one closed before a later stretch's first row belongs to the stretch before, and one closed once the row after the stretch was written to the stretch after) and reflections are on for the thread — the app's mode (`off` / `auto`), then the team's `lessons` field (library YAML, else the run's copy), then `Project.lessons` (`utils/lessons-mode.ts`); the app's `off` wins. No signal, nothing new or lessons off → nothing. A thread has at most one queued segment; a later close extends it. Nothing else closes a stretch: no outcome, stage, card or quiet-window closers (user decision R1).
- The archive dialog decides for its archive (user decision): `POST /v1/chats/:runId/archive?lessons=reflect|skip` (team runs archive through the same route) hands the choice to `ArchiveLessonsRegistry` (in `AgentsModule`, so the route never imports this module) before the archive lands, dropped again when the archive fails; the close takes it once. `reflect` queues the stretch whatever the settings say; `skip` records it `skipped` / `user_skipped` and moves the watermark past it in one transaction, a queued segment of the thread included. Without a choice the settings decide. The dialog reads `GET /v1/lessons/estimate`: it shows the box only for `signals > 0`, ticked as `lessonsOn` (the same settings fold) says, and the price it shows is `typical` (`LessonSpendService.typical`: medians of spend and time over the newest `LESSON_TYPICAL_SAMPLE` finished segments, only those billed to the model the reflection would run as when there are `LESSON_TYPICAL_SAME_MODEL_MIN`; unpriced runs out of the median, null before any run finished), never the token formula.
- The runner (`LessonAutoRunner`) starts queued segments one at a time, oldest first, as soon as each is queued, and never reads the settings again: whether a stretch runs was decided at its close. A segment holds a `LESSON_SEGMENT_LEASE_MS` lease while it reflects or checks, and a lease that runs out is taken back (the chat cancelled) as a failed attempt. A reflection that settles without filing is a failed attempt too: back to `queued`, and `failed` with its reason (`utils/run-failure.ts`: the run's newest `error` row) after `LESSON_SEGMENT_MAX_ATTEMPTS`. At start it takes back segments whose run ended or is gone. No spend limit (user decision R2). "Reflect now" starts its own reflection at once, outside the queue. A delete takes no lessons (user decision: they are taken when a thread is archived); `closedBy: 'delete'` and `skipReason: 'off'` survive only on rows written before.
- `LessonReflectionService.start` takes the thread's queued segment (else records a new one), reads the items past the watermark up to its snapshot, and starts the chat with `lessonsReflectionGuide` as its `taskInstructions` and a brief naming the stretch, the signals and the lessons kept out of memory in the same team, else project (rejected, undone, dropped by the check). 409 `LESSONS_NOTHING_NEW`, `LESSONS_REFLECTING` (one at a time per thread) and `LESSONS_NOT_REFLECTABLE` (an analysis, builder or project chat). It runs in the source's folder, else its project's, else the userData folder, as `LessonsConfigService.reflectionChoice` says: what a press names, else `LessonsConfig.reflector` (a CLI, profile, model, effort, context window and model parameters pushed by Electron main's `lessons` key), else "same as the thread" — the source run as it ran: its CLI, `configDir`, `model`, `effort`, `contextWindow` and `modelParameters` (null ones stay null, the CLI's own default; a press naming another model drops the window and parameters, one naming another CLI takes none of them). Nothing falls back to another CLI or account: a signed-out profile fails like any run.
- A hidden lessons chat has no shell and no write tools: it starts in `ask` (`LESSONS_REFLECTION_APPROVAL`), `runsReadOnly` sets `AgentTurnInput.readOnly` on its turns, and each adapter strips its own CLI's tools — claude `--tools Read,Grep,Glob` with `--strict-mcp-config` (geniro's server only, `claude-in-chrome` switched off), codex `features.shell_tool = false` in the read-only sandbox under `untrusted`, cursor a profile whose `permissions` deny `Shell(*)` and `Write(**)`. `runsReadOnly` also makes the permission gate refuse at once, with no card, every request the rules do not approve; geniro's own tools are approved in every mode. Never `plan`: claude 2.1.316 runs Sonnet under `--permission-mode plan` whatever `--model` says. The card's footer names the model the reflection was billed for (`billedModelOf` over its `turn_complete` rows).
- geniro's MCP server lists a hidden lessons chat only `read_analyzed_thread`, `memory_search`, `memory_read`, `propose_lessons` and `check_lessons` (`mcp/tools/hidden-lessons-gate.ts`): every tool schema rides the prompt prefix each reflection writes to the cache, which measured about 90% of a reflection's cost.
- `propose_lessons` (`mcp/tools/propose-lessons/`, auto-approved by `isHostLessonsCall`) is listed only on a reflection turn (`AnalysisBroker.isReflection`); a hidden lessons chat is refused `report_recommendations`, `mark_recommendations` and `save_team_change` (`canReview`), and `memory_save` / `memory_forget` / `memory_feedback` (`MemoryService.isReflection`). `LessonFilingService` refuses the whole call with every problem named — `TOO_MANY` (over 3), `TOO_LONG`, `EVIDENCE_OUT_OF_SEGMENT`, `QUOTE_NOT_FOUND` (`quoteIn` over the row's strings), `CONTAINS_SECRET` (`redactSecrets`), `UNKNOWN_HANDLE`, `NEAR_DUPLICATE`, `ALREADY_FILED`, `NO_PLACE_FOR_TARGET` (project instructions or knowledge on a thread with no project, member instructions on a thread that is no team run), `UNKNOWN_MEMBER` (not in the run's shared team copy), `UNKNOWN_DOCUMENT` (no active document of the project by that handle) — and otherwise records `lesson_proposals` with the places the thread had (`places`: project id and the team copy's members, `utils/lesson-places.ts`, which the brief also lists) and moves the watermark to the segment's end (never back). Zero lessons → segment `empty`; a card only for "Reflect now".
- Targets (`LessonTarget`): `memory` (scope, type), `project_instructions`, `member_instructions` (member id), `knowledge` (an existing document's handle, or null for a new one). Only a memory lesson with dedup `new` is ever written without the user; every other one stays `proposed` on the card — instructions and knowledge are shared, always-loaded texts, and a `refines` / `broken_again` lesson is the user's to apply.
- Filing at once (user decision R4): each memory-target lesson with dedup `new` goes through `MemoryService.fileLesson` with actor `{kind: 'lesson', runId: <reflection>, …}` — an agent write: near-duplicate check, the review rule (`pending` while `agentWrites` is `pending`), provenance with `Memory.lessonProposalId`, and out of the memory index (`indexable`) until the user approves it or agents' marks promote it (`.claude/rules/daemon-memory.md` → Marks); it is found through `memory_search` at once. The brief lists the memory entries the thread had in front of it (`MemoryService.seenEntries`), and the reflection reports what they did as `propose_lessons.effects`, checked like evidence (inside the stretch, seen by the thread) and recorded as the thread's marks; auto lessons forgotten by marks or expiry join the rejected list (`forgottenLessons`). The proposal becomes `saved` (`resultRef` the handle) or `skipped_duplicate`; a target the thread has no place for stays `proposed` for Save. A memory-target lesson with dedup `refines` or `broken_again` goes through `MemoryService.applyLesson` instead (user decision: agent notes apply by themselves): when the named entry is an active agent note the user has not approved (not `indexable`), the thread sees it, the user does not review agent writes and the new text reads like no other entry, `refines` rewrites its title and body and `broken_again` approves it into the index, provenance kept; the proposal becomes `saved` with `resultRef` that handle, `autoApplied` (`LessonAutoApplied`: the old text and the rev the change left) and a `by: 'auto'` outcome. Anything else leaves it `proposed`; a check that failed delivers nothing, and lessons already waiting are never applied later. Undo on such a lesson (`undoable`) puts the old text back through `restoreText`, or takes the note out of the index, only while the entry is still at that rev (409 `LESSON_ENTRY_CHANGED` otherwise); Edit and Approve stay refused. Then the `lessons` row and one `lesson_outcome` row per lesson (`by: 'auto'`) go into the SOURCE (`LessonRowWriter`, persist-then-emit, an archived source included), and the segment ends `reflected`.
- The check (`LessonCheckService`), only while `LessonsConfig.checker` is set and the reflection found ≥ 1 lesson: the proposals are held `checking` (segment `checking`) and a second hidden chat (`lessons_check`, the checker's CLI, profile, model and effort, `lessonsCheckGuide`) answers through `check_lessons` (`mcp/tools/check-lessons/`, listed by `AnalysisBroker.isLessonCheck`) with one verdict per lesson — refused whole on `UNKNOWN_LESSON`, `MISSING_VERDICT`, `DUPLICATE_VERDICT`, `REWRITE_MISMATCH`, `TOO_LONG`, `CONTAINS_SECRET`. `keep` and `rewrite` (new title and rule, the reflector's evidence) are filed as above; `drop` becomes `dropped_by_check` with its reason, on the card. A check that ends without verdicts is retried up to `LESSON_SEGMENT_MAX_ATTEMPTS`, then its lessons are `check_failed` and wait on the card for Save / Reject. `LessonFilingService.useCheck` is how the check registers, so neither service imports the other's constructor.
- The user's decisions (`LessonProposalService`, all open to a paired device): Save on a `proposed` or `check_failed` lesson writes as the user where its target (as sent, else as proposed) says — a memory entry through `MemoryService.create` (active, indexed); `- <rule>` appended to the project's `lessons` block (created when missing) through `ProjectsService.update` at the revision read, logged with origin `lesson` (the thread as its chat); `- <rule>` appended to the member's instructions in the LIBRARY team through `TeamChangeService.appendMemberLine` (authority `lesson`: hash-guarded against the version read, backed up, logged with source `lesson`; never a project overlay); or a project knowledge document through `KnowledgeService.create`, or a `## <title>` section appended through `edit` at the read rev. "Update rule" (`update-rule`, dedup `refines`) edits the named entry through `MemoryService.edit`; "Move up" (`move-up`, dedup `broken_again`, `moveUpOf`) approves the named entry into the index, the least-reaching step (409 `LESSON_ALREADY_INDEXED` when it is already there; the project's instructions are a Save target). Reject stores the reason; on a lesson saved to memory Undo forgets the entry (restorable), Edit rewrites it (the entry becomes the user's own), Approve sets it active and approved (indexed) — refused `LESSON_NOT_FILED` for a lesson saved anywhere else. Save, Update rule and Edit take `notDuplicateOf`, the handles of a near-duplicate refusal (`409 MEMORY_NEAR_DUPLICATE`) the user pressed again past, passed to the memory write; Save also keeps vouching the entry a `refines` or `broken_again` lesson names. Each writes a `lesson_outcome` row (newest per proposal wins; `resultRef` names where it landed), skipped when the source thread is gone. `GET /v1/lessons/proposals?status=proposed,check_failed` is Settings → Memory's Waiting for review → Lessons list: every waiting lesson, a deleted thread's included (`sourceExists`); `GET /v1/lessons/history` (`LessonProposalService.history`) is Settings → Memory → Lessons → History: every proposal of every status, newest first by `(createdAt, id)`, a page of `limit` at a time with a `nextBefore` cursor (`<createdAt ISO>~<id>`, 400 `LESSON_HISTORY_BAD_CURSOR` for any other), plus `counts` over every row by `LESSON_HISTORY_BUCKETS` (saved; waiting = proposed, check_failed, the same set as Waiting for review; checking; notSaved = the rest), never folded from the page. `?status=saved` filtered on the wire's `undoable` (saved to memory as an entry of its own, the same test Undo and Edit apply) and not `memoryPending` (that entry still waits for review, so it counts among the waiting entries) is its Saved to memory list. The write of a reflection's card announces `lessons_changed` with `filed: {saved, waiting}` (saved = filed into memory active, waiting = proposed, check_failed or held pending under review), the desktop's lessons banner.
- Spend: a reflection's turns carry `usage_events.purpose = 'lessons'` and a check's `'lessons_check'` (`usageDimensions`, live and in the backfill), summed as `byPurpose` on `GET /v1/stats/usage`; `GET /v1/lessons/spend` (`LessonSpendService`) folds every row of today and this month by step, counts runs with no reported cost as unpriced (never $0) and lists failed segments with their reasons, each classified as `cause` `limit` (with the CLI's verbatim `resetsAt`), `signed_out` or `other` by `AgentAdapter.failureFrom` of the reflection run's own CLI, or of every adapter when that run is gone; the card's footer reads `GET /v1/lessons/reflections/:id` (a reflection or its check) over that run's ledger rows. `GET /v1/lessons/estimate` prices the reflection and, with a checker, the check (`LessonEstimateService`: the stretch's payload characters and the guide's over 4, plus `LESSON_READ_OVERHEAD_TOKENS`, read `LESSON_READ_PASSES` times, each pass at the context tier its prompt reaches, plus `LESSON_ANSWER_TOKENS`; no list price → `usd: null`, never 0).
- Background jobs: `LessonBackgroundJobSource` registers every segment but a `skipped` one with `BackgroundJobsRegistry` (`v1/background-jobs`, which imports nothing back) as a `lessons` job — queued, running with its phase, done (reflected or empty) or failed with `failReason` — its cost, time and billed model from the ledger rows of its reflection and check (`LessonSpendService.samplesOf`), and what it filed counted from its proposals (saved; waiting = proposed, checking, check_failed or saved with its entry still pending review; dropped = dropped_by_check or skipped_duplicate), read in one batch per page. Every `lessons_changed` is also a `background_jobs_changed`, and so is a usage row of a lessons reflection or check (`UsageEventBus`), which lands after the segment's last status change.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.