Skip to content
Learning reference

Learning reference

Reference for repository lessons (internal/lessons, internal/store/lessons.go, internal/bridgeapi/lessons.go, internal/humanapi/lessons.go, internal/factory/codify/, internal/factory/api/lessons.go, internal/metrics/metrics.go). For a walkthrough, see Repository lessons.

Configuration

WhereKeyDefaultEffect
charts/maku (values.yaml)learning.enabledfalseWhen true, renders learning: {enabled: true} into room-broker-config
maku-broker config (internal/config/config.go)learning.enabledfalseEnables /api/lessons, /api/rooms/{id}/lessons, and /v1/lessons*. GET /learning is always served; when false, GET lesson APIs return {"enabled": false} and write routes return 404 learning_disabled

Model, bounds, and states

PropertyRule
IdentifierL-<n> (^L-[1-9][0-9]*$), sequential per repository
Versions & editslesson_versions stores immutable (repository, number, version) snapshots (text, author, source_url, class, paths). EditLesson checks current_version = $expected (409 version_conflict)
Text cleaning (lessons.CleanText)\r\n normalized; rejects lines starting with #, <!--, ```, or ~~~ (text_has_markup); collapses whitespace runs to single spaces; rejects empty (text_empty); max 500 UTF-8 bytes (text_too_long); scans with redact.Redactor (text_has_secret, never echoing the secret); sanitizes via sanitize.Text
Scoperepository (owner/name, lowercased), optional class (≤ 64 non-whitespace/non-control chars), optional paths (≤ 32 globs, ≤ 256 bytes each), dataClass (public or internal)
CapacityAt most 200 lessons per repository outside codified and dismissed (limit_reached)
Recall selection (lessons.Select)Only active lessons; drops internal lessons for non-internal runs; matches class == "" or class == run.Class; ranks class-specific ahead of general, then newest updatedAt (tie-break number descending); capped at 8 lessons and 2048 UTF-8 bytes of text (omitted counts skipped lessons). Factory recall times out after 2 s
Vote suspensionlesson_votes keys votes by (repository, number, vote_epoch, actor) (rooms_broker has SELECT, INSERT only). Reaching 3 distinct voters on an active lesson transitions active → suspended and appends not_relevant + suspend actions in one transaction. resume clears notRelevantCount and increments vote_epoch
Dormancy & retentionrooms_retention marks active lessons unused for 90 days (GREATEST(COALESCE(last_recalled_at, created_at), state_at) <= now() - interval '90 days') as dormant (UPDATE (state, state_at) column grant + trigger restricting it to active → dormant, plus dormant action with actor: "system:retention"). rooms_retention purges stopped and dismissed lessons whose state_at is at least 90 days old (lesson_versions, lesson_actions, lesson_votes, and lesson_recalls cascade). lesson_versions and lesson_actions are append-only for rooms_broker
Ready to codifystate == "active", recallCount >= 10, notRelevantCount == 0, and firstRecalledAt at least 21 days old
Codify (codify.Service)Appends - <text> (codified from L-<n>) under ## Verify in .github/agent-factory/steering/<class>.md (creating # Steering: <class>\n\n## Verify\n... when absent), validated by steering.Validate (≤ 2048 bytes, ≤ 3 ## modules). Branch maku/codify-<class>-L-<n>, title steering(<class>): codify lesson L-<n>. Reuses an open PR idempotently; factory never merges. codify.Watcher polls GET /v1/lessons/codifying at startup and every 10 min
Run & PR provenanceReconciler sets AgentRun annotation agents.ogenki.io/lessons (comma-joined L-<n> IDs, CREATE-only in admission); runctl injects AGENT_LESSONS; pr_footer.py appends Agent-Lessons: L-12, L-15
Statesactive, proposed, stopped, suspended, dormant, codified, dismissed
Actionsteach, accept, edit, stop, resume, not_relevant, dismiss, codify, suspend, dormant

Comment command grammar

Both commands follow commandLine anchoring: on their own line at column 0, outside fenced code blocks and blockquotes, unedited, from a maintainer with repository write access. They are polled from the task’s issue and pull request conversation comments in every phase and for 14 days after a task becomes terminal (30 s while non-terminal, 10 min once terminal).

CommandGrammar & behavior
/factory remember <text>Takes the rest of the line plus following non-blank lines up to the first blank line, joined with spaces. Empty text is refused (text_empty)
/factory forget L-<n>Stops L-<n> (active → stopped)

Refusal codes (lessons.Refusal): text_empty, text_too_long, text_has_secret, text_has_markup, limit_reached, not_permitted, disabled, no_such_lesson, bad_transition.

HTTP routes

Broker Human API (:8080)

JSON bodies are strictly decoded (DisallowUnknownFields) and capped at 16 KiB. Error responses return {code, message} where message is a complete sentence.

RouteRequest / queryResponse / auth
GET /learning—Always serves the SPA HTML shell with CSP (200), even when learning.enabled is false
GET /api/lessons?repo=owner/name&state= (all or comma-separated states)Requires repository read (403 not_permitted). Returns {enabled: false} when off; {enabled, repository, viewer: {canTeach, canStop, canResume, canEdit, canCodify}, lessons, omittedLastRun} when on. Each lesson carries id, number, version, state, text, class, paths, taughtBy, source, recallCount, lastRecalledAt, notRelevantCount, readyToCodify, codifyPR?, attention? ("suspended_by_votes"), votes? (writers only), createdAt, updatedAt
POST /api/lessons{repository, text, class?, paths?, dataClass?, roomID?, seq?}Requires repository write. With roomID, derives dataClass from the room (refusing body dataClass with 400 bad_data_class) and sets source to /r/<room>#<seq>. Returns 201 {lesson}, 422 on refusal, 404 learning_disabled when off
PATCH /api/lessons/{owner}/{name}/{number}{version, text?, class?, paths?}Requires repository write. Updates text/class/paths and increments version. Returns 200 {lesson}, 409 version_conflict on stale version, 404 no_such_lesson / learning_disabled, 422 on refusal
POST /api/lessons/{owner}/{name}/{number}/actions{action, roomID?, runID?} (stop, resume, not_relevant, codify)stop, resume, and codify require repository write (codify also requires a human bearer token forwarded to the factory’s POST /v1/lessons/codify); not_relevant requires roomID and room read (optional 8-char runID). Returns 200 {lesson} (plus pullRequest: {number, url, created} for codify), 404 no_such_lesson / learning_disabled, 409 bad_transition, 422 codify_no_class / codify_too_large / codify_invalid_note
GET /api/rooms/{id}/lessons—Requires room read. Returns {enabled: false} when off; {enabled, repository, viewer, runs: [{runID, role, outcome, omitted?, lessons, at}]} when on (outcome: served, empty, skipped, unavailable)

Broker System API (:8443)

Authenticated as system:factory (OutputClient), admitted through the system limiter, 16 KiB strict JSON. Returns 404 {error: "learning_disabled"} when learning.enabled is false.

RouteRequestResponse
POST /v1/lessons{repository, text, class?, paths?, dataClass?, author, sourceURL?}201 {lesson} or 422 {error: "lesson_refused", code, detail}
POST /v1/lessons/{owner}/{name}/{number}/actions{action: "stop", actor}200 {lesson} or 404 {error: "no_lesson"}
POST /v1/lessons/recall{repository, dataClass?, class?, roomID, runID, skip?}200 {outcome, lessons: [{id, version, text, class, paths}], omitted} (idempotent by runID)
GET /v1/lessons/codifying—200 {lessons} (active lessons with codifyPR set)
POST /v1/lessons/{owner}/{name}/{number}/codified{merged: bool}200 {lesson} (active → codified and increments codify metric when merged: true; clears codifyPR when merged: false)

Factory API (:8082)

RouteRequestResponse / auth
POST /v1/lessons/codify{repository, class, lessonID, text, source?, recallCount?}Requires human bearer token (not sponsored/internal) with repository write access (api.access). Returns 200 {number, url, created} or 422 {error, message, current?, resulting?} (codify_no_class, codify_too_large, codify_invalid_note)

CLI commands

--repo defaults to the origin remote of the current directory. All broker strings are filtered through maku.SafeText; --json prints the raw broker JSON response.

CommandEffect
maku learning teach <text> [--class C] [--paths GLOB]... [--repo owner/name] [--json]Creates an active lesson
maku learning list [--state S] [--repo owner/name] [--json]Lists lessons (ID, STATE, CLASS, USED, LAST USED, TEXT, plus cap notice when omittedLastRun > 0)
maku learning show L-<n> [--repo owner/name] [--json]Prints full details for one lesson, including Version, Ready to codify, and Codify PR
maku learning edit L-<n> [--text T] [--class C] [--paths G]... [--repo owner/name] [--json]Writes a new lesson version (L-<n> (v<N>): <text>)
maku learning stop L-<n> [--repo owner/name] [--json]Stops L-<n>
maku learning resume L-<n> [--repo owner/name] [--json]Resumes L-<n> (stopped / suspended / dormant → active)
maku learning codify L-<n> [--repo owner/name] [--json]Opens or reuses a steering-note PR for L-<n> and prints its URL
maku start --without-lessons ...Sends withoutLessons: true on POST /api/handoffs/{id}/start so the task sets spec.learning.withoutRecall: true

Metrics

Exported on the broker’s :9090 /metrics endpoint (internal/metrics/metrics.go). repository is lowercased and bounded to configured repositories; every other label is a closed enum (unlisted values map to other).

MetricTypeLabelsMeaning
maku_learning_lessonsgaugerepository, stateRepository lessons by repository and state
maku_learning_actions_totalcounterrepository, actionTyped lesson actions (teach, accept, edit, stop, resume, not_relevant, dismiss, codify, suspend, dormant, other)
maku_learning_recalls_totalcounterrepository, outcomeRecall outcomes (served, empty, skipped, unavailable, other)
maku_learning_recall_omitted_totalcounterrepositoryActive lessons omitted by the recall cap