Skip to content
Back to skills

Rule Daemon Thread Analysis

ASecurity

Thread analysis — the analysis chat, its cards, member assessments, team analysis. A repository rule for apps/daemon/src/v1/agents/**/*analys*, apps/daemon/src/v1/agents/**/recommendations-*, apps/daemon/src/v1/agents/**/run-snapshots*, apps/daemon/src/v1/agents/**/team-runs-fold*, apps/daemon/src/v1/agents/**/host-project-instructions*, apps/daemon/src/v1/teams/**/*analys*, apps/daemon/src/v1/teams/**/*instruction-sizes*, apps/daemon/src/v1/teams/**/fresh-session-base*, apps/daemon/src/v1/ag...

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

Works with

  • cursor
  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned December 4, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Rule Daemon Thread Analysis?

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

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

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-thread-analysis
description: "Thread analysis — the analysis chat, its cards, member assessments, team analysis. A repository rule for apps/daemon/src/v1/agents/**/*analys*, apps/daemon/src/v1/agents/**/recommendations-*, apps/daemon/src/v1/agents/**/run-snapshots*, apps/daemon/src/v1/agents/**/team-runs-fold*, apps/daemon/src/v1/agents/**/host-project-instructions*, apps/daemon/src/v1/teams/**/*analys*, apps/daemon/src/v1/teams/**/*instruction-sizes*, apps/daemon/src/v1/teams/**/fresh-session-base*, apps/daemon/src/v1/agents/**/repo-instruction-files*, apps/daemon/src/v1/teams/**/team-change*, apps/daemon/src/v1/teams/**/team-edits*, apps/daemon/src/v1/mcp/tools/read-analyzed-thread/**, apps/daemon/src/v1/mcp/tools/*-recommendations/**, apps/daemon/src/v1/mcp/tools/save-*/**, apps/daemon/src/v1/agents/**/knowledge-items*, apps/daemon/src/v1/agents/**/project-instructions*, apps/daemon/src/v1/agents/**/team-builder*, apps/daemon/src/v1/teams/**/team-proposal*, apps/daemon/src/v1/stats/**/recommendation-*, apps/daemon/src/v1/stats/**/team-spend-fold*, apps/daemon/src/v1/system-analysis/**; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/daemon-thread-analysis.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->

# Thread analysis

"Analyze thread": `ThreadAnalysisService`, `POST /v1/chats/:runId/analyses`.

- An analysis is an ordinary chat whose `Run.analysisSourceRunId` / `analysisSourceSeq` name the thread it reads and the seq its reads stop at (the source's newest row when it was started). Its method is `taskInstructions` (`utils/thread-analysis-guide.ts`), never a plugin skill at run time; it has the agent read the overview views itself and hand a sub-agent only a narrow deep dive in a fresh context, never a fork of its conversation, which carries every page read into each of its requests (`subAgents`). Its approval mode is the dialog's, else `ANALYSIS_DEFAULT_APPROVAL` (`auto`), never `CHAT_DEFAULT_APPROVAL`: it works unwatched in its popup.
- It belongs to its source, like the builder's chat to its team, and is a system chat (`RunWire.systemKind` `thread_analysis`, `utils/system-chat-kind.ts` over `agentFlagRunKindOf`; user decision: it opens as an ordinary chat): `listChats` returns it only with `includeSystem` (the Chats screen's System section), chat search (`ChatSearchIndexDao.match` / `run`) finds it, `list_threads` and the command center never do; `GET /v1/chats/:runId/analysis` finds it (`{analysis: null}` for none, newest wins), and there is one per thread.
  - A start replaces exactly the analyses that existed BEFORE it created its own, and only AFTER the new one has its brief: a failed start keeps the old one, and two racing starts never delete each other's.
  - Deleting the source deletes it (`ThreadAnalysisService` on `bus.allDeleted()`, whichever route deleted the source); what that misses (a daemon stopped before the announce, a failed delete) is swept at boot (`sweepOrphans`).
  - An archived source is read exactly like a live one (user decision: archived and deleted are different things; a deleted run is not read). A start takes it, no view has an archive branch, and neither `sweepOrphans` nor archiving the source touches its analysis, whose own row is not archived, so it keeps taking messages; the retention sweep deletes it only with the source. Archiving ends the run's processes and deletes nothing an analysis reads: the CLI transcripts, attachments and artifacts go only at the permanent delete (`RunTeardownService.purge`), with the rows, and no analysis read touches a CLI transcript. Known limit: `SubagentRecoveryService` skips an archived run, so a delegate whose ending was unknown when the run was shelved stays `untracked` in the rows.
- Its five tools (`read_analyzed_thread`, `report_recommendations`, `mark_recommendations`, `save_team_change`, `save_project_instructions`) are offered only to an analysis: `ChatService` registers an `AnalysisBroker` sink per turn only when the run has a source — or is a team's builder chat (below) — and keeps it past the turn with the chat's other kept tools (`keepHostTools`), because the CLI works on by itself when a background sub-agent or command reports, and reads and files the card there; the next turn's registration replaces it. A hidden lessons chat's sink dies with its turn. (`save_team_change` is also a builder chat's — `.claude/rules/daemon-host-tools-team-proposal.md`; `save_project_instructions` is every chat's, and so are `read_teams` and `propose_team`, for a change the user asks for in their own words, which its guide's *Beyond the card* tells it needs no Apply.) The sink carries the source and snapshot, so no tool takes a run id from the model.
- **Builder chats** (`Run.editsTeamSlug`) get the team analysis's reader and card too (user decision: the dock has the same tools and information as "Analyze & improve"). Each turn snapshots the team's `BUILDER_CHAT_ANALYSED_RUNS` newest runs, archived ones included, as it begins (`ChatService.builderAnalysisTurn` over `utils/run-snapshots.ts`, the snapshot `ThreadAnalysisService` takes too), read before any host tool registers; a team with no run, or a failed read (logged), leaves the turn without the analysis tools. Nothing is stored on the run. Its brief carries the team analysis's method (`builderChatAnalysisGuide`, the same sections as `teamAnalysisGuide`) in a `<team-analysis>` block, with two differences: repo items point at the runs' own repository (each run's `cwd`), since the builder works in the library, and a selected `W-`, `O-` or (for a project that runs this team) `P-` item goes on ONE `propose_team` card, never a save (its `save_team_change` stays a dry run), with `recommendation_ids` naming them, and is marked once that card's verdict arrives. The Apply route takes a builder chat's card (`RecommendationsApplyService`). Known limit: the builder runs in the library directory, which a team analysis is kept out of, so an agent reading run output there sits beside every team file — and every project's overlay under `overlays/`, which it can write without a card — under the builder's `acceptEdits` default (accepted: the same reach the library files already have; an overlay written that way is still parsed and checked at every run start, and refuses the run rather than running a broken one).
- `read_analyzed_thread` pages ~22KB (codex cuts a tool result near 10k tokens): timing from `ThreadTimelineService` (the waterfall's UNCAPPED fold plus id-paired tool durations and the critical path, cached per `(runId, snapshotSeq, working)`, after the run's call membership is stamped), rows clipped at 2KB, one row in chunks. view=spans takes `failed` (only failed tool calls, each with its call's input and its result's error text clipped to `FAILED_SPAN_TEXT_CHARS`, read in one statement per `SPAN_TEXT_WINDOW` spans of the page, `ItemDao.rowsAtSeqs`) and `tool` (a case-insensitive part of the tool name); either alone reads tool spans only. view=items takes `role`, filtered in `ItemDao.analysisPage`; view=items with `failed` answers the very page view=spans `failed` does (one path, `spans`), so an analysis that reaches for items finds the failed calls with their input and error text too. view=failures and view=userMessages answer across every run the analysis reads (`turn.system.runs`, `turn.team.runs`, else the source; `runId` narrows to one readable run) in one fold kept for its later pages like view=runs (`cursor`, `RUNS_CHANGED` once lapsed): failures are the timelines' failed tool spans named by `toolMetricOf`, grouped by tool and `errorSignature` (`utils/failure-groups.ts`; a JSON body's bare error code is signed with its message beside it), their error texts read by `failedCallErrors` (one statement per window of result rows), every call counted, only the examples capped at `FAILURE_GROUP_EXAMPLES`; user messages are `ItemDao.userMessagesInOrder` up to each snapshot, clipped to `USER_MESSAGE_CHARS`. Each answer's `note` says what it leaves out and how to read the rest. They exist so an analysis clusters failures and reads the user's corrections in a few calls: a Code Mode script that paged every span and message of every thread made thousands of calls per analysis, and per-thread filters alone still left hundreds. An overview past `OVERVIEW_BYTES` clips each goal's evidence first and keeps every goal, then shortens `goals`, `pitfalls` and the tool and critical-path lists, and touches `nodes`, `stages` and `calls` only once none of those can shrink (`fitToBudget`'s `lastResort`). Images are collapsed (`collapse-image-blocks.ts`, twin of the renderer's export) and secrets masked before any cut; every answer leads with `HISTORY_RESULT_PREFACE`.
- `report_recommendations` names every problem in one refusal, from every check, since each re-send regenerates the card's whole text (a card failing the schema names its schema issues first, since the other checks read a parsed card). A refused card (one failing the schema too) stays in the turn's sink (`AnalysisReportsService.sinkFor`, in memory only: the turn holds its text anyway and a restart ends the turn), and `patch` — entries merged by id, member or title, each field sent replacing that field (`utils/recommendations-patch.ts`), `remove` taking entries off — re-runs every check on the result: refused again it stays as the newest kept card, passed it is filed like any card. A new whole call replaces it, a recorded card or the next turn drops it, and a patch with none kept is refused `NO_KEPT_CARD`, naming the whole card as the way on. It refuses an evidence seq that does not exist at or below the snapshot, a team item for a plain chat, a memory item while the shared memory is off (the guide then leaves the memory target out too), a duplicate id, an id whose `W-`/`R-`/`U-`/`M-`/`P-`/`O-`/`K-`/`X-` prefix contradicts its target, an external item whose `location` is not a repository's absolute root, a project item whose `location` is not the project of an analysed run (or any project item when none has one), an item with no `territory`, a hotspot naming an item the card lacks or (in a team analysis) a member that took no turn in the analysed runs, and a member assessment that breaks its rules (below). Each item keeps to one territory, `process` (how the agents work) or `domain` (what the work itself needs to know), and the card tags it; the guide has a finding that needs both filed as two items. Every item carries the agent's estimate per run (`impact.minutesSaved`, `impact.costSavedUsd`, negative for a change that adds, null dollars when the runs report no cost) and its `impact.outcome`; the card's `hotspots` say where the time and money went and which items address each. Both are required in the tool's arguments and optional in the stored payload (`CardRecommendationItem`), so an older card still reads. The card's timing strip is measured by the daemon, never taken from the agent.
- **Pull requests after done** (user decision: an analysis judges how a pull request moved on GitHub after the team said done): `PullRequestAfterDoneService` takes the pull requests a run itself named up to its snapshot — `Run.pullRequests`, `Run.touchedPullRequests` and its `run_outcome` rows, never a listing — with their done marks (`utils/pull-request-done-marks.ts`: the first recorded outcome, and each message or reasoning row holding `DONE CHECK` or `DELIVERY REPORT` in capitals that names the pull request, found through the `chat_text` index, `ChatSearchIndexDao.runRowsMatching`), and asks `PullRequestLifecycleService` for each one's GitHub life in one budget per read (`LIFECYCLE_READ_BUDGET_MS`; what is left answers `read-budget-spent` and is read next time). The life is `utils/pull-request-lifecycle.ts`: ready and draft events, pushes dated by the check suites and Actions runs their heads started (a force push by its event; a commit's own date never, a rebase rewrites it), review threads by their first comment (a `Bot` author or a `[bot]` login is a bot), changes-requested reviews, failed checks (Actions runs of a `pull_request*` event; a run started by hand is not one), what was skipped while it was a draft, and `mergeable` now (GitHub dates no conflict). `view=runs` gives every pull request of a run its `lifecycle` (`lifecycleSummary`: the times, `afterDone` counted strictly after the first mark, `afterReady`), a pull request with no recorded outcome listed with `outcomeRecorded: false`; `view=pr` lists one run's, and with `pullRequest` (`owner/repo#N`, its URL, or `#N` when one has that number) answers that one's events in time order beside the done marks, each with the run's newest message at or before it, asking GitHub about that one alone; a pull request the run only links to from its messages (`PullRequestAfterDoneService.mentioned`: one repository's `github.com/<o>/<r>/pull/<N>` in a message, never reasoning) is read the same way and marked `onlyLinkedFromMessages`. Done marks come from messages only, never reasoning. A team card's `teamStats.pullRequestsAfterDone` is measured when the card is filed (`pullRequestsAfterDone` in `utils/team-runs-fold.ts`): per team version, the pull requests its runs named (one named by two runs counts once), how many were read with a done mark, and their average bot and human threads, pushes and failed checks after it; absent when no run named one, and a card without it still reads. The guides' "PR after done" step has the analysis say, for each event after the mark, who should have caught it first, and the team report's section 3 tables it.
- **Member assessments** (`members` on `report_recommendations`, `MemberAssessmentSchema`): a team-kind card (a team analysis, a builder chat, a thread analysis of a team run) marks each member's usefulness and quality 1–5 (null when the runs give too little to judge) with cited rows, a summary and a verdict (`keep` / `tune` / `reconfigure` / `replace` / `remove`) naming the `W-`, `O-` or `P-` items on the same card that carry it out (`MEMBER_VERDICT_TARGETS`: a project's overlay beats the team, so a model it sets is only changed there). `checkMembers` refuses: any assessment on a plain chat; none at all on a team card while some member took a turn; a member assessed twice or that took no turn in the analysed runs (the card's `teamStats.agents`, or a thread analysis's own timeline lanes); an item not on the card or of another target; `keep` naming an item, and any other verdict naming none or resting on two null marks. Evidence is checked like an item's. The ledger (`member_assessments`, `MemberAssessmentDao`, teardown-exempt) is filed by `RecommendationLedgerService` from the same `recommendations` rows (live and by the boot sweep over `RunDao.teamLedgerChats`), with the runs the card read (`teamStats.runList`'s ids, the source alone for a thread analysis), the library version and the items' titles; a thread analysis files its assessments under its source run's team and none of its items, which stay with the thread. Each row keeps the judge (the CLI and model the filing chat ran as). An older profile's table also has `user_verdict`, `user_note` and `user_verdict_at` columns, which no entity property names and nothing reads or writes; the safe schema sync never drops them, so their values stay on disk — never drop or reuse them in a migration. `judge.sameVendor` compares the judge's vendor with the member's in the newest version its runs ran, both through `AgentAdapter.modelVendorOf` (`AdapterConfig.modelVendor`: one vendor per CLI, or per model id prefix); `GET /v1/teams/:slug/analysis-judge` (`AnalysisJudgeService`) answers the same for a judge the dialog is about to start, with the agents whose every model is another vendor's. `GET /v1/stats/teams/:slug` answers each member's assessments newest first with the versions their runs ran (from those runs' thread rows, never the library at filing) and what became of their items (`recommendationStatusOf`, as the history counts it; null for a thread analysis), and view=history carries the same `members`.
- **Knowledge items** (target `knowledge`, ids `K-`, kind `add` / `update` / `retire`, offered while `KnowledgeService.agentsMayWrite`): `document` names the place key and, for an existing one, its handle and the rev read; `change` is the document's whole text, so at most what any item's `change` holds (`KNOWLEDGE_ITEM_MAX_TEXT`). A move is two items, the K- item's `movesWith` naming the W-, R-, U-, P- or O- item with the other side (`checkItems`, one document per item), and an Apply selecting only one of them is refused `MOVE_SPLIT`, as the card ticks them together. `report_recommendations` asks the store first (`KnowledgeService.checkRecommended`), so nothing the write would refuse reaches a card. The write is `knowledge_save` with only `item` (listed on an analysis turn, `KnowledgeItemsService`): the daemon reads the text from the card, so the model sends none, only for an id in the NEWEST Apply. User decision: pressing Apply on that text is the review, so `KnowledgeService.applyRecommended` writes it live and approved whatever `agentWrites` says of an agent's own write, its author still the agent, and `retire` archives the document, the one way an agent reaches an archive. A read-only store refuses. Order, so the text is never in neither place: a W-, P- or O- item moving out is refused `MOVE_DOCUMENT_FIRST` until its document is marked applied (`moveOrderRefusal`, in `save_team_change` and `save_project_instructions`), and a retire `MOVE_SOURCE_FIRST` until its partner is. Known limits: R- and U- items are written with the agent's own file tools and a `propose_team` card sent without `recommendation_ids`, which no daemon check holds to the order; the guide does. A project's own chat holds no recommendation card: its brief has the same rule (`WHAT_GOES_WHERE`) for proposing a move in words.
- **External items** (target `external`, ids `X-`; user decision: a request about a repository the runs did not work in stayed as words, and an analysis must not write there): `location` is that repository's absolute root folder on this Mac, holding its `.git`, and the check refuses any other. Apply stays a model turn: the guide has the agent call `create_task` (a project whose folder it is, else the analysed run's project with `folder` set to it; the quiet column, so nothing starts unasked; `TaskBoardToolService.refuseUnattended` still guards a non-`auto` chat) and mark the item `applied` with the card's key in the note, `failed` when none could be filed. So in the ledger and `view=history` an applied `X-` item means filed, not done, and the guide sends a later analysis to the card. No daemon check ties a mark to a card. A change to code beyond instructions, checks and rules — Geniro's own included, when its repository is on this Mac — is an `X-` item too, never words in the reply.
- **Every proposal goes on the card** (user decision): the guide (`theBar`) has the analysis file every change it would propose, an unsure one with a low `confidence` rather than dropped or left in the reply; every weak or poor instruction-quality mark carries the item that fixes it (cited from a turn that carried the text when the runs show no cost, with 0 minutes saved); a hotspot with no item says why none can reach it; and a recommendation the user skipped or passed over may come back when it would still help a lot, its `basis` saying when it was offered and what the user answered — never while the user's note still rules it out. `MAX_RECOMMENDATIONS_PER_TARGET` (20) leaves room for it.
- A `user` item edits an agent's own standing-instructions file, which reaches every project that agent works in. Its path is an adapter fact (`AdapterConfig.userInstructions`, resolved by `AgentAdapter.userInstructionsFile` under the run's `configDir`), listed to the analysis in the overview's `source.userInstructions` (chat) and in view=team's `userInstructions` (every member and pool member the run's snapshot ran), each with its size as it stands now (`sizedUserInstructionFiles`: its own length, not what it imports; `exists` false for a missing file, null for one it could not stat or a CLI that keeps none). Never spell a path in the guide.
- view=team's `instructionSizes` is every member's always-on block (`InstructionSizesService`, the member sheet's measure) composed from the library's copy with the read run's own `customInstructions`, `projectInstructions`, `memoryIndex`, `taskInstructions` and `replyLanguage` (`AnalysedTeamRef.instructions`; none when that run is gone), plus `inThisRun` where the run's own copy composes a block of another length. Beside it, `freshSessionBase` (`FreshSessionBaseService` in `v1/teams`, the team page's `POST /v1/teams/:slug/fresh-session-bases` too) is what each member's fresh CLI session started with: the pure fold `utils/fresh-session-base.ts` takes the first `turn_complete` of every CLI session in the team's newest `FRESH_SESSION_RUNS_READ` runs (`ItemDao.memberTurnReadings`, read inside the engine; the executor stamps `sessionId` on every member turn's `turn_complete`, own turns and calls alike, and `nodePoolMember` when the turn runs as a pool member; a start whose row names no CLI or model takes the member's as the team defines it now), per member, pool member and project (the read run's project only, when it has one), and medians the newest `FRESH_STARTS_PER_MEMBER`; each start reads the turn's FIRST request (`AgentUsage.firstRequestContextTokens`, claude's `usage.iterations[0]`) and falls back to its last only where the CLI reported no first, and `baseSource` says which (`lastRequest` as soon as one start fell back). It is split into Geniro's block (the same measure), the repository files measured from disk now under the adapter fact `AdapterConfig.repoInstructions` (`utils/repo-instruction-files.ts`: the file names from the folder up to the repository root, `@`-imports, rules without `paths:`) and the CLI's remainder, never clamped; MCP servers come from the harvest with their date (`McpHarvestStore.getStaleReading`). The CLI's own breakdown is stored (user decision, replacing "nothing is stored"): when a member's session opens (`resumeSessionId` null, its `session` event), the executor asks the live process once through `AgentAdapter.readContextUsage` (`FreshSessionContextRecorder`, best-effort, no model turn) and keeps the answer in `session_context_readings` (runtime data, purged with its run). `contextReading` carries the newest one per member, pool member and group, projected by `freshSessionContextReading` so a reader cannot take what is not in the window for what is: `inWindow` (the CLI's parts, summing to `cliTotalTokens`), `reserved` (room the CLI holds back, claude's `kind: "buffer"` row), `onUse` (deferred schemas), and per MCP server `inWindowTokens` (its loaded tools' schemas, `AgentContextServer.loadedTokens`) apart from `onUseTokens` (the schemas it only offers on use); a deferred tool sits in the window by name, which the CLI prices nowhere, so no per-name figure is made up. `firstRequestLessCliTotalTokens` is that session's first request less `cliTotalTokens`, never clamped and null when either is unknown; it is commonly negative, the CLI's parts adding up to more than the first request, and it is unrelated to `cliRemainderTokens`. With a reading, only `plugins` stays in `notMeasured` (user decision: no estimate, no second probe session): the CLI ties a plugin's skills and agents to its `pluginId`, but not what its hooks add, and plugin skills share one listing budget with every other skill, so a sum per plugin is not what a plugin costs; without one, plugins, skills and built-in tools are listed as not measured, never zero. A read that fails costs view=team only this part.
- The overview counts failed tool calls (a `tool_result` with `isError`, paired in `pairToolCalls`) and sums the tokens and cost the CLI reported; a figure no turn reported stays null. It also lists the run's goals with their evidence (`run_goals`, as they stand now), its outcome (the newest `thread_outcome` row at or below the snapshot, else derived from the goals, through `threadOutcomeOf`, so it carries `divergesFromGoals`), its team notes' count and the current `pitfall` notes up to the snapshot (`pitfallNotes`, and `pitfalls`: the newest `OVERVIEW_PITFALLS`, each clipped to `OVERVIEW_PITFALL_CHARS` with a pointer to view=item), each MCP server's calls and failures (whichever adapter's `toolCallMetric` reads a server off the name), the stage moves and the calls between members.
- **Project instructions** (target `project`, ids `P-`): an analysis reads them through `read_analyzed_thread` `view=project` (answered by the reader, masked, then paged): each analysed run's project (`ProjectScopeService.projectOfRun`) with its description and instructions as they stand, the `instructionsRevision` a write quotes, each run's start copy (`Run.projectInstructions`) where its text differs — compared without the `Project:` line, so a rename is no difference — and the newest 20 rows of `project_instruction_changes`; the overview names the run's project too. The analysis chat itself is created under the analysed run's project (a team analysis: the one project its runs share, else explicitly none), so its memory writes land there. `save_project_instructions` (`ProjectInstructionsChangeService` in `v1/agents`, over `ProjectsService.update`) writes only the instruction blocks (the whole ordered list: a kept id edits a block, a new id adds one, a missing one is removed), never the description, only for `P-` ids selected in the NEWEST Apply and filed on that card about the same project, only for a project of the analysed runs, and only at the quoted revision (`REVISION_DRIFT` otherwise); the write is logged with source `analysis`, the ids, the chat and the card seq, and announced as `projects_changed`. Those rules hold for a call carrying `ids`. A call without them is a change the user asked for in words, to any project (`projectId` + `blocks` + `baseRevision`; the agent reads the project first with `list_projects` naming it in `project`, which answers its description, blocks, `instructionsRevision`, `instructionsChars` and `instructionsMaxChars`), written through `saveForChat` and logged with source `chat` and that chat's run id. Every chat is offered it so: an analysis and a builder chat holding the analysis tools with `ids` optional, an ordinary chat or a builder chat with no runs naming the project, and a project's own chat with `projectId` optional (`.claude/rules/daemon-projects-tasks.md`). The tool's gate is the card sink alone (`ProjectInstructionsBroker.canPropose`), which `ChatService` registers for every chat's turn, and the team executor for a team run's lead only (`.claude/rules/daemon-host-tools-team-proposal.md`). A block sent as its id alone keeps that block as it stands, a missing title or text keeps that part (`resolveProjectBlocks`), and the filled-in list is held to the write's own rules before any card (`checkedProjectChange`: `UNKNOWN_BLOCK`, `INVALID_BLOCKS`, `INSTRUCTIONS_TOO_LONG` with `chars` / `maxChars` / `charsNow`), so the user never approves a change the write would refuse; `view=project` names `instructionsChars` and `instructionsMaxChars`. A change that passes those checks is not written by the call: it parks on an `approval_request` card (`ProjectInstructionsBroker`, registered per turn as above) showing the changed lines as unified hunks (`instructionsDiff`) and the `P-` ids it carries out, in every approval mode, and only that card's Apply writes it (`ProjectInstructionsChangeService.write`) — deferred like a patch on a CLI that will not hold the call open (`Run.pendingQuestion` kind `project`). The call itself is auto-approved (`isHostProjectInstructionsCall`), since the card is the gate. The ledger files `P-` items from team analyses like any other target. A builder chat's `P-` items for a project that runs its team go on its `propose_team` card instead (`recommendation_ids`, held by `TeamProposalService.carrying` to the same rules: newest Apply, the move's document first, filed about that project), so one approval writes them and the project log keeps the ids with source `analysis` and the card seq.
- The mark that completes an Apply answers telling the agent to call `record_outcome` (`everySelectedMarked`), the moment the thread's outcome is known; the guide says the same. An Apply (`POST /v1/chats/:runId/recommendations/apply`) is a user message carrying the selected items in full and `payload.apply: {cardSeq, ids}`; it is refused `RUN_BUSY` while a turn runs, never delivered mid-turn, and `ALREADY_APPLIED` for a card that already has one (the renderer reads "applied" from its window only). `save_team_change` (`TeamChangeService`, in `v1/teams`) writes only `W-` ids in the NEWEST Apply (user messages read in seq order), refuses a hash drift, a deleted file and an invalid team, and writes a timed backup first. It is not auto-approved. `save_project_instructions` holds the same Apply rule for `P-` ids (see *Project instructions* above).
- A builder chat's `save_team_change` runs under `TeamChangeService`'s `builder` authority, always as a dry run (its change is written behind `propose_team`'s card — `.claude/rules/daemon-host-tools-team-proposal.md`): no Apply and no `ids`, `baseHash` or `dryRun` argument (all refused), the same edit and team checks, and its edits apply to the file as it stands. Its version check is per turn: the sink records when the turn began, and the turn's first check is refused (`HASH_DRIFT`) when the file was written after that — the editor does not save while the chat works, so something else wrote it; every later check is held to the hash the last one read or a refusal reported (`TeamBuilderBroker.noteVersion`). A `configDir` it wrote back as a `read_teams` token is restored (`restoreConfigDirs`, `CONFIG_DIR_UNKNOWN` for one naming no profile of this team). An approved card backs the file up; there is no backup tool.
- `save_team_change` takes EDITS (`teams/utils/team-edits.ts`: unique `find`/`replace` in a string value — unique in the whole team, or only under the field or part its optional `path` names — `path` set or remove), and every applied set answers where each edit landed (`landed`, list elements named by id), applied to the library copy as it stands (an analysis's at the hash it quotes). A `path` walks own keys only and refuses `__proto__`, `constructor` and `prototype`: the model writes it. Never take the whole team back: a library team runs to 250KB, and re-emitting it as tool arguments was minutes of silent generation per save.
- Timeline spans are clipped to the read's `[from, to]`; the critical path takes, at each step, the work still going latest before the cursor (an interval running past the cursor counts up to it); tool calls pair by member, call and id (ACP ids restart per session). Whether the source was working at the snapshot is recorded at the start (`Run.analysisSourceWorking`) and every read folds with it, so one snapshot always folds the same.
- **Team analysis** ("Analyze & improve", `TeamAnalysisService` in `v1/teams` over `ThreadAnalysisService.startTeam`, `GET /v1/teams/:slug/analysis`, `POST /v1/teams/:slug/analyses`): the same chat, tools, card and Apply, reading the team's runs started within the `days` period (`AnalyzeTeamDto.days`, 1 to 365), archived ones included (user decision: the runs still on the desk are no sample of a team), newest first, at most `MAX_ANALYSED_TEAM_RUNS`, instead of one thread. `GET /v1/teams/:slug/analysis-runs?days=N` (`countTeamAnalysisRuns`) answers `{ inPeriod, analysed }` through the same `ThreadAnalysisService.teamRunsSince` selection `startTeam` reads, so the count the dialog shows is the set an analysis would read. `Run.analysisTeamSlug` names the team and `Run.analysisRuns` (`utils/analysed-runs.ts`) each run with its own snapshot seq and working flag; `analysisSourceRunId` stays null, so every "is this an analysis" check reads both columns (`listChats`, chat search, the proposal gate, Apply, `ANALYSIS_OF_ANALYSIS`). The runs are chosen by the daemon from every run of the slug, never from a client's list; a run with no rows is skipped, none left is `ANALYSIS_NO_RUNS`.
  - It belongs to the team: deleting one of its runs keeps it, deleting the team deletes it (`TeamChatService.deleteTeam`), and a boot sweep deletes those whose library file is gone (`TeamAnalysisService.sweepOrphans`). One per team, replaced on the same terms as a thread's. It runs in the folder the dialog sent, else the newest read run's that still exists (an archived run's worktree may be gone); with neither it is refused `ANALYSIS_FOLDER_GONE` and the dialog asks — never the library directory, which would put an agent reading untrusted run output beside every team file.
  - `AnalysisTurn.team` carries the runs; `sourceRunId` is the newest of them. Every `read_analyzed_thread` view takes `runId`: those runs, or any other run of the team (user decision: everything can be read, and the analysis pays only for what it reads, so the guide opens one only for a concrete question and never sweeps them). `ThreadReaderService.readSourceOf` opens it against the daemon's slug, refusing `RUN_GONE` (a deleted run has no rows), `NOT_A_TEAM_RUN`, `OTHER_TEAM_RUN` and `RUN_EMPTY`, and pins it in `AnalysedTeam.opened` at its first read (`runSnapshotOf`: its newest row and working flag together), in memory on the turn's own object: first wins when two reads race, and a later turn, like a builder's sample, reads it afresh, which only adds rows. A thread analysis takes none but its own (`NOT_ANALYSED`). `view=runs section=otherRuns` (`TeamHistoryService.otherRuns`, paged by the tool's reader like view=spend's sections) lists those runs newest first, each with its title, date, status, whether it is archived and its cost over every row its ledgers hold (`TeamStatsService.totalsOf`, what `population` sums), bounded by nothing; `view=runs`, `teamStats`, `view=project` and the card's project and member checks keep to the sample. `view=runs` states the population beside the sample (`runsRead`, `population`: every thread row of the team, a deleted run's included, with cost, worked time and turns per run, `TeamStatsService.population`, handed in by the tool like the version index since `v1/agents` may not import `v1/stats`; null when it cannot be read), and answers each run's totals, its questions to the user and each pull request's outcome with its history figures (`RunOutcomeHistoryService`, through the run's snapshot) with every node's work in that run (`runs[].nodes`, `runNodeFigures`: the lane's turns, tools and bill, its working time — the CLI's own plus the `wall_turns` ledger through the run's snapshot (`servedWorkedMs`), as in `nodes` — and from the timeline its busy and blocked wall time and its share of the critical path, null for a node with a completed turn its CLI did not time, whose span the waterfall draws from the lane's previous row and which measures nothing; `models` times only measured turns, `timedTurns`), every node's totals (`nodes`, from the waterfall's lanes: the true turn count and a polled-spend CLI's bill), every caller→callee edge's calls over the runs (`calls`, `callFigures`, from the waterfall's call spans, with `workedMs`: how long the callees worked inside them, `callWorkedMsByStart` matched to each span by its `call_started` seq — CLI durations plus `wall_turns`, which `view=spans` puts on each call span too; the call card's clock is a different measure, the call's open time), and every node's turns per CLI and model (`models`, from the turn spans; a turn that reported no model — a failure, a Stop — is counted on the model its node last reported in that run; one before any report is filed apart under the model the run's own frozen copy configured (`configuredModels`, never the live `node_state.model`), `modelSource: 'configured'`. A pooled node is followed per member: every waterfall turn carries `member` — the CLI and configured model its own usage row (`turn_complete`, or a failed turn's `error` / `turn_cancelled`) names, member 1 when the row names none (`ChatWaterfallService`, `poolMemberOf`). A pool hand-off (`ItemDao.poolHandOffRows`, the executor's `nodePoolHandOff` row) splits the open turn: the attempt handed on is drawn as a failed turn of its member, and the rest goes on as the member the row names, so a member that keeps hitting its limit counts its failures. A pooled turn no row names a member for is left `model: null`, `modelSource: 'unreported'`), each over every row of each run up to its snapshot (`utils/team-runs-fold.ts`) — what the guide (`teamAnalysisGuide`) compares models and the graph's structure from, and what its report (`TEAM_REPORT`: the versions with a verdict on each earlier change, each run's questions and pull-request outcomes, a verdict on each agent's model, instruction size and a graded instruction quality, section by section in the reply before the card — never a figure the card draws) copies its figures from. It is masked whole, then paged like `view=team` (`pagedAnswer`, `offset`), never cut; a read from offset 0 folds afresh and keeps its text per run set for five minutes after its last read, so every later page is cut from that text; a later page asked after it lapsed is refused `RUNS_CHANGED` (read again from 0).
  - Versions: `view=runs` names each run's team version (`snapshotVersion` over its own frozen copy, the hash the team ledger stamps) with its number and whether it is the library's now, and folds the analysed runs per version (`versions`, `versionFigures`). The numbers are the stats module's (`TeamHistoryService.versionIndex`), handed to `ThreadReaderService.read` by the tool, since `v1/agents` may not import `v1/stats`; a failed read names versions by hash alone.
  - History (`view=history`, answered by the tool from `TeamHistoryService` in `v1/stats`, masked whole, then paged by `historyAnswer` in the tool's reader): a history that fits one page answers whole; a longer one answers its summary and each section's size, and `section` (`versions`, `changeLog`, `recommendations`, `members`) reads a page at a time, cut between records and each page valid JSON on its own, a record past a page coming in parts (`part`). A version record carries only its diff's `added` and `removed`; the diff itself is `section=diff` with `version`, cut on line breaks. `offset` with no section still cuts the old chunks of the whole answer, for a chat mid-read across an update. It holds every recorded version newest first with its diff (`TeamVersionsService`) and figures over EVERY run the ledgers kept, deleted ones included (runs, cost, turns, the CLIs' own worked time, pull-request outcomes — `foldTeamHistory`); the change log; and every recommendation filed about the team with its status (`applied` / `skipped` / `failed` as marked — for an `X-` item, applied means its card was filed — `selected` in an Apply but never marked, `not-selected` when an Apply took others from its card, else `open` while its chat exists and `unanswered` once a new analysis replaced the card before any Apply — never decided, so the guide files it again when the runs still call for it), its estimates (`expectedMinutesSavedPerRun`, `expectedCostSavedPerRunUsd`, `expectedOutcome`), linked to the logged change that carried it out. Offered to any analysis with a team (`analysedTeamOf`): a team analysis, a builder chat, a thread analysis of a team run.
  - Spend (`view=spend`, answered by the tool from `TeamHistoryService.spend`, masked, then paged by `spendAnswer` in the tool's reader; pure fold `foldTeamSpend` in `v1/stats/utils/team-spend-fold.ts`, `NOT_A_TEAM` for a plain chat): every `usage_events` row of every thread row stamped with the team, so archived and deleted runs count whatever the analysis samples, in three windows (all, the last 30 days, the analysed runs) each saying what it covers, and per project, member and model, none capped; past one page those three are read by `section` like view=history's. A turn is filed under the project its folder belongs to (`ProjectRootsService` + `nearestProjectOf`), one row per project; a folder in no project is named by its last segment alone, since these runs can be work the analysis was never started on. A turn's bill is apportioned among input, cache read, cache write and output by its tokens at `AgentAdapter.billingRatesOf`, the catalog's rates with `AdapterListPrice.cacheWriteInputMultiple` where the CLI writes a longer-lived cache than the catalog prices, so the parts sum to the bill (each is then rounded to the cent, so a row's parts can read a cent or two off) whatever tier or delegate money it holds; polled money and a model with no list price are `notSplitUsd`. `largestCacheWrites` names 10 rows and bounds no count.
  - The change log (`team_change_log`, `TeamChangeLogService` in `v1/teams`, teardown-exempt) gets one entry per library write geniro makes on someone's say-so, AFTER the file is written (a failed log write is logged and never refuses the save): an analysis's applied save (`source: 'analysis'`, the Apply's ids and card seq, the items' titles), an approved `propose_team` card (`'builder'` when the chat edits that team — its ids read from the card's summary and reason, which the builder's brief has name them — else `'chat'`, with the user's note), a version restore (`'restore'`), and a lesson the user saved into a member's instructions (`'lesson'`, the source thread as its chat, with the backup). Each carries the team versions it moved between. An editor save is not logged: a version no entry made reads as edited by hand.
  - The recommendation ledger (`team_recommendations`, `RecommendationLedgerService` in `v1/stats`, teardown-exempt) copies every `recommendations` card a team analysis or builder chat files, every Apply selecting from one and every `recommendation_outcome` mark, off `bus.all()`, serialized per chat, with a boot sweep over the chats that still exist; a card is filed once, the first selection stands, and a mark moves forward only by its row's seq. A new analysis deletes the chat it replaces, so this copy is the only record of what was recommended before.
  - Evidence names its `runId` and is checked against that run's snapshot, a run outside the sample against the pin its read made: one this turn has not read is refused, since a citation never pins anything, so no seq past what the agent could read passes. The card carries no timing strip (one run's would pass for the team's); it carries `teamStats` instead (`teamCardStats` in `utils/team-runs-fold.ts` over `ThreadReaderService.foldRuns`, the folds `view=runs` answers from): averages and totals over every analysed run at its own snapshot, each run with its version number (the tool hands `report_recommendations` the stats module's version index, as for `view=runs`), each agent's working time, share, critical path, calls and cost — every per-run figure divided by the runs that measured it — with its models, the longest caller→callee edges with the uncapped edge count, and `population`, so a sample and its savings estimates read against every run the team has. It is measured when the card is filed, never taken from the agent, and read back with `.catch(null)`, so a stats block that no longer parses never makes the card unreadable to Apply, marks or the ledger. `view=team` and `save_team_change` act on the analysis's own slug (`ThreadReaderService.analysedTeamOf`); `view=team runId=…` sets the library against that run's own copy. Every "is this an analysis" check on a row is `utils/analysed-runs.ts` `isAnalysisRun`.
- **System analysis** (Settings → System analysis, `v1/system-analysis`, `/v1/system-analyses`; user decision: one place that reads every troubled thread of a period, geniro's own analyses and lessons chats included, and files what geniro itself should fix): a hidden analysis chat with `Run.analysisPurpose = 'system'`, `analysisRuns` the pinned threads and `analysisDigest` the frozen digest. It is created only from Settings (desktop only), never from a thread, and `isAnalysisRun` is true for it. It is a system chat (`systemKind` `system_analysis`): `listChats` returns it only with `includeSystem` and chat search finds it, while `list_threads` and the command center never return it (every hide site there filters `analysis_purpose = 'system'`, the Kysely ones through `notSystemAnalysis`). Lessons reflections stay out of every listing and search (`NOT_LESSONS_REFLECTION`, its Kysely twin `notLessonsReflection`).
  - The digest (`SystemDigestService.build`, pure fold `foldSystemDigest`) reads the ledgers first — flags (`agent_flags`, agents' and the daemon's own, told apart by `automatic`), failed tool calls (`tool_call_events`), thread outcomes, unmet goals, lessons dropped by the check — then the transcripts of at most `SYSTEM_DIGEST_PAYLOAD_CANDIDATES` best candidates of each group (geniro's own threads and the user's, `withSystemSlots`) for corrections and refused approvals, one run per turn of the event loop. A thread with no signal is left out; at most `SYSTEM_ANALYSIS_MAX_THREADS` of the user's threads and `SYSTEM_DIGEST_SYSTEM_THREADS` of geniro's own (thread and team analyses, lessons reflections and checks, and earlier system analyses — user decision; a starting analysis is created after its digest is built, so it is never its own entry) are pinned, each group ranked apart by `SYSTEM_DIGEST_WEIGHTS`, ties to the newest activity then the run id; a full group never takes the other's slot. Flags of deleted runs are kept under `goneFlags` (the last `SYSTEM_DIGEST_GONE_FLAGS`). Failed tool calls are split by the ledger's `mcpServer` (`failedToolCallsByKind`, per thread and in the totals, over every live thread of the period): `geniro` (`GENIRO_MCP_SERVER`), any other server, and null — the CLI's own shell and file tools, whose failures are mostly ordinary command exits, so the score weighs only the first two. Only geniro's own failures have their error text read (`failedCallErrors` off the ledger row's `seq`, the result row) and are grouped by tool and signature with `groupFailures`: `geniroToolErrors` on the digest (the period, every call counted, the first `SYSTEM_DIGEST_TOOL_ERRORS` groups listed with their thread count, first error text and one example from a pinned thread when one has it, `readable: false` when none has, since the reader refuses any thread outside the digest; `totals.geniroToolErrorGroups` counts every group) and on each thread (its first `SYSTEM_DIGEST_TOOL_ERRORS_PER_THREAD`). The new fields are optional on the wire so a digest frozen before them still reads (`systemDigestOf`). The newest scope read's build is kept in memory (`SystemAnalysisService`), and a start for the same `days` within `SYSTEM_DIGEST_REUSE_MS` of it takes that build — its pinned threads and snapshots — instead of folding the period again; a start always takes the kept build away, and builds afresh when the one it took fails.
  - Reading: `AnalysisTurn.system.runs` is the pinned set; `view=digest` reads the frozen digest, masked and paged, its period, totals and `geniroToolErrors` first so they sit on the first page however many threads and flags follow, then `threads`, `flags` and `goneFlags`; every per-run view takes `runId` of a pinned run (a hidden lessons run included) and refuses any other `NOT_IN_DIGEST`; `view=runs`, `team` and `project` are `UNSUPPORTED`. `view=history` (`SystemAnalysisHistoryService`, exported to the MCP module) lists every earlier system item from the ledger with its mark, what its press did (`applyAction`) and its board card's column by `taskId`, the reader's own chat left out.
  - The digest also freezes the usage counters (`toolUsage`, `DigestToolUsageSchema` in `agents/chat.types.ts`, optional so an older digest reads): the `SYSTEM_DIGEST_TOOL_USAGE_ROWS` most called subjects and every never-called one, each with its figures and `removable`, with a one-line count in `totals.toolUsage` that the scope route carries too.
  - A `G-` item may name a `tool` (subject kind, name and source as `toolUsage` lists them, and a verdict improve / remove / merge / keep / other). `checkToolItems` refuses `TOOL_SUBJECT_NOT_FOR_TARGET` (not a G- item of a system analysis), `UNKNOWN_TOOL_SUBJECT` (not in the frozen digest) and `REMOVE_BELOW_THRESHOLD` (remove on a subject that is not `removable`, naming its figures), in the one refusal that names every problem. When the card is recorded the daemon copies the subject's figures from the frozen digest onto the item (`tool.figures`, with `asOf`), never ones the model typed, and `cardBrief` writes them into the filed card's text.
  - The card proposes only `geniro` (`G-`), `user` and `memory` items (`TARGET_NOT_FOR_SYSTEM`); a `geniro` item outside a system analysis is refused; it has no members, no timing strip and no team stats; `addressesFlags` names flag handles an agent raised. Its ledger rows go under the reserved slug `SYSTEM_LEDGER_SLUG` with `chatKind: 'system'`, `taskId` and `applyAction`.
  - Apply is the report's button, never `POST /v1/chats/:runId/recommendations/apply`: `POST /v1/system-analyses/:runId/apply` (`SystemAnalysisApplyService`, no model turn for G- items) — `cards` files each picked G- item with `TasksService.create` in the picked project (its quiet column, `source: 'system_analysis'`, `sourceRef` `<runId>:<cardSeq>:<itemId>`, an existing card by that ref reused), `implement` also writes an approved start request of kind `analysis`, `report` files nothing and marks every item skipped "Kept as report". Each outcome is a `recommendation_outcome` row (`filed <KEY>`, `filed to start <KEY>`, `started <KEY>`, `could not start <KEY>: <reason>` for a filed card whose start failed, or failed with the reason; the card reads the key from each, twin of `systemOutcomeOf` in the renderer); the Apply row is persisted without a turn when only G- items are picked (`ChatService.recordApply`), else sent as today's message naming only the U-/M- items; a press whose every picked item failed to file writes no Apply row (`apply: null`), so the card stays open for another press, which reuses any card already filed by its `sourceRef`. `SystemAnalysisStartsService` reports each start of an analysis-kind card and each failure the drain reports into the analysis chat as a notice; no manager is woken. A start, an Apply and each reported card start or failure publish `SystemAnalysisEventBus`, broadcast as `system_analyses_changed` (`{runId}`), which Settings' past analyses re-read on.

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.