instar 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,185 @@
1
+ export declare const ISSUE_BUCKETS: readonly ["framework-limitation", "instar-integration-gap", "generic-agent-mistake"];
2
+ export type IssueBucket = (typeof ISSUE_BUCKETS)[number];
3
+ export declare const ISSUE_SEVERITIES: readonly ["low", "medium", "high"];
4
+ export type IssueSeverity = (typeof ISSUE_SEVERITIES)[number];
5
+ export declare const ISSUE_STATUSES: readonly ["open", "spec'd", "fixed", "wont-fix"];
6
+ export type IssueStatus = (typeof ISSUE_STATUSES)[number];
7
+ export declare const PLAYBOOK_STATUSES: readonly ["none", "candidate", "extracted", "superseded"];
8
+ export type PlaybookStatus = (typeof PLAYBOOK_STATUSES)[number];
9
+ export interface FrameworkIssueLedgerOptions {
10
+ dbPath: string;
11
+ /** Override clock for deterministic tests. */
12
+ now?: () => number;
13
+ }
14
+ /** What Stage B emits per observation (spec §5). */
15
+ export interface RecordObservationInput {
16
+ framework: string;
17
+ bucket: IssueBucket;
18
+ title: string;
19
+ severity?: IssueSeverity;
20
+ /** Conservative auto-merge key (spec §13.3). Required — identifies the canonical issue. */
21
+ dedupKey: string;
22
+ /** Richer fingerprint for probable-dup review (spec §13.3). */
23
+ signature?: string;
24
+ /** OPAQUE reference only — path+line, log ref, PR#, sentinel-event id (spec §13.2/§17). */
25
+ evidence?: string;
26
+ observedVersion?: string;
27
+ tickId?: string;
28
+ /**
29
+ * Collapses repeated observations of the same open issue within a fix-window
30
+ * to one episode (spec §13.4). Defaults to the observed version so an unfixed
31
+ * issue accrues at most one episode per version span.
32
+ */
33
+ episodeKey?: string;
34
+ /** Forced primary when dual-tagged (spec §6). */
35
+ bucketPrimary?: IssueBucket;
36
+ relatedSpec?: string;
37
+ }
38
+ export interface RecordObservationResult {
39
+ issueId: string;
40
+ created: boolean;
41
+ episodeRecorded: boolean;
42
+ recurrenceCount: number;
43
+ probableLoop: boolean;
44
+ }
45
+ export interface IssueRow {
46
+ id: string;
47
+ framework: string;
48
+ bucket: IssueBucket;
49
+ bucketPrimary: IssueBucket | null;
50
+ title: string;
51
+ severity: IssueSeverity;
52
+ status: IssueStatus;
53
+ dedupKey: string;
54
+ signature: string | null;
55
+ recurrenceCount: number;
56
+ firstSeenVersion: string | null;
57
+ lastSeenVersion: string | null;
58
+ fixedInVersion: string | null;
59
+ regressedFromIssueId: string | null;
60
+ playbookStatus: PlaybookStatus;
61
+ wontFixReason: string | null;
62
+ relatedSpec: string | null;
63
+ probableLoop: boolean;
64
+ createdAt: number;
65
+ updatedAt: number;
66
+ /** Derived at read (spec §13.4) — never stored, so a re-classification can't stale it. */
67
+ generalizable: boolean;
68
+ /** Derived at read: severityWeight × recurrenceCount × recency decay (spec §13.4). */
69
+ impactScore: number;
70
+ }
71
+ export interface ListIssuesQuery {
72
+ framework?: string;
73
+ bucket?: IssueBucket;
74
+ status?: IssueStatus;
75
+ limit?: number;
76
+ }
77
+ export interface PlaybookQuery {
78
+ targetFramework: string;
79
+ limit?: number;
80
+ }
81
+ /** A single issue Stage-B forensics produced for a run (everything but the
82
+ * per-run framework/tickId, which `captureRun` supplies). */
83
+ export type ForensicFinding = Omit<RecordObservationInput, 'framework' | 'tickId'>;
84
+ export interface CaptureRunInput {
85
+ framework: string;
86
+ tickId?: string;
87
+ findings: ForensicFinding[];
88
+ }
89
+ export interface CaptureRunResult {
90
+ runId: string;
91
+ framework: string;
92
+ findingsCount: number;
93
+ observationsWritten: number;
94
+ newIssues: number;
95
+ /** Previously-fixed issues whose signature/dedupKey matches a new finding —
96
+ * surfaced for human regression review, NOT auto-linked (spec §13.5). */
97
+ regressionCandidates: Array<{
98
+ findingDedupKey: string;
99
+ candidateIssueId: string;
100
+ }>;
101
+ }
102
+ export interface CaptureStats {
103
+ totalRuns: number;
104
+ totalObservationsWritten: number;
105
+ lastRanAt: number | null;
106
+ byFramework: Array<{
107
+ framework: string;
108
+ runs: number;
109
+ observations: number;
110
+ lastRanAt: number;
111
+ }>;
112
+ }
113
+ export declare function scanForSecret(s: string): boolean;
114
+ export declare class FrameworkIssueLedger {
115
+ private db;
116
+ private now;
117
+ constructor(opts: FrameworkIssueLedgerOptions);
118
+ /** Stable list of frameworks the ledger has seen — for the route allowlist (spec §5/§17). */
119
+ knownFrameworks(): string[];
120
+ /**
121
+ * Record one Stage-B observation. Finds-or-creates the canonical issue via
122
+ * (framework, dedupKey); collapses the observation into a distinct episode via
123
+ * episodeKey; increments the materialized recurrence_count only on a new
124
+ * episode (spec §13.4). All writes run in a single transaction (CAS-safe: the
125
+ * UNIQUE(issue_id, episode_key) index is the concurrency guard — a racing
126
+ * duplicate episode insert fails and is counted as already-recorded).
127
+ */
128
+ recordObservation(input: RecordObservationInput): RecordObservationResult;
129
+ /** Retention pruning — keep first N + last M observations per issue (spec §13.2). */
130
+ private pruneObservations;
131
+ /**
132
+ * Single-writer CAS mutate of an issue's mutable fields (status, bucket,
133
+ * playbookStatus, regression link, etc.). Follows CommitmentTracker's
134
+ * read-modify-write-with-version-check pattern; enum fields are validated.
135
+ * `wont-fix` requires a reason (spec §13.7).
136
+ */
137
+ updateIssue(issueId: string, patch: Partial<{
138
+ status: IssueStatus;
139
+ bucket: IssueBucket;
140
+ bucketPrimary: IssueBucket | null;
141
+ playbookStatus: PlaybookStatus;
142
+ fixedInVersion: string | null;
143
+ regressedFromIssueId: string | null;
144
+ wontFixReason: string | null;
145
+ relatedSpec: string | null;
146
+ }>): IssueRow | null;
147
+ /**
148
+ * Suggest a regression link: a new issue whose signature/dedupKey matches a
149
+ * previously-`fixed` issue is a candidate regression (spec §13.5). Returns the
150
+ * matching fixed issues (does NOT auto-link — review decides).
151
+ */
152
+ suggestRegressions(input: {
153
+ framework: string;
154
+ dedupKey: string;
155
+ signature?: string | null;
156
+ }): IssueRow[];
157
+ getIssue(id: string): IssueRow | null;
158
+ listIssues(q?: ListIssuesQuery): IssueRow[];
159
+ /**
160
+ * The onboarding playbook for `targetFramework`: generalizable lessons from
161
+ * PRIOR (other) frameworks, ranked by impactScore (spec §13.6). The playbook
162
+ * for X is sourced from frameworks != X — never X's own issues.
163
+ */
164
+ playbook(q: PlaybookQuery): IssueRow[];
165
+ observationCount(issueId: string): number;
166
+ /**
167
+ * Stage-B auto-capture (spec §5, §19.2). The single atomic entry point the
168
+ * mentor tick calls after forensics: it writes every finding to the ledger
169
+ * (no "remember to log" — zero-manual-capture) and ALWAYS logs the run to the
170
+ * capture-funnel, even when `findings` is empty. That funnel row is what makes
171
+ * an inert/broken writer visible: a run that produced zero observations is
172
+ * recorded as a run, so "ran, found nothing" is distinguishable from "never
173
+ * ran." Regression candidates are surfaced for review, never auto-linked
174
+ * (spec §13.5 — promotion is not the writer's call).
175
+ */
176
+ captureRun(input: CaptureRunInput): CaptureRunResult;
177
+ /** Capture-funnel observability (spec §5/§18). Surfaces ticks→observations so
178
+ * a writer that runs but never writes is visible. */
179
+ captureStats(): CaptureStats;
180
+ private rowToIssue;
181
+ close(): void;
182
+ }
183
+ /** Clamp a list limit to 1..500 (spec §5/§17). */
184
+ export declare function clampLimit(raw: unknown): number;
185
+ //# sourceMappingURL=FrameworkIssueLedger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameworkIssueLedger.d.ts","sourceRoot":"","sources":["../../src/monitoring/FrameworkIssueLedger.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,aAAa,sFAIhB,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,gBAAgB,oCAAqC,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,eAAO,MAAM,cAAc,kDAAmD,CAAC;AAC/E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AA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