SessionStore
Defined in: src/store.ts:493
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SessionStore(
path):SessionStore
Defined in: src/store.ts:495
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”SessionStore
Methods
Section titled “Methods”ackEpicMigrations()
Section titled “ackEpicMigrations()”ackEpicMigrations(
repoPath,parentIssueNumber):void
Defined in: src/store.ts:1214
Acknowledge a completed epic’s landing-PR migrations (#645): stamp migrationsAckedAt AND
dismiss the row in one operator action. migrationsAckedAt is the durable audit record of
WHEN the human acknowledged; the coupled dismissedAt is what actually clears the band and
prevents a re-prompt (listEpicCompleted filters dismissedAt IS NULL).
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”void
addHeldTask()
Section titled “addHeldTask()”addHeldTask(
row):void
Defined in: src/store.ts:3165
Parameters
Section titled “Parameters”createdAt
Section titled “createdAt”number
string
repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”void
addLearning()
Section titled “addLearning()”addLearning(
input):Learning
Defined in: src/store.ts:2396
Parameters
Section titled “Parameters”evidence
Section titled “evidence”string[]
rationale
Section titled “rationale”string
repoPath
Section titled “repoPath”string
string
scopeGlobs?
Section titled “scopeGlobs?”string[]
Returns
Section titled “Returns”addMergeSuggestion()
Section titled “addMergeSuggestion()”addMergeSuggestion(
input):MergeSuggestion
Defined in: src/store.ts:2716
Persist a background merge suggestion.
Parameters
Section titled “Parameters”mergedRationale
Section titled “mergedRationale”string
mergedRule
Section titled “mergedRule”string
repoPath
Section titled “repoPath”string | null
repoPaths
Section titled “repoPaths”string[] | null
signature
Section titled “signature”string
sourceIds
Section titled “sourceIds”string[]
targetId
Section titled “targetId”string | null
Returns
Section titled “Returns”addSignal()
Section titled “addSignal()”addSignal(
input):Signal
Defined in: src/store.ts:2089
Parameters
Section titled “Parameters”payload
Section titled “payload”string
repoPath
Section titled “repoPath”string
sessionId
Section titled “sessionId”string | null
Returns
Section titled “Returns”archive()
Section titled “archive()”archive(
id):void
Defined in: src/store.ts:1502
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
attributeInjected()
Section titled “attributeInjected()”attributeInjected(
ids,opts):void
Defined in: src/store.ts:2611
For each id: bump injectedCount + stamp lastUsedAt; bump helpfulCount only when good.
Empty ids → no-op.
Parameters
Section titled “Parameters”string[]
boolean
Returns
Section titled “Returns”void
autoOptimizedAt()
Section titled “autoOptimizedAt()”autoOptimizedAt(
id):number|null
Defined in: src/store.ts:2888
Server-internal getter: the timestamp when reviseLearning last ran on this id. Exposed so tests can assert the autoOptimizedAt stamp without reaching into private db.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number | null
bumpPrReviewHead()
Section titled “bumpPrReviewHead()”bumpPrReviewHead(
repoPath,prNumber,headSha,now):void
Defined in: src/store.ts:3124
Re-point an existing pr_review at a new head without changing the verdict. No-op when no row exists.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
prNumber
Section titled “prNumber”number
headSha
Section titled “headSha”string
number
Returns
Section titled “Returns”void
bumpReviewHead()
Section titled “bumpReviewHead()”bumpReviewHead(
sessionId,headSha,updatedAt):void
Defined in: src/store.ts:1634
Re-point an existing verdict at a new head without re-reviewing. Used when a head change (rebase/force-push) leaves the reviewed diff content-identical (same patchId): the prior decision/findings/rounds still apply, so only headSha + updatedAt move.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
headSha
Section titled “headSha”string
updatedAt
Section titled “updatedAt”number
Returns
Section titled “Returns”void
clearEpicBaseMismatch()
Section titled “clearEpicBaseMismatch()”clearEpicBaseMismatch(
repoPath,parentIssueNumber,childNumber):void
Defined in: src/store.ts:1065
Clear a child’s base-mismatch marker (the PR was re-targeted / merged correctly).
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
childNumber
Section titled “childNumber”number
Returns
Section titled “Returns”void
completeReviewerSpawn()
Section titled “completeReviewerSpawn()”completeReviewerSpawn(
reviewerSessionId,u,completedAt):void
Defined in: src/store.ts:2043
Fill a spawn’s token totals + completedAt once its transcript is read. No-op when the reviewerSessionId is unknown (the WHERE simply matches nothing).
Parameters
Section titled “Parameters”reviewerSessionId
Section titled “reviewerSessionId”string
completedAt
Section titled “completedAt”number
Returns
Section titled “Returns”void
countHeldTasks()
Section titled “countHeldTasks()”countHeldTasks():
number
Defined in: src/store.ts:3198
Returns
Section titled “Returns”number
countSessionBlockingSignals()
Section titled “countSessionBlockingSignals()”countSessionBlockingSignals(
sessionId):number
Defined in: src/store.ts:2633
COUNT of blocking signals (block/stall/critic) for a session.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”number
create()
Section titled “create()”create(
input):Session
Defined in: src/store.ts:1281
Parameters
Section titled “Parameters”NewSession
Returns
Section titled “Returns”deletePushSub()
Section titled “deletePushSub()”deletePushSub(
endpoint):void
Defined in: src/store.ts:893
Parameters
Section titled “Parameters”endpoint
Section titled “endpoint”string
Returns
Section titled “Returns”void
dismissEpicCompleted()
Section titled “dismissEpicCompleted()”dismissEpicCompleted(
repoPath,parentIssueNumber):void
Defined in: src/store.ts:1228
Mark a completed epic as dismissed (hides it from listEpicCompleted).
At land-time there’s no explicit dismiss call: the aggregate landing PR’s
Closes #<parent> closes the parent on merge, and the autoDismissClosed
reconcile (src/server.ts) then dismisses the band once the parent is
confidently closed.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”void
dropPlanGate()
Section titled “dropPlanGate()”dropPlanGate(
sessionId):void
Defined in: src/store.ts:1718
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”void
dropRecap()
Section titled “dropRecap()”dropRecap(
sessionId):void
Defined in: src/store.ts:1871
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”void
dropReview()
Section titled “dropReview()”dropReview(
sessionId):void
Defined in: src/store.ts:1610
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”void
ensureLocalPr()
Section titled “ensureLocalPr()”ensureLocalPr(
repoPath,branch,base):LocalPr
Defined in: src/store.ts:844
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
branch
Section titled “branch”string
string
Returns
Section titled “Returns”generatingHerdDigests()
Section titled “generatingHerdDigests()”generatingHerdDigests():
HerdDigest[]
Defined in: src/store.ts:1975
Rows currently in-flight — used by the service’s finalize loop (restart-safe).
Returns
Section titled “Returns”generatingRecaps()
Section titled “generatingRecaps()”generatingRecaps():
Recap[]
Defined in: src/store.ts:1848
Rows currently in-flight — used by the service’s finalize loop (restart-safe).
Returns
Section titled “Returns”Recap[]
get(
id):Session|null
Defined in: src/store.ts:1337
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Session | null
getBuildQueue()
Section titled “getBuildQueue()”getBuildQueue(
sessionId):BuildQueue
Defined in: src/store.ts:2939
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”getCaps()
Section titled “getCaps()”getCaps():
CapRow[]
Defined in: src/store.ts:1512
Returns
Section titled “Returns”CapRow[]
Implementation of
Section titled “Implementation of”getCreditSnapshot()
Section titled “getCreditSnapshot()”getCreditSnapshot():
CreditSnapshot|null
Defined in: src/store.ts:1527
Returns
Section titled “Returns”CreditSnapshot | null
Implementation of
Section titled “Implementation of”getEpicBaseMismatch()
Section titled “getEpicBaseMismatch()”getEpicBaseMismatch(
repoPath,parentIssueNumber,childNumber): {actualBase:string;checkedAt:number;prNumber:number|null; } |null
Defined in: src/store.ts:1073
A single child’s marker (or null) — drives the doRetire throttle read.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
childNumber
Section titled “childNumber”number
Returns
Section titled “Returns”{ actualBase: string; checkedAt: number; prNumber: number | null; } | null
getEpicRun()
Section titled “getEpicRun()”getEpicRun(
repoPath):EpicRun|null
Defined in: src/store.ts:931
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”EpicRun | null
getHeldTask()
Section titled “getHeldTask()”getHeldTask(
id):HeldTask|null
Defined in: src/store.ts:3186
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”HeldTask | null
getHerdDigest()
Section titled “getHerdDigest()”getHerdDigest(
dayKey):HerdDigest|null
Defined in: src/store.ts:1931
Parameters
Section titled “Parameters”dayKey
Section titled “dayKey”string
Returns
Section titled “Returns”HerdDigest | null
getLatestHerdDigest()
Section titled “getLatestHerdDigest()”getLatestHerdDigest():
HerdDigest|null
Defined in: src/store.ts:1938
Returns
Section titled “Returns”HerdDigest | null
getLearning()
Section titled “getLearning()”getLearning(
id):Learning|null
Defined in: src/store.ts:2480
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Learning | null
getLocalPr()
Section titled “getLocalPr()”getLocalPr(
repoPath,branch):LocalPr|null
Defined in: src/store.ts:855
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
branch
Section titled “branch”string
Returns
Section titled “Returns”LocalPr | null
getLocalPrByNumber()
Section titled “getLocalPrByNumber()”getLocalPrByNumber(
number):LocalPr|null
Defined in: src/store.ts:865
Parameters
Section titled “Parameters”number
Section titled “number”number
Returns
Section titled “Returns”LocalPr | null
getMergePassSignature()
Section titled “getMergePassSignature()”getMergePassSignature(
key):string
Defined in: src/store.ts:2826
Signature of the active-rule set the last merge pass processed for a scope
(<repoPath> for intra, __cross__ for the global pass). Lets the background pass
skip re-spawning when nothing changed. Empty string when never run.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string
getMergeSuggestion()
Section titled “getMergeSuggestion()”getMergeSuggestion(
id):MergeSuggestion|null
Defined in: src/store.ts:2786
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”MergeSuggestion | null
getOrInitEpicIntegrationBranch()
Section titled “getOrInitEpicIntegrationBranch()”getOrInitEpicIntegrationBranch(
repoPath,parentIssueNumber,derived):string
Defined in: src/store.ts:963
Single source of truth for an epic’s pinned integration-branch name (#645), keyed
PER EPIC (repoPath, parentIssueNumber). The name derives from the parent title, but
the title can be edited mid-run — re-deriving everywhere would re-point new spawns +
the landing base and orphan children already merged on the old branch. So we pin it
once on first sight and read it forever: an existing pin is returned as-is; otherwise
derived is persisted for THIS epic and returned. Per-epic keying is load-bearing —
epic_run is one-row-per-repo and superseded when a new epic starts, so a repo-scoped
pin would be inherited by the next epic and would be wrong for a superseded epic’s
still-pending landing PR.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
derived
Section titled “derived”string
Returns
Section titled “Returns”string
getPlanGate()
Section titled “getPlanGate()”getPlanGate(
sessionId):PlanGate|null
Defined in: src/store.ts:1683
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”PlanGate | null
getPrReview()
Section titled “getPrReview()”getPrReview(
repoPath,prNumber):PrReview|null
Defined in: src/store.ts:3085
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
prNumber
Section titled “prNumber”number
Returns
Section titled “Returns”PrReview | null
getPushPrefs()
Section titled “getPushPrefs()”getPushPrefs(
endpoint):PushPrefs|null
Defined in: src/store.ts:914
Parameters
Section titled “Parameters”endpoint
Section titled “endpoint”string
Returns
Section titled “Returns”PushPrefs | null
getRecap()
Section titled “getRecap()”getRecap(
sessionId):Recap|null
Defined in: src/store.ts:1790
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”Recap | null
getRepoConfig()
Section titled “getRepoConfig()”getRepoConfig(
repoPath):RepoConfig
Defined in: src/store.ts:775
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”getRetiredSeenAt()
Section titled “getRetiredSeenAt()”getRetiredSeenAt(
repoPath):number
Defined in: src/store.ts:2861
Return the last time the user acknowledged retired rules for a repo (epoch ms). Defaults to 0 when never set.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”number
getReview()
Section titled “getReview()”getReview(
sessionId):ReviewVerdict|null
Defined in: src/store.ts:1564
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”ReviewVerdict | null
getSetting()
Section titled “getSetting()”getSetting(
key):string|null
Defined in: src/store.ts:759
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | null
getSignalsByIds()
Section titled “getSignalsByIds()”getSignalsByIds(
ids):Signal[]
Defined in: src/store.ts:2926
Resolve cited evidence signal ids to their full rows (newest first), for the
drawer’s “where did this come from” view. Ids that no longer resolve (pruned
signals) are silently dropped, so the result can be shorter than ids. Empty
in, empty out.
Parameters
Section titled “Parameters”string[]
Returns
Section titled “Returns”Signal[]
hasEpicCompleted()
Section titled “hasEpicCompleted()”hasEpicCompleted(
repoPath,parentIssueNumber):boolean
Defined in: src/store.ts:1130
True if an epic_completed row exists for this key, regardless of dismissedAt. Used by the backfill pre-check so a dismissed-but-idle run isn’t re-backfilled.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”boolean
hasIssueLog()
Section titled “hasIssueLog()”hasIssueLog(
sessionId,key):boolean
Defined in: src/store.ts:1615
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
string
Returns
Section titled “Returns”boolean
incrementLearningIneffective()
Section titled “incrementLearningIneffective()”incrementLearningIneffective(
id,signalIds):Learning|null
Defined in: src/store.ts:2519
Bump ineffectiveCount for an active/promoted rule (self-audit, spec §5) by the
number of signalIds not already counted against it, recording them so a later
re-distill over the same rolling window can’t re-count the same evidence. A
no-op (returns null) for proposed/dismissed/missing rules, or when every cited
signal was already counted — keeping “Not working (N)” honest.
Parameters
Section titled “Parameters”string
signalIds
Section titled “signalIds”string[]
Returns
Section titled “Returns”Learning | null
ineffectiveSignalsFor()
Section titled “ineffectiveSignalsFor()”ineffectiveSignalsFor(
id):Signal[]
Defined in: src/store.ts:2588
Resolve the stored ineffectiveSignalIds for a rule to full Signal rows.
Server-side only — ineffectiveSignalIds is intentionally absent from the
Learning type and hydrateLearning. Returns [] for missing/unflagged rules.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Signal[]
lastUsedByRepo()
Section titled “lastUsedByRepo()”lastUsedByRepo():
Record<string,number>
Defined in: src/store.ts:1479
Map of repoPath → most-recent session createdAt (across all sessions, incl. archived).
Returns
Section titled “Returns”Record<string, number>
list()
Section titled “list()”list(
opts?):Session[]
Defined in: src/store.ts:1344
Parameters
Section titled “Parameters”activeOnly?
Section titled “activeOnly?”boolean
Returns
Section titled “Returns”Session[]
listActiveLearnings()
Section titled “listActiveLearnings()”listActiveLearnings(
repoPath):Learning[]
Defined in: src/store.ts:2461
Active + promoted rules for a repo, for prompt injection (spec §4a). Oldest-updated first.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”Learning[]
listAllActiveLearnings()
Section titled “listAllActiveLearnings()”listAllActiveLearnings():
Learning[]
Defined in: src/store.ts:2707
Active + promoted rules across ALL repos (Phase 4 cross-repo recurrence pass). Oldest-updated first.
Returns
Section titled “Returns”Learning[]
listBuildQueues()
Section titled “listBuildQueues()”listBuildQueues():
BuildQueue[]
Defined in: src/store.ts:3049
Return one BuildQueue per session that has ≥1 step, via a single JOIN. Sessions with no steps are omitted entirely.
Returns
Section titled “Returns”listEpicBaseMismatches()
Section titled “listEpicBaseMismatches()”listEpicBaseMismatches(
repoPath,parentIssueNumber):object[]
Defined in: src/store.ts:1091
All parked children for one epic — fed into assembleEpic for the actionable warnings.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”object[]
listEpicCompleted()
Section titled “listEpicCompleted()”listEpicCompleted(
repoPath?):object[]
Defined in: src/store.ts:1139
All non-dismissed completed epics, optionally filtered by repoPath, newest-completed first.
Parameters
Section titled “Parameters”repoPath?
Section titled “repoPath?”string
Returns
Section titled “Returns”object[]
listEpicIntegrated()
Section titled “listEpicIntegrated()”listEpicIntegrated(
repoPath,parentIssueNumber):Set<number>
Defined in: src/store.ts:1011
Child #s squash-merged into the integration branch for one epic.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”Set<number>
listEpicIntegratedDetails()
Section titled “listEpicIntegratedDetails()”listEpicIntegratedDetails(
repoPath,parentIssueNumber):object[]
Defined in: src/store.ts:1019
All integrated child rows for one epic, with PR details and mergedAt timestamp.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
Returns
Section titled “Returns”object[]
listEpicRuns()
Section titled “listEpicRuns()”listEpicRuns():
EpicRun[]
Defined in: src/store.ts:940
All persisted epic_run rows (one per repo). Mirrors getEpicRun’s row shape.
Returns
Section titled “Returns”EpicRun[]
listHeldTasks()
Section titled “listHeldTasks()”listHeldTasks():
HeldTask[]
Defined in: src/store.ts:3179
Returns
Section titled “Returns”HeldTask[]
listLearnings()
Section titled “listLearnings()”listLearnings(
repoPath,opts?):Learning[]
Defined in: src/store.ts:2447
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
status?
Section titled “status?”Returns
Section titled “Returns”Learning[]
listMergeSuggestions()
Section titled “listMergeSuggestions()”listMergeSuggestions(
opts?):MergeSuggestion[]
Defined in: src/store.ts:2760
Parameters
Section titled “Parameters”repoPath?
Section titled “repoPath?”string
status?
Section titled “status?”Returns
Section titled “Returns”listPendingLearnings()
Section titled “listPendingLearnings()”listPendingLearnings():
Learning[]
Defined in: src/store.ts:2915
Returns
Section titled “Returns”Learning[]
listPushSubs()
Section titled “listPushSubs()”listPushSubs():
StoredPushSub[]
Defined in: src/store.ts:897
Returns
Section titled “Returns”listRecentlyArchived()
Section titled “listRecentlyArchived()”listRecentlyArchived(
sinceMs):Session[]
Defined in: src/store.ts:1355
Archived sessions retired since sinceMs, newest-first — drives the read-only
“recently done” surface (recaps survive worktree teardown).
Parameters
Section titled “Parameters”sinceMs
Section titled “sinceMs”number
Returns
Section titled “Returns”Session[]
listRepoPathsWithInjectableLearnings()
Section titled “listRepoPathsWithInjectableLearnings()”listRepoPathsWithInjectableLearnings():
string[]
Defined in: src/store.ts:2473
Distinct repoPaths that have ≥1 active/promoted (injectable) rule, for the cross-repo injectable sweep (GET /api/learnings/injectable).
Returns
Section titled “Returns”string[]
listRepoPathsWithRetiredLearnings()
Section titled “listRepoPathsWithRetiredLearnings()”listRepoPathsWithRetiredLearnings():
string[]
Defined in: src/store.ts:2871
Distinct repoPaths that have ≥1 retired rule, for the cross-repo injectable sweep.
Returns
Section titled “Returns”string[]
listRetiredLearnings()
Section titled “listRetiredLearnings()”listRetiredLearnings(
repoPath):Learning[]
Defined in: src/store.ts:2849
Retired rules for a repo, newest-updated first.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”Learning[]
listReviewerSpawns()
Section titled “listReviewerSpawns()”listReviewerSpawns():
ReviewerSpawnRow[]
Defined in: src/store.ts:2070
All reviewer-spawn rows, oldest-spawned first. Column names already match the ReviewerSpawnRow fields, so a direct cast suffices.
Returns
Section titled “Returns”listSignals()
Section titled “listSignals()”listSignals(
repoPath,opts?):Signal[]
Defined in: src/store.ts:2110
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
limit?
Section titled “limit?”number
sinceTs?
Section titled “sinceTs?”number
Returns
Section titled “Returns”Signal[]
listSubsumedLearnings()
Section titled “listSubsumedLearnings()”listSubsumedLearnings(
targetId):Learning[]
Defined in: src/store.ts:2695
Rules soft-retired by being merged into targetId (Phase 4 citation list). Scoped to
status=‘retired’ AND retiredReason=‘merged’ so a since-restored member (which has its
mergedIntoId cleared) can never reappear here. Newest-retired first.
Parameters
Section titled “Parameters”targetId
Section titled “targetId”string
Returns
Section titled “Returns”Learning[]
markIssueLog()
Section titled “markIssueLog()”markIssueLog(
sessionId,key):void
Defined in: src/store.ts:1623
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
string
Returns
Section titled “Returns”void
markLocalPrMerged()
Section titled “markLocalPrMerged()”markLocalPrMerged(
number):void
Defined in: src/store.ts:875
Parameters
Section titled “Parameters”number
Section titled “number”number
Returns
Section titled “Returns”void
markRetiredSeen()
Section titled “markRetiredSeen()”markRetiredSeen(
repoPath,ts):void
Defined in: src/store.ts:2866
Record that the user has seen retired rules for a repo up to ts (epoch ms).
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
number
Returns
Section titled “Returns”void
mergeLearning()
Section titled “mergeLearning()”mergeLearning(
id,rule,rationale?):Learning|null
Defined in: src/store.ts:2571
Deliberate inverse of reviseLearning: enriches a rule’s text while PRESERVING all
effectiveness counters (helpfulCount, injectedCount, ineffectiveCount, lastUsedAt,
evidenceCount, ineffectiveSignalIds). Use when the distiller wants to apply an
mem0-style UPDATE — merging richer text into an existing rule so the help-rate record
carries forward. Unlike reviseLearning, this does NOT reset counters and does NOT stamp
autoOptimizedAt. Hard-guards active-only: promoted rules have their text mirrored in
CLAUDE.md verbatim and must never be silently rewritten here.
Parameters
Section titled “Parameters”string
string
rationale?
Section titled “rationale?”string
Returns
Section titled “Returns”Learning | null
mergeSuggestionSignatures()
Section titled “mergeSuggestionSignatures()”mergeSuggestionSignatures(
opts):Set<string>
Defined in: src/store.ts:2808
Signatures of suggestions of a kind, so a background pass can skip re-proposing a group
the operator already has (or rejected). intra is scoped to a repo; cross is global
(repoPath ignored).
cross additionally includes applied: promoting a cross group to the global CLAUDE.md
(#872) leaves its member rules ACTIVE, so without this carve-out the next cross pass would
re-detect and re-suggest the same group. intra-apply retires its members, so the group
can’t recur — applied is intentionally excluded there.
Parameters
Section titled “Parameters”repoPath?
Section titled “repoPath?”string
Returns
Section titled “Returns”Set<string>
overnightDelta()
Section titled “overnightDelta()”overnightDelta(
sinceTs):object
Defined in: src/store.ts:1984
Overnight delta since sinceTs: PRs merged (from issue_log merged:<pr> stamps) and
sessions archived after that instant. Feeds the rundown’s “while you were away” summary.
Parameters
Section titled “Parameters”sinceTs
Section titled “sinceTs”number
Returns
Section titled “Returns”object
archivedSessions
Section titled “archivedSessions”archivedSessions:
object[]
mergedPrs
Section titled “mergedPrs”mergedPrs:
number[]
pendingLearningCount()
Section titled “pendingLearningCount()”pendingLearningCount():
number
Defined in: src/store.ts:2907
Returns
Section titled “Returns”number
promoteLearning()
Section titled “promoteLearning()”promoteLearning(
id,prUrl):Learning|null
Defined in: src/store.ts:2897
active → promoted, recording the CLAUDE.md PR url (spec §4b). Returns null when the rule is missing or not in a state that allows promotion.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Learning | null
pruneArchivedSessions()
Section titled “pruneArchivedSessions()”pruneArchivedSessions(
opts):number
Defined in: src/store.ts:2139
Delete archived sessions beyond the retention window — those older than maxAgeMs
OR ranked past the newest keepNewest (global, union: whichever evicts first). Only
status = 'archived' rows are eligible; live sessions are never touched. Each victim’s
reviews row is cascaded in the same transaction so it can’t orphan. signals are left
to their own prune. Age and rank both key off COALESCE(archivedAt, updatedAt, createdAt)
so legacy archived rows predating the archivedAt column still sort/expire correctly.
Returns the number of sessions removed.
Parameters
Section titled “Parameters”keepNewest
Section titled “keepNewest”number
maxAgeMs
Section titled “maxAgeMs”number
Returns
Section titled “Returns”number
pruneOrphanInjectedLearnings()
Section titled “pruneOrphanInjectedLearnings()”pruneOrphanInjectedLearnings():
void
Defined in: src/store.ts:2880
Delete session_injected_learnings rows whose session no longer exists.
Returns
Section titled “Returns”void
pruneOrphanMergeSuggestions()
Section titled “pruneOrphanMergeSuggestions()”pruneOrphanMergeSuggestions():
void
Defined in: src/store.ts:2837
Drop pending suggestions whose member rules no longer all exist (a member was hard- deleted, or — for safety — left the schema). Keeps the drawer from offering a merge that can’t apply. Applied/dismissed rows are kept as history.
Returns
Section titled “Returns”void
pruneReviewerSpawns()
Section titled “pruneReviewerSpawns()”pruneReviewerSpawns(
beforeTs):number
Defined in: src/store.ts:2078
Drop reviewer-spawn rows older than beforeTs (own retention sweep — these are
decoupled from the session archive path on purpose). Returns the count removed.
Parameters
Section titled “Parameters”beforeTs
Section titled “beforeTs”number
Returns
Section titled “Returns”number
pruneSignals()
Section titled “pruneSignals()”pruneSignals(
beforeTs):number
Defined in: src/store.ts:2122
Parameters
Section titled “Parameters”beforeTs
Section titled “beforeTs”number
Returns
Section titled “Returns”number
putCap()
Section titled “putCap()”putCap(
row):void
Defined in: src/store.ts:1518
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”putCreditSnapshot()
Section titled “putCreditSnapshot()”putCreditSnapshot(
row):void
Defined in: src/store.ts:1537
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”putHerdDigest()
Section titled “putHerdDigest()”putHerdDigest(
d):void
Defined in: src/store.ts:1945
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
putPlanGate()
Section titled “putPlanGate()”putPlanGate(
g):void
Defined in: src/store.ts:1693
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
putPrReview()
Section titled “putPrReview()”putPrReview(
r):void
Defined in: src/store.ts:3104
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
putPushSub()
Section titled “putPushSub()”putPushSub(
sub,ua):void
Defined in: src/store.ts:883
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
putRecap()
Section titled “putRecap()”putRecap(
recap):void
Defined in: src/store.ts:1801
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
putReview()
Section titled “putReview()”putReview(
v):void
Defined in: src/store.ts:1575
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
recentSessionCountsByRepo()
Section titled “recentSessionCountsByRepo()”recentSessionCountsByRepo(
since):Record<string,number>
Defined in: src/store.ts:1493
Map of repoPath → count of sessions (agents) created since since (ms epoch).
Drives the “recently worked on” shortcut in the repo picker — a measure of how
many agents were run on each repo in the recent window, across all sessions.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Record<string, number>
recordEpicBaseMismatch()
Section titled “recordEpicBaseMismatch()”recordEpicBaseMismatch(
repoPath,parentIssueNumber,childNumber,m):void
Defined in: src/store.ts:1047
Park a child whose PR targets the wrong base. Upsert — refreshes actualBase/prNumber/checkedAt (checkedAt is the throttle anchor, so it must advance on every recheck).
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
childNumber
Section titled “childNumber”number
actualBase
Section titled “actualBase”string
checkedAt
Section titled “checkedAt”number
prNumber
Section titled “prNumber”number | null
Returns
Section titled “Returns”void
recordEpicCompleted()
Section titled “recordEpicCompleted()”recordEpicCompleted(
row):void
Defined in: src/store.ts:1110
Record a completed epic (all children done-in-epic). Idempotent upsert. On conflict, refreshes parentTitle/completedAt/childrenJson but leaves dismissedAt untouched so a previously dismissed epic never resurrects.
Parameters
Section titled “Parameters”childrenJson
Section titled “childrenJson”string
completedAt
Section titled “completedAt”number
parentIssueNumber
Section titled “parentIssueNumber”number
parentTitle
Section titled “parentTitle”string
repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”void
recordEpicIntegrated()
Section titled “recordEpicIntegrated()”recordEpicIntegrated(
repoPath,parentIssueNumber,childNumber,pr?,mergedBase?):void
Defined in: src/store.ts:984
Record that a child PR was squash-merged into the epic integration branch. Idempotent (PK upsert) — the drain may re-observe a merge across pumps. On conflict, updates only PR columns (guarded by COALESCE so a null re-observe cannot clobber previously-recorded good values). createdAt is never overwritten.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
childNumber
Section titled “childNumber”number
number
Section titled “number”number
string
mergedBase?
Section titled “mergedBase?”string
Returns
Section titled “Returns”void
recordInjectedLearnings()
Section titled “recordInjectedLearnings()”recordInjectedLearnings(
sessionId,ids):void
Defined in: src/store.ts:2599
Record that a set of learning ids were injected into a session’s context. INSERT OR IGNORE keeps it idempotent. Empty ids → no-op. No counter bump.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
string[]
Returns
Section titled “Returns”void
recordReviewerSpawn()
Section titled “recordReviewerSpawn()”recordReviewerSpawn(
r):void
Defined in: src/store.ts:2025
Record a freshly-spawned reviewer session. Token/completed columns stay NULL until
finalize (completeReviewerSpawn). A plain INSERT is correct — every spawn forces a
fresh reviewerSessionId UUID, so the PK never collides.
Parameters
Section titled “Parameters”"review" | "plan_gate" | "recap" | "rundown"
string | null
reviewerSessionId
Section titled “reviewerSessionId”string
spawnedAt
Section titled “spawnedAt”number
taskSessionId
Section titled “taskSessionId”string
worktreePath
Section titled “worktreePath”string
Returns
Section titled “Returns”void
removeHeldTask()
Section titled “removeHeldTask()”removeHeldTask(
id):void
Defined in: src/store.ts:3194
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
replaceBuildQueue()
Section titled “replaceBuildQueue()”replaceBuildQueue(
sessionId,steps):BuildQueue
Defined in: src/store.ts:2965
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”restoreLearning()
Section titled “restoreLearning()”restoreLearning(
id):Learning|null
Defined in: src/store.ts:2660
retired → retiredFromStatus (or ‘active’); clears retiredAt/retiredReason/retiredFromStatus,
and clears mergedIntoId so a rule restored after a Phase-4 consolidation carries no
dangling citation back to its former survivor. Returns null when not retired or missing.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Learning | null
retireLearning()
Section titled “retireLearning()”retireLearning(
id,reason):Learning|null
Defined in: src/store.ts:2645
active|promoted → retired; sets retiredAt, retiredReason, retiredFromStatus, updatedAt. Returns the updated Learning, or null for illegal source state / missing row.
Parameters
Section titled “Parameters”string
reason
Section titled “reason”string
Returns
Section titled “Returns”Learning | null
retireLearningMerged()
Section titled “retireLearningMerged()”retireLearningMerged(
sourceId,targetId):Learning|null
Defined in: src/store.ts:2679
Soft-retire a rule that was consolidated into another (Phase 4 merge): same as
retireLearning(id, "merged") but also records mergedIntoId = targetId as the
retained citation back to the surviving rule. active|promoted → retired only.
Parameters
Section titled “Parameters”sourceId
Section titled “sourceId”string
targetId
Section titled “targetId”string
Returns
Section titled “Returns”Learning | null
reviseLearning()
Section titled “reviseLearning()”reviseLearning(
id,rule,rationale?):Learning|null
Defined in: src/store.ts:2548
Replace a flagged rule’s text (and optionally rationale) and clear the visible
ineffective flag. Only operates on active/promoted rules; no-ops for
proposed/dismissed/missing. Blank rewrites are rejected (returns null).
PRESERVES ineffectiveSignalIds so the dedup set survives the revision — only
genuinely new failure signals can re-raise the flag after an optimization.
RESETS the effectiveness baseline (helpfulCount/injectedCount/lastUsedAt)
to zero: the rule’s help-rate measures CURRENT text, so a rewrite is a fresh
artifact that must re-earn its record. Without this, an auto-optimized rule
would inherit the old text’s poor help-rate and shouldRetire would re-trip on
the cumulative Wilson bound at the first fresh ineffective signal — hollowing
out the “second chance” the auto-optimize flag promises (the n_min gate also
re-applies, so the rewrite must accrue fresh injections before it can retire).
Parameters
Section titled “Parameters”string
string
rationale?
Section titled “rationale?”string
Returns
Section titled “Returns”Learning | null
setAutoMergeState()
Section titled “setAutoMergeState()”setAutoMergeState(
id,patch):void
Defined in: src/store.ts:1462
Update full-auto merge fields. enabled: override (boolean|null). rebaseCount: absolute.
rebaseHead: the head SHA last steered for (string), or null to clear.
Parameters
Section titled “Parameters”string
enabled?
Section titled “enabled?”boolean | null
rebaseCount?
Section titled “rebaseCount?”number
rebaseHead?
Section titled “rebaseHead?”string | null
Returns
Section titled “Returns”void
setAutopilotState()
Section titled “setAutopilotState()”setAutopilotState(
id,patch):void
Defined in: src/store.ts:1429
Patch a session’s autopilot fields. Only the provided keys are written.
Parameters
Section titled “Parameters”string
complete?
Section titled “complete?”boolean
enabled?
Section titled “enabled?”boolean | null
paused?
Section titled “paused?”boolean
question?
Section titled “question?”string | null
stepCount?
Section titled “stepCount?”number
Returns
Section titled “Returns”void
setBuildQueueApproved()
Section titled “setBuildQueueApproved()”setBuildQueueApproved(
sessionId,approved):void
Defined in: src/store.ts:3039
Flip the human-curation gate for a session’s queue.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
approved
Section titled “approved”boolean
Returns
Section titled “Returns”void
setBuildStepStatus()
Section titled “setBuildStepStatus()”setBuildStepStatus(
sessionId,stepId,status):boolean
Defined in: src/store.ts:3012
Update the status of a single step. Returns true when the TARGET row was actually changed (unchanged contract; the cascade below is additive).
Monotonic forward-fill: when a step is advanced to active or done, every EARLIER
step still pending is auto-completed to done, in the same transaction. The
build-queue contract is ordered execution (“work the steps in order”), so reaching
step N implies steps before it are done — this keeps the displayed status from lagging
actual progress even when the agent under-reports (e.g. marks a later step but never
the earlier ones). Deterministic and server-side: needs zero agent compliance.
Strictly monotonic + safe: only pending → done, only at LOWER positions; never
un-completes a step, never touches later steps, and never overrides skipped (an
explicit terminal state the agent sets to drop a step). A step the agent silently
jumped over (left pending) is treated as done — the reasonable default under the
ordered contract; the agent has the explicit skipped status if it means otherwise.
Only fires on active/done, never on pending (un-set) or skipped.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
stepId
Section titled “stepId”string
status
Section titled “status”Returns
Section titled “Returns”boolean
setEpicLandingPr()
Section titled “setEpicLandingPr()”setEpicLandingPr(
repoPath,parentIssueNumber,fields):void
Defined in: src/store.ts:1183
Write the Stage B (#635) landing-PR resolution onto a completed epic. Direct UPDATE (not part of recordEpicCompleted’s preserve-by-omission upsert).
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
fields
Section titled “fields”attempts
Section titled “attempts”number
prNumber
Section titled “prNumber”number | null
string | null
Returns
Section titled “Returns”void
setEpicMigrationPaths()
Section titled “setEpicMigrationPaths()”setEpicMigrationPaths(
repoPath,parentIssueNumber,paths):void
Defined in: src/store.ts:1203
Persist the migration paths detected in a completed epic’s landing PR (#645). Stored as a JSON array; an empty array clears any prior detection. Direct UPDATE, mirroring setEpicLandingPr’s style.
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
parentIssueNumber
Section titled “parentIssueNumber”number
string[]
Returns
Section titled “Returns”void
setEpicRun()
Section titled “setEpicRun()”setEpicRun(
r):void
Defined in: src/store.ts:946
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setHaltReason()
Section titled “setHaltReason()”setHaltReason(
id,reason,haltedAt):void
Defined in: src/store.ts:2012
Parameters
Section titled “Parameters”string
reason
Section titled “reason”"error" | "usage_limit" | "completed" | "operator" | null
haltedAt
Section titled “haltedAt”number | null
Returns
Section titled “Returns”void
setLearningScope()
Section titled “setLearningScope()”setLearningScope(
id,globs):Learning|null
Defined in: src/store.ts:2502
Replace a rule’s scope globs (operator edit, #842). Runs the same sanitizeScopeGlobs
the distiller uses — normalize to repo-relative form, drop empty/over-long patterns,
dedupe, and cap the count — so both paths persist identical, bounded scope; [] makes
it an Always-rule again. No-op (returns null) for a missing rule.
Parameters
Section titled “Parameters”string
string[]
Returns
Section titled “Returns”Learning | null
setLearningStatus()
Section titled “setLearningStatus()”setLearningStatus(
id,status,rule?):Learning|null
Defined in: src/store.ts:2485
Parameters
Section titled “Parameters”string
status
Section titled “status”string
Returns
Section titled “Returns”Learning | null
setMergePassSignature()
Section titled “setMergePassSignature()”setMergePassSignature(
key,sig):void
Defined in: src/store.ts:2830
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
setMergeSuggestionStatus()
Section titled “setMergeSuggestionStatus()”setMergeSuggestionStatus(
id,status):MergeSuggestion|null
Defined in: src/store.ts:2793
Parameters
Section titled “Parameters”string
status
Section titled “status”Returns
Section titled “Returns”MergeSuggestion | null
setPlanPhase()
Section titled “setPlanPhase()”setPlanPhase(
id,phase):void
Defined in: src/store.ts:2004
Parameters
Section titled “Parameters”string
"planning" | "executing" | null
Returns
Section titled “Returns”void
setPushPrefs()
Section titled “setPushPrefs()”setPushPrefs(
endpoint,prefs):boolean
Defined in: src/store.ts:922
Update a device’s category selection; false when no such subscription exists.
Parameters
Section titled “Parameters”endpoint
Section titled “endpoint”string
Returns
Section titled “Returns”boolean
setRecapPendingDiff()
Section titled “setRecapPendingDiff()”setRecapPendingDiff(
sessionId,files):void
Defined in: src/store.ts:1864
Set/clear the transient diff carrier used by finalize’s block-join. Server-only — never read by the client-facing getRecap/snapshotRecaps paths. Pass [] to clear.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
DiffFile[]
Returns
Section titled “Returns”void
setRepoConfig()
Section titled “setRepoConfig()”setRepoConfig(
repoPath,cfg):void
Defined in: src/store.ts:788
Parameters
Section titled “Parameters”repoPath
Section titled “repoPath”string
Returns
Section titled “Returns”void
setSandboxState()
Section titled “setSandboxState()”setSandboxState(
id,patch):void
Defined in: src/store.ts:1405
Patch a session’s applied sandbox state (set at spawn by the sandbox wrapper). Only the provided keys are written.
Parameters
Section titled “Parameters”string
applied?
Section titled “applied?”SandboxProfile | null
degraded?
Section titled “degraded?”boolean
egressApplied?
Section titled “egressApplied?”boolean
egressDegraded?
Section titled “egressDegraded?”boolean
Returns
Section titled “Returns”void
setSetting()
Section titled “setSetting()”setSetting(
key,value):void
Defined in: src/store.ts:766
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
snapshotPlanGates()
Section titled “snapshotPlanGates()”snapshotPlanGates():
Record<string,PlanGate>
Defined in: src/store.ts:1722
Returns
Section titled “Returns”Record<string, PlanGate>
snapshotRecaps()
Section titled “snapshotRecaps()”snapshotRecaps():
Record<string,Recap>
Defined in: src/store.ts:1834
All recaps except empty ones — the UI never shows an empty recap.
Returns
Section titled “Returns”Record<string, Recap>
snapshotReviews()
Section titled “snapshotReviews()”snapshotReviews():
Record<string,ReviewVerdict>
Defined in: src/store.ts:1642
Returns
Section titled “Returns”Record<string, ReviewVerdict>
takeSessionInjectedLearnings()
Section titled “takeSessionInjectedLearnings()”takeSessionInjectedLearnings(
sessionId):string[]
Defined in: src/store.ts:2623
Return and delete the learningIds recorded for a session. A second call returns [].
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”string
Returns
Section titled “Returns”string[]
update()
Section titled “update()”update(
id,patch):void
Defined in: src/store.ts:1365
Parameters
Section titled “Parameters”string
Partial<Pick<Session, "name" | "status" | "lastState" | "branch" | "herdrAgentId" | "readyToMerge" | "mergingSince" | "mergingTrainId" | "mergingPrNumber">>
Returns
Section titled “Returns”void