@akasecurity/ai-tc-claude-code 0.9.10 → 0.9.11

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.
@@ -491,9 +491,6 @@ var require_ignore = __commonJS({
491
491
  }
492
492
  });
493
493
 
494
- // ../../packages/plugin-runtime/src/attached/egress-wire.ts
495
- import { createHash as createHash4 } from "crypto";
496
-
497
494
  // ../../packages/persistence/src/attached-derived.ts
498
495
  import { rmSync } from "fs";
499
496
  import { join } from "path";
@@ -20742,13 +20739,11 @@ var FindingGroup = external_exports.object({
20742
20739
  latestDetectedAt: external_exports.iso.datetime(),
20743
20740
  instances: external_exports.array(FindingInstance),
20744
20741
  // Derived from instances' statuses with open-dominates precedence (see
20745
- // buildFindingGroups). Undefined only when no instance carries a status.
20742
+ // foldGroupStatus). Undefined only when no instance carries a status.
20746
20743
  status: FindingStatus.optional(),
20747
- // The distinct people across the WHOLE group, not just the `instances`
20748
- // preview — from the store's whole-group aggregate when it supplies one,
20749
- // else folded from the rows (see buildFindingGroups). Undefined when no
20750
- // instance carries a user, or when the store supplied whole-group folds
20751
- // without one.
20744
+ // The distinct people across the WHOLE group, not just the instances
20745
+ // carried here. Undefined when no instance carries a user, or when the
20746
+ // store supplied whole-group folds without one.
20752
20747
  users: external_exports.array(FindingUser).optional()
20753
20748
  }).meta({ id: "FindingGroup" });
20754
20749
  var FindingStats = external_exports.object({
@@ -20777,21 +20772,31 @@ var FindingFacets = external_exports.object({
20777
20772
  // counted under no value.
20778
20773
  status: external_exports.array(FindingFacetItem),
20779
20774
  // Host tool (attributes.tool_name). Present only on the instance-level
20780
- // reads, which can filter by it; the grouped read omits the dimension
20775
+ // reads, which can filter by it; the type-level read omits the dimension
20781
20776
  // because a group spans tools.
20782
20777
  tool: external_exports.array(FindingFacetItem).optional()
20783
20778
  }).meta({ id: "FindingFacets" });
20784
- var DEFAULT_GROUPED_FINDINGS_LIMIT = 50;
20785
- var ListGroupedFindingsQuery = external_exports.object({
20779
+ var FindingTypeSummary = FindingGroup.omit({ instances: true, match: true }).meta({
20780
+ id: "FindingTypeSummary"
20781
+ });
20782
+ var DEFAULT_FINDING_TYPES_LIMIT = 50;
20783
+ var MAX_FINDING_TYPES_LIMIT = 100;
20784
+ var ListFindingTypesQuery = external_exports.object({
20786
20785
  // NOTE: severity filters by Severity (critical/high/medium/low), not by
20787
- // FindingAction.
20786
+ // FindingAction. It narrows TYPES: a type's severity is the one its newest
20787
+ // firing version carries, and this list pages types.
20788
+ //
20789
+ // That is NOT a claim the findings of a type share it. A rule can hold several
20790
+ // definition versions at different severities, so a type kept by this filter
20791
+ // can hold findings that individually do not match — see totals.findings on
20792
+ // ListFindingTypesResponse, which counts them all.
20788
20793
  severity: external_exports.array(Severity).optional(),
20789
20794
  subtype: external_exports.array(external_exports.string()).optional(),
20790
20795
  provider: external_exports.array(FindingProvider).optional(),
20791
20796
  action: external_exports.array(FindingAction).optional(),
20792
- // Matches a group's DERIVED status (see FindingGroup.status), not its
20793
- // individual instances' — so a filtered group's Status column always reads
20794
- // one of the requested values.
20797
+ // Matches a type's DERIVED status (see FindingGroup.status), not its
20798
+ // individual findings' — so a filtered row's status always reads one of the
20799
+ // requested values.
20795
20800
  status: external_exports.array(FindingStatus).optional(),
20796
20801
  q: external_exports.string().optional(),
20797
20802
  // Scope to findings whose event carries this session id (the Activity page's
@@ -20801,23 +20806,37 @@ var ListGroupedFindingsQuery = external_exports.object({
20801
20806
  // from a time-scoped page (Activity's range) can carry that scope. Absent
20802
20807
  // means all time — this list has no default window.
20803
20808
  from: external_exports.iso.datetime().optional(),
20804
- // A group or instance id that must appear in the page even when the cursor
20805
- // has already advanced past its sort position. This is what keeps the
20806
- // Findings page's one-shot ?finding= deep link resolving once the list
20807
- // paginates: the target group is appended out of sort order rather than
20808
- // scanning forward for it. Never affects totals, facets or the cursor.
20809
+ // A RULE id that must appear in the page even when the cursor has already
20810
+ // advanced past its sort position. This is what keeps the selected type
20811
+ // visible in the list once it paginates: the target is appended out of sort
20812
+ // order rather than scanned forward for. Never affects totals, facets or the
20813
+ // cursor. Unlike the grouped read this replaces, it names a rule only — an
20814
+ // instance id is resolved by `findingInstance`, which is a primary-key seek
20815
+ // and so is not bounded by what any page happens to hold.
20809
20816
  includeId: external_exports.string().optional(),
20810
- groupBy: external_exports.literal("type").optional(),
20811
- limit: external_exports.coerce.number().int().min(1).max(100).optional(),
20817
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
20812
20818
  cursor: external_exports.string().optional()
20813
20819
  });
20814
- var ListGroupedFindingsResponse = external_exports.object({
20820
+ var ListFindingTypesResponse = external_exports.object({
20815
20821
  totals: external_exports.object({
20822
+ // Findings belonging to the matching TYPES — not findings that each match
20823
+ // the filters. The filters here select types, so a type that survives
20824
+ // contributes its whole instanceCount.
20825
+ //
20826
+ // `status` is the one exception, narrowed per finding via
20827
+ // countInstancesByStatus. `severity`, `provider` and `action` are not, so
20828
+ // this can exceed what the instance read reports for the same filters: a
20829
+ // rule whose severity moved between versions is kept on its newest and
20830
+ // still counts its older findings. Narrowing the other three needs
20831
+ // per-dimension counts the aggregate does not carry today.
20816
20832
  findings: external_exports.number().int().nonnegative(),
20817
- groups: external_exports.number().int().nonnegative()
20833
+ // Counts TYPES, which is the unit this read pages. The instance read's
20834
+ // own totals count findings; the two deliberately answer different
20835
+ // questions and are never summed.
20836
+ types: external_exports.number().int().nonnegative()
20818
20837
  }),
20819
20838
  facets: FindingFacets,
20820
- items: external_exports.array(FindingGroup),
20839
+ items: external_exports.array(FindingTypeSummary),
20821
20840
  nextCursor: external_exports.string().nullable(),
20822
20841
  // Present only on session-scoped queries (`sessionId` set): per ruleId, how
20823
20842
  // many times that rule fired in the session's persisted transcript. Findings
@@ -20825,7 +20844,7 @@ var ListGroupedFindingsResponse = external_exports.object({
20825
20844
  // every firing, so the two numbers legitimately differ — this map lets a
20826
20845
  // session-scoped view show both.
20827
20846
  sessionFirings: external_exports.record(external_exports.string(), external_exports.number().int().nonnegative()).optional()
20828
- }).meta({ id: "ListGroupedFindingsResponse" });
20847
+ }).meta({ id: "ListFindingTypesResponse" });
20829
20848
  var ApplyFindingActionRequest = external_exports.object({
20830
20849
  // 'quarantined' is system-assigned (see FindingAction) — clients may not set
20831
20850
  // it, so it is excluded from the request contract. The mapping helper
@@ -20855,12 +20874,13 @@ var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
20855
20874
  var MAX_FLAT_FINDINGS_LIMIT = 200;
20856
20875
  var ListFindingInstancesQuery = external_exports.object({
20857
20876
  severity: external_exports.array(Severity).optional(),
20858
- // Rule ids, the same vocabulary the grouped list's `subtype` carries.
20877
+ // Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
20878
+ // ONE of them is how the master/detail view scopes its right-hand panel.
20859
20879
  subtype: external_exports.array(external_exports.string()).optional(),
20860
20880
  provider: external_exports.array(FindingProvider).optional(),
20861
20881
  action: external_exports.array(FindingAction).optional(),
20862
20882
  // Matches each instance's OWN derived status (deriveFindingStatus), unlike
20863
- // the grouped query's group-level fold.
20883
+ // the types query's type-level fold.
20864
20884
  status: external_exports.array(FindingStatus).optional(),
20865
20885
  // Exact host-tool names (attributes.tool_name, e.g. 'Bash'). A real filter,
20866
20886
  // where the free-text `q` can only match the rendered "via Bash" label.
@@ -20877,37 +20897,47 @@ var ListFindingInstancesQuery = external_exports.object({
20877
20897
  });
20878
20898
  var ListFindingInstancesResponse = external_exports.object({
20879
20899
  // Instances matching the filters across the whole scope, not just this
20880
- // page — cursor-independent, like the grouped list's totals.
20900
+ // page — cursor-independent, like the types list's totals.
20881
20901
  totals: external_exports.object({ findings: external_exports.number().int().nonnegative() }),
20882
- // Counts in INSTANCES here, where the grouped response counts groups. Each
20902
+ // Counts in INSTANCES here, where the types response counts types. Each
20883
20903
  // dimension still excludes its own filter.
20884
20904
  facets: FindingFacets,
20885
20905
  items: external_exports.array(FindingInstanceDetail),
20886
20906
  nextCursor: external_exports.string().nullable()
20887
20907
  }).meta({ id: "ListFindingInstancesResponse" });
20888
- var FindingLocationFile = external_exports.object({
20889
- // Empty when the instances carried no file path (a prompt or a tool call
20890
- // with no file attribution).
20891
- file: external_exports.string(),
20892
- instanceCount: external_exports.number().int().nonnegative(),
20893
- maxSeverity: Severity,
20894
- latestDetectedAt: external_exports.iso.datetime(),
20895
- // Folded from the instances' derived statuses with the same
20896
- // open-dominates precedence a group uses.
20897
- status: FindingStatus.optional(),
20898
- // Distinct rules seen at this location, capped — the row shows them as
20899
- // chips, and the count is what conveys scale.
20900
- ruleIds: external_exports.array(external_exports.string())
20901
- }).meta({ id: "FindingLocationFile" });
20902
- var FindingLocationRepo = external_exports.object({
20908
+ var FindingLocationSummary = external_exports.object({
20909
+ // Opaque, stable, minted from the pair by encodeLocationId. It exists
20910
+ // because a location's identity is two values and a URL param carries one:
20911
+ // `?loc=` names a location the way `?rule=` names a type. Only ever compared
20912
+ // for EQUALITY — the page's selection check, this read's `includeId`, the
20913
+ // client's page dedupe — never decoded, and never a sort key.
20914
+ id: external_exports.string(),
20903
20915
  /** Empty when the instances carried no repo attribute. */
20904
20916
  repo: external_exports.string(),
20917
+ // Empty when the instances carried no file path (a prompt, or a tool call
20918
+ // with no file attribution). Both halves empty is a real location — usually
20919
+ // the largest one in a store — and is selectable like any other.
20920
+ file: external_exports.string(),
20905
20921
  instanceCount: external_exports.number().int().nonnegative(),
20922
+ // The WORST severity present, not the first row's. It is this list's primary
20923
+ // sort key, so it is also what explains why a row is where it is, and it is
20924
+ // how a reader decides what to open without opening everything.
20906
20925
  maxSeverity: Severity,
20907
20926
  latestDetectedAt: external_exports.iso.datetime(),
20927
+ // Folded from the instances' derived statuses with the same open-dominates
20928
+ // precedence a group uses, so it answers "is anything left to do here" and
20929
+ // not much more: a location holding 1 open among 40 resolved reads like one
20930
+ // holding 40 open. That loss is accepted — the panel beside this list
20931
+ // carries each finding's own status, and instanceCount sits next to the
20932
+ // badge.
20908
20933
  status: FindingStatus.optional(),
20909
- files: external_exports.array(FindingLocationFile)
20910
- }).meta({ id: "FindingLocationRepo" });
20934
+ // Every distinct rule seen at this location, UNCAPPED — so the length is a
20935
+ // tally rather than a sample and a row can say how many there are. Bounded
20936
+ // by the ruleset, not by the store. The view bounds what it DISPLAYS.
20937
+ ruleIds: external_exports.array(external_exports.string())
20938
+ }).meta({ id: "FindingLocationSummary" });
20939
+ var DEFAULT_FINDING_LOCATIONS_LIMIT = 50;
20940
+ var MAX_FINDING_LOCATIONS_LIMIT = 100;
20911
20941
  var ListFindingLocationsQuery = external_exports.object({
20912
20942
  severity: external_exports.array(Severity).optional(),
20913
20943
  subtype: external_exports.array(external_exports.string()).optional(),
@@ -20920,18 +20950,42 @@ var ListFindingLocationsQuery = external_exports.object({
20920
20950
  q: external_exports.string().optional(),
20921
20951
  sessionId: external_exports.string().optional(),
20922
20952
  from: external_exports.iso.datetime().optional(),
20923
- limit: external_exports.coerce.number().int().min(1).max(500).optional()
20953
+ // A LOCATION id (see FindingLocationSummary.id) that must appear in the page
20954
+ // even when the cursor has already advanced past its sort position — the
20955
+ // counterpart of ListFindingTypesQuery.includeId, and needed far more often
20956
+ // here. Selecting a row pushes the URL, which re-renders the server and resets
20957
+ // the client's page cache to page 0; with distinct (repo, file) pairs running
20958
+ // into the thousands, a selection sitting off page 0 is the ordinary case
20959
+ // rather than a deep-link corner. Never affects totals, facets or the cursor.
20960
+ includeId: external_exports.string().optional(),
20961
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
20962
+ cursor: external_exports.string().optional()
20924
20963
  });
20925
20964
  var ListFindingLocationsResponse = external_exports.object({
20926
20965
  totals: external_exports.object({
20966
+ // Findings matching the filters across the whole scope. Unlike the types
20967
+ // read's same-named field this needs no caveat: the filters here narrow
20968
+ // per finding, so this is the sum of every row's instanceCount.
20927
20969
  findings: external_exports.number().int().nonnegative(),
20928
- repos: external_exports.number().int().nonnegative(),
20929
- files: external_exports.number().int().nonnegative()
20970
+ // Counts LOCATIONS, the unit this read pages — the number the paginator
20971
+ // states. The facets beside it count FINDINGS (see below); a surface
20972
+ // showing both says which is which.
20973
+ locations: external_exports.number().int().nonnegative()
20930
20974
  }),
20931
- /** Sorted by max severity, then most recent. */
20932
- items: external_exports.array(FindingLocationRepo),
20933
- /** Whether `limit` truncated the repo list. */
20934
- hasMore: external_exports.boolean()
20975
+ // Counts in FINDINGS, where the types response counts types, each dimension
20976
+ // still excluding its own filter. Deliberately not locations: counting those
20977
+ // needs a set of location keys per dimension per value — memory tracking the
20978
+ // store times the vocabulary, in a read whose scan promises flat memory —
20979
+ // and the cheap per-location version is not an approximation but WRONG. A
20980
+ // location holding {claudecode, block} and {codex, warn} would survive
20981
+ // provider=claudecode AND action=warn, under which no single finding
20982
+ // matches, so the facet would contradict the instanceCount this whole view
20983
+ // rests on. Findings also keep the toolbar in the same unit as the page
20984
+ // tally and the panel it sits above.
20985
+ facets: FindingFacets,
20986
+ /** Sorted by max severity, then most recent, then (repo, file). */
20987
+ items: external_exports.array(FindingLocationSummary),
20988
+ nextCursor: external_exports.string().nullable()
20935
20989
  }).meta({ id: "ListFindingLocationsResponse" });
20936
20990
 
20937
20991
  // ../../packages/schema/src/zod/meta.ts
@@ -22100,6 +22154,14 @@ var ControlPlaneErrorBody = external_exports.object({
22100
22154
  message: external_exports.string().optional()
22101
22155
  }).optional()
22102
22156
  });
22157
+ var RemoteFailureKind = external_exports.enum([
22158
+ "unauthorized",
22159
+ "forbidden",
22160
+ "route-absent",
22161
+ "invalid-request",
22162
+ "rejected",
22163
+ "unreachable"
22164
+ ]);
22103
22165
  var AttachDeviceRequest = external_exports.object({
22104
22166
  // This machine's own continuity id, so re-attaching ROTATES the credential
22105
22167
  // on one machine record instead of producing a second one. Client-minted
@@ -22793,139 +22855,62 @@ function deriveFindingStatus(row) {
22793
22855
  if (row.latestResolutionStatus === "dismissed") return "dismissed";
22794
22856
  return "open";
22795
22857
  }
22796
- function distinctUsers(instances) {
22797
- const seen = /* @__PURE__ */ new Set();
22798
- const users = [];
22799
- for (const i of instances) {
22800
- if (i.user === void 0 || seen.has(i.user.id)) continue;
22801
- seen.add(i.user.id);
22802
- users.push(i.user);
22803
- }
22804
- return users;
22805
- }
22806
22858
  function sortUsers(users) {
22807
22859
  return [...users].sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
22808
22860
  }
22809
- function buildFindingGroups(rows, opts = {}) {
22810
- const overrides = opts.overrides;
22861
+ function buildFindingTypes(aggregates, opts = {}) {
22811
22862
  const packNames = opts.packNames;
22812
- const aggregates = opts.aggregates;
22813
- const byRuleId = /* @__PURE__ */ new Map();
22814
- for (const row of rows) {
22815
- const existing = byRuleId.get(row.ruleId);
22816
- if (existing) existing.push(row);
22817
- else byRuleId.set(row.ruleId, [row]);
22818
- }
22819
- const groups = [];
22820
- for (const [ruleId, ruleRows] of byRuleId) {
22821
- const instances = ruleRows.map((r) => {
22822
- const effectiveDbAction = overrides?.get(r.id) ?? r.actionTaken;
22823
- return {
22824
- id: r.id,
22825
- provider: toApiProvider(r.sourceTool),
22826
- repo: r.repo,
22827
- file: r.file,
22828
- ...r.toolName === void 0 ? {} : { toolName: r.toolName },
22829
- ...r.eventId === void 0 ? {} : { eventId: r.eventId },
22830
- ...r.sessionId === void 0 ? {} : { sessionId: r.sessionId },
22831
- ...r.user === void 0 ? {} : { user: r.user },
22832
- action: toApiAction(effectiveDbAction),
22833
- detectedAt: r.occurredAt,
22834
- confidence: r.confidence,
22835
- status: r.status
22836
- };
22837
- });
22838
- const agg = aggregates?.get(ruleId);
22839
- const users = agg ? sortUsers(agg.users ?? []) : distinctUsers(instances);
22840
- const latestDetectedAt = agg?.latestDetectedAt ?? ruleRows.reduce(
22841
- (max, r) => r.occurredAt > max ? r.occurredAt : max,
22842
- ruleRows[0]?.occurredAt ?? (/* @__PURE__ */ new Date(0)).toISOString()
22843
- );
22844
- const seenProviders = /* @__PURE__ */ new Set();
22845
- const providers = (agg ? [...new Set(agg.sourceTools.map(toApiProvider))].sort() : instances.map((i) => i.provider)).filter((p) => {
22846
- if (seenProviders.has(p)) return false;
22847
- seenProviders.add(p);
22848
- return true;
22849
- });
22850
- const actionSet = new Set(
22851
- agg ? agg.actionsTaken.map(toApiAction) : instances.map((i) => i.action)
22852
- );
22863
+ const types = [];
22864
+ for (const [ruleId, agg] of aggregates) {
22865
+ const users = sortUsers(agg.users ?? []);
22866
+ const providers = [...new Set(agg.sourceTools.map(toApiProvider))].sort();
22867
+ const actionSet = new Set(agg.actionsTaken.map(toApiAction));
22853
22868
  const aggregateAction = actionSet.size === 1 ? [...actionSet][0] ?? null : null;
22854
- const severity = ruleRows[0]?.severity ?? "low";
22855
- const detection = {
22856
- id: ruleId,
22857
- name: packNames?.get(ruleId) ?? null
22858
- };
22859
- const apiCategory = toApiCategory(ruleRows[0]?.category ?? "custom");
22860
- const policy = { id: `category:${apiCategory}`, name: apiCategory };
22861
- const match = {
22862
- maskedValue: ruleRows[0]?.maskedMatch ?? "",
22863
- contextPrefix: ""
22864
- // empty (pending privacy review)
22865
- };
22866
- const status = foldGroupStatus(
22867
- agg ? agg.statusInputs.map(deriveFindingStatus) : instances.map((i) => i.status)
22868
- );
22869
- const group = {
22869
+ const apiCategory = toApiCategory(agg.category ?? "custom");
22870
+ const type = {
22870
22871
  id: ruleId,
22871
22872
  category: apiCategory,
22872
22873
  subtype: ruleId,
22873
22874
  // human label comes with pack metadata later
22874
- severity,
22875
- match,
22876
- detection,
22877
- policy,
22878
- instanceCount: agg?.instanceCount ?? instances.length,
22875
+ severity: agg.severity ?? "low",
22876
+ detection: { id: ruleId, name: packNames?.get(ruleId) ?? null },
22877
+ policy: { id: `category:${apiCategory}`, name: apiCategory },
22878
+ instanceCount: agg.instanceCount,
22879
22879
  providers,
22880
22880
  aggregateAction,
22881
- latestDetectedAt,
22882
- instances,
22883
- status,
22881
+ latestDetectedAt: agg.latestDetectedAt,
22882
+ status: foldGroupStatus(agg.statusInputs.map(deriveFindingStatus)),
22884
22883
  ...users.length > 0 ? { users } : {}
22885
22884
  };
22886
- if (agg) {
22887
- actionsCache.set(group, [...actionSet]);
22888
- if (agg.searchText !== void 0) {
22889
- haystackCache.set(group, buildHaystack(group, agg.searchText));
22890
- }
22885
+ actionsCache.set(type, [...actionSet]);
22886
+ if (agg.searchText !== void 0) {
22887
+ haystackCache.set(type, buildHaystack(type, agg.searchText));
22891
22888
  }
22892
- groups.push(group);
22889
+ types.push(type);
22893
22890
  }
22894
- return groups;
22891
+ return types;
22895
22892
  }
22896
22893
  var haystackCache = /* @__PURE__ */ new WeakMap();
22897
- function buildHaystack(g, extra) {
22894
+ function buildHaystack(t, extra) {
22898
22895
  return [
22899
- g.subtype,
22900
- g.category,
22901
- g.match.maskedValue,
22902
- g.policy.name,
22903
- g.id,
22904
- ...g.instances.map((i) => i.repo),
22905
- ...g.instances.map((i) => i.file),
22906
- ...g.instances.map((i) => i.toolName ? `via ${i.toolName}` : ""),
22907
- ...g.instances.map((i) => i.id),
22908
- // The people: the whole group's list when the store folded one, plus the
22909
- // preview's own — the two overlap, and a haystack does not mind.
22910
- ...(g.users ?? []).map((u) => u.name),
22911
- ...g.instances.map((i) => i.user?.name ?? ""),
22896
+ t.subtype,
22897
+ t.category,
22898
+ t.policy.name,
22899
+ t.id,
22900
+ ...(t.users ?? []).map((u) => u.name),
22912
22901
  ...extra === void 0 ? [] : [extra]
22913
22902
  ].join(" ").toLowerCase();
22914
22903
  }
22915
- function groupHaystack(g) {
22916
- const cached2 = haystackCache.get(g);
22904
+ function typeHaystack(t) {
22905
+ const cached2 = haystackCache.get(t);
22917
22906
  if (cached2 !== void 0) return cached2;
22918
- const haystack = buildHaystack(g);
22919
- haystackCache.set(g, haystack);
22907
+ const haystack = buildHaystack(t);
22908
+ haystackCache.set(t, haystack);
22920
22909
  return haystack;
22921
22910
  }
22922
22911
  var actionsCache = /* @__PURE__ */ new WeakMap();
22923
- function groupActions(g) {
22924
- const cached2 = actionsCache.get(g);
22925
- if (cached2 !== void 0) return cached2;
22926
- const actions = [...new Set(g.instances.map((i) => i.action))];
22927
- actionsCache.set(g, actions);
22928
- return actions;
22912
+ function typeActions(t) {
22913
+ return actionsCache.get(t) ?? [];
22929
22914
  }
22930
22915
  function countInstancesByStatus(statusInputs, statuses) {
22931
22916
  const statusSet = new Set(statuses);
@@ -22936,8 +22921,8 @@ function countInstancesByStatus(statusInputs, statuses) {
22936
22921
  }
22937
22922
  return sum;
22938
22923
  }
22939
- function applyFindingFilters(groups, opts) {
22940
- let filtered = groups;
22924
+ function applyFindingFilters(types, opts) {
22925
+ let filtered = types;
22941
22926
  if (opts.severity && opts.severity.length > 0) {
22942
22927
  const sevSet = new Set(opts.severity);
22943
22928
  filtered = filtered.filter((g) => sevSet.has(g.severity));
@@ -22948,7 +22933,7 @@ function applyFindingFilters(groups, opts) {
22948
22933
  }
22949
22934
  if (opts.actions && opts.actions.length > 0) {
22950
22935
  const actionSet = new Set(opts.actions);
22951
- filtered = filtered.filter((g) => groupActions(g).some((a) => actionSet.has(a)));
22936
+ filtered = filtered.filter((t) => typeActions(t).some((a) => actionSet.has(a)));
22952
22937
  }
22953
22938
  if (opts.subtype && opts.subtype.length > 0) {
22954
22939
  const subtypeSet = new Set(opts.subtype);
@@ -22960,7 +22945,7 @@ function applyFindingFilters(groups, opts) {
22960
22945
  }
22961
22946
  if (opts.q) {
22962
22947
  const q = opts.q.toLowerCase();
22963
- filtered = filtered.filter((g) => groupHaystack(g).includes(q));
22948
+ filtered = filtered.filter((t) => typeHaystack(t).includes(q));
22964
22949
  }
22965
22950
  return filtered;
22966
22951
  }
@@ -22975,11 +22960,11 @@ function compareFindingGroupOrder(a, b) {
22975
22960
  if (recencyDiff !== 0) return recencyDiff;
22976
22961
  return a.id.localeCompare(b.id);
22977
22962
  }
22978
- function sortFindingGroups(groups) {
22979
- return [...groups].sort(compareFindingGroupOrder);
22963
+ function sortFindingTypes(types) {
22964
+ return [...types].sort(compareFindingGroupOrder);
22980
22965
  }
22981
- function computeFindingFacets(allGroups, opts) {
22982
- const forSeverity = applyFindingFilters(allGroups, {
22966
+ function computeFindingFacets(allTypes, opts) {
22967
+ const forSeverity = applyFindingFilters(allTypes, {
22983
22968
  providers: opts.providers,
22984
22969
  actions: opts.actions,
22985
22970
  statuses: opts.statuses,
@@ -22990,7 +22975,7 @@ function computeFindingFacets(allGroups, opts) {
22990
22975
  for (const g of forSeverity) {
22991
22976
  severityMap.set(g.severity, (severityMap.get(g.severity) ?? 0) + 1);
22992
22977
  }
22993
- const forProvider = applyFindingFilters(allGroups, {
22978
+ const forProvider = applyFindingFilters(allTypes, {
22994
22979
  actions: opts.actions,
22995
22980
  statuses: opts.statuses,
22996
22981
  q: opts.q,
@@ -23001,7 +22986,7 @@ function computeFindingFacets(allGroups, opts) {
23001
22986
  for (const g of forProvider) {
23002
22987
  for (const p of g.providers) providerMap.set(p, (providerMap.get(p) ?? 0) + 1);
23003
22988
  }
23004
- const forAction = applyFindingFilters(allGroups, {
22989
+ const forAction = applyFindingFilters(allTypes, {
23005
22990
  providers: opts.providers,
23006
22991
  statuses: opts.statuses,
23007
22992
  q: opts.q,
@@ -23010,9 +22995,9 @@ function computeFindingFacets(allGroups, opts) {
23010
22995
  });
23011
22996
  const actionMap = /* @__PURE__ */ new Map();
23012
22997
  for (const g of forAction) {
23013
- for (const a of groupActions(g)) actionMap.set(a, (actionMap.get(a) ?? 0) + 1);
22998
+ for (const a of typeActions(g)) actionMap.set(a, (actionMap.get(a) ?? 0) + 1);
23014
22999
  }
23015
- const forSubtype = applyFindingFilters(allGroups, {
23000
+ const forSubtype = applyFindingFilters(allTypes, {
23016
23001
  providers: opts.providers,
23017
23002
  actions: opts.actions,
23018
23003
  statuses: opts.statuses,
@@ -23021,7 +23006,7 @@ function computeFindingFacets(allGroups, opts) {
23021
23006
  });
23022
23007
  const subtypeMap = /* @__PURE__ */ new Map();
23023
23008
  for (const g of forSubtype) subtypeMap.set(g.subtype, (subtypeMap.get(g.subtype) ?? 0) + 1);
23024
- const forStatus = applyFindingFilters(allGroups, {
23009
+ const forStatus = applyFindingFilters(allTypes, {
23025
23010
  providers: opts.providers,
23026
23011
  actions: opts.actions,
23027
23012
  q: opts.q,
@@ -23069,10 +23054,20 @@ function matchesDimension(row, opts, dimension) {
23069
23054
  return !opts.statuses?.length || row.status !== void 0 && opts.statuses.includes(row.status);
23070
23055
  case "tools":
23071
23056
  return !opts.tools?.length || row.toolName !== void 0 && opts.tools.includes(row.toolName);
23057
+ // An EMPTY value is a real filter here, not an absent one. The location
23058
+ // list buckets a finding whose event recorded no repo — or no file — under
23059
+ // the empty string, and selecting that bucket has to narrow the panel to
23060
+ // exactly it. Only `undefined` means "no filter"; a caller that wants every
23061
+ // row omits the key, which every call site already does.
23062
+ //
23063
+ // Reading '' as unset is what this replaced, and it failed in the one place
23064
+ // it mattered: the no-repo/no-file bucket is often the largest in a real
23065
+ // store, and its panel dropped both predicates and returned the WHOLE scope
23066
+ // — a row reading 3 findings beside a panel listing every finding there is.
23072
23067
  case "repo":
23073
- return opts.repo === void 0 || opts.repo === "" || row.repo === opts.repo;
23068
+ return opts.repo === void 0 || row.repo === opts.repo;
23074
23069
  case "file":
23075
- return opts.file === void 0 || opts.file === "" || row.file === opts.file;
23070
+ return opts.file === void 0 || row.file === opts.file;
23076
23071
  case "q":
23077
23072
  return !opts.q || rowHaystack(row).includes(opts.q.toLowerCase());
23078
23073
  }
@@ -23186,6 +23181,23 @@ function addToLocation(acc, row) {
23186
23181
  acc.statuses.push(row.status);
23187
23182
  acc.ruleIds.add(row.ruleId);
23188
23183
  }
23184
+ function compareLocationOrder(a, b) {
23185
+ const rankA = SEVERITY_ORDER2[a.maxSeverity] ?? -1;
23186
+ const rankB = SEVERITY_ORDER2[b.maxSeverity] ?? -1;
23187
+ if (rankA !== rankB) return rankA - rankB;
23188
+ if (a.latestDetectedAt !== b.latestDetectedAt) {
23189
+ return a.latestDetectedAt < b.latestDetectedAt ? 1 : -1;
23190
+ }
23191
+ if (a.repo !== b.repo) return a.repo < b.repo ? -1 : 1;
23192
+ if (a.file !== b.file) return a.file < b.file ? -1 : 1;
23193
+ return 0;
23194
+ }
23195
+ function encodeLocationId(repo, file2) {
23196
+ return `${encodePart(repo)}/${encodePart(file2)}`;
23197
+ }
23198
+ function encodePart(value) {
23199
+ return encodeURIComponent(value.replace(/[\uD800-\uDFFF]/gu, "\uFFFD"));
23200
+ }
23189
23201
 
23190
23202
  // ../../packages/schema/src/zod/installed-pack.ts
23191
23203
  var InstalledPack = external_exports.object({
@@ -23700,11 +23712,11 @@ var WorkspaceSettings = external_exports.object({
23700
23712
  // covers the current payload and must be re-granted.
23701
23713
  modelJudgeConsent: ModelJudgeConsent.optional(),
23702
23714
  // Records that the user consented to the DEFERRED send — the outbox — along
23703
- // with the payload shape and the endpoint they agreed to. Since payload v2
23704
- // that covers both the pre-attach backlog and undelivered captures (which
23705
- // carry prompt/reply text in `content`); the key name predates the widening.
23706
- // Absent until granted, and a grant for a different endpoint or an older
23707
- // payload no longer counts.
23715
+ // with the payload shape and the endpoint they agreed to. Since payload v3
23716
+ // that covers the pre-attach backlog AND undelivered captures alike, and both
23717
+ // carry prompt/reply/tool-output text in `content`; the key name predates
23718
+ // both widenings. Absent until granted, and a grant for a different endpoint
23719
+ // or an older payload no longer counts.
23708
23720
  historySyncConsent: HistorySyncConsent.optional()
23709
23721
  });
23710
23722
  function defaultWorkspaceSettings() {
@@ -23835,6 +23847,9 @@ var ManagedSettingKey = external_exports.enum([
23835
23847
  "dataSharesInPlace",
23836
23848
  "redactFallback"
23837
23849
  ]).meta({ id: "ManagedSettingKey" });
23850
+ function isManagedSettingKey(value) {
23851
+ return ManagedSettingKey.safeParse(value).success;
23852
+ }
23838
23853
  var ManagedSettingsValues = external_exports.object({
23839
23854
  runMode: external_exports.enum(["standalone", "attached"]).optional(),
23840
23855
  controlPlane: external_exports.object({
@@ -23859,7 +23874,27 @@ var ManagedSettings = external_exports.object({
23859
23874
  // Which of those the user may not change. A key here with no matching value
23860
23875
  // freezes whatever the user last chose; a value with no lock is a DEFAULT
23861
23876
  // the user may still override. The two are separable on purpose.
23862
- lockedFields: external_exports.array(ManagedSettingKey).default([])
23877
+ //
23878
+ // Parsed as NAMES rather than as the enum, and split below: a name this
23879
+ // build does not know is dropped from the locked set and reported, never a
23880
+ // reason to refuse the file. The same shape reaches an older build whenever
23881
+ // an administrator locks a key a newer build added, and refusing it there
23882
+ // ran that build entirely unmanaged — every pin and lock gone — on exactly
23883
+ // the fleets most likely to carry a version skew. A name outside the enum
23884
+ // is still never HONOURED: the lockable set stays explicit above.
23885
+ lockedFields: external_exports.array(external_exports.string()).default([])
23886
+ }).transform(({ lockedFields, ...rest }) => {
23887
+ const known = [];
23888
+ const unknown2 = [];
23889
+ for (const name of lockedFields) {
23890
+ if (isManagedSettingKey(name)) known.push(name);
23891
+ else unknown2.push(name);
23892
+ }
23893
+ return {
23894
+ ...rest,
23895
+ lockedFields: known,
23896
+ ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {}
23897
+ };
23863
23898
  }).meta({ id: "ManagedSettings" });
23864
23899
 
23865
23900
  // ../../packages/schema/src/zod/project-files.ts
@@ -23983,7 +24018,11 @@ var FindingsTimeseriesPoint = external_exports.object({
23983
24018
  timestamp: external_exports.iso.date(),
23984
24019
  critical: external_exports.number().int().nonnegative(),
23985
24020
  high: external_exports.number().int().nonnegative(),
23986
- medium: external_exports.number().int().nonnegative()
24021
+ medium: external_exports.number().int().nonnegative(),
24022
+ // Optional and additive, so a producer written against the earlier
24023
+ // three-series contract keeps validating. A consumer plotting it resolves the
24024
+ // absent case itself — the chart point requires a number.
24025
+ low: external_exports.number().int().nonnegative().optional()
23987
24026
  }).meta({ id: "FindingsTimeseriesPoint" });
23988
24027
  var FindingsTimeseriesResponse = external_exports.object({
23989
24028
  range: TimeRange,
@@ -24009,6 +24048,10 @@ var ResolvedFeedItem = external_exports.object({
24009
24048
  findingKey: external_exports.string(),
24010
24049
  ruleId: external_exports.string(),
24011
24050
  severity: Severity,
24051
+ // Repository slug, and the file path RELATIVE to it. The pair is what
24052
+ // identifies the file: a bare path matches the same name in every repo.
24053
+ // Optional and additive; empty when the event carried no repo.
24054
+ repo: external_exports.string().optional(),
24012
24055
  path: external_exports.string(),
24013
24056
  // ISO-8601 datetime (matches FindingInstance.detectedAt / the rest of the
24014
24057
  // findings domain). The reader `.toISOString()`s the DB epoch-ms values.
@@ -25582,7 +25625,8 @@ var SqliteActivityRepository = class {
25582
25625
  SELECT 1 FROM audit_events d
25583
25626
  WHERE d.root_session_id = audit_events.id
25584
25627
  AND (d.content LIKE ? ESCAPE '\\'
25585
- OR json_extract(d.attributes, '$.detail') LIKE ? ESCAPE '\\')))`
25628
+ OR coalesce(json_extract(d.attributes, '$.detail'),
25629
+ json_extract(d.attributes, '$.target')) LIKE ? ESCAPE '\\')))`
25586
25630
  );
25587
25631
  params.push(pattern, pattern, pattern, pattern, pattern, pattern);
25588
25632
  }
@@ -26920,23 +26964,6 @@ var LATEST_RESOLUTION_BY_KEY_SQL = `(
26920
26964
  )`;
26921
26965
 
26922
26966
  // ../../packages/persistence/src/repositories/findings.ts
26923
- var PREVIEW_INSTANCES_PER_GROUP = 200;
26924
- var DEFAULT_LOCATIONS_LIMIT = 100;
26925
- var LOCATION_RULE_IDS_CAP = 20;
26926
- function compareLocationOrder(a, b) {
26927
- return compareFindingGroupOrder(
26928
- {
26929
- severity: a.maxSeverity,
26930
- latestDetectedAt: a.latestDetectedAt,
26931
- id: ""
26932
- },
26933
- {
26934
- severity: b.maxSeverity,
26935
- latestDetectedAt: b.latestDetectedAt,
26936
- id: ""
26937
- }
26938
- );
26939
- }
26940
26967
  var CONCAT_SEP = ",";
26941
26968
  var TUPLE_SEP = "|";
26942
26969
  function splitConcat(value) {
@@ -26988,13 +27015,48 @@ function decodeGroupCursor(cursor) {
26988
27015
  return null;
26989
27016
  }
26990
27017
  function firstAfter(sorted, cursor) {
26991
- const index = sorted.findIndex((g) => compareFindingGroupOrder(g, cursor) > 0);
27018
+ const index = sorted.findIndex((t) => compareFindingGroupOrder(t, cursor) > 0);
26992
27019
  return index === -1 ? sorted.length : index;
26993
27020
  }
26994
27021
  function findDeepLinked(sorted, page, id) {
26995
- if (page.some((g) => g.id === id || g.instances.some((i) => i.id === id))) return void 0;
26996
- return sorted.find((g) => g.id === id || g.instances.some((i) => i.id === id));
27022
+ if (page.some((t) => t.id === id)) return void 0;
27023
+ return sorted.find((t) => t.id === id);
27024
+ }
27025
+ function encodeLocationCursor(location) {
27026
+ const payload = {
27027
+ sev: location.maxSeverity,
27028
+ t: location.latestDetectedAt,
27029
+ r: location.repo,
27030
+ f: location.file
27031
+ };
27032
+ return Buffer.from(JSON.stringify(payload)).toString("base64url");
27033
+ }
27034
+ function decodeLocationCursor(cursor) {
27035
+ const parsed2 = parseJsonObject(Buffer.from(cursor, "base64url").toString("utf8"));
27036
+ if (parsed2 !== void 0 && typeof parsed2.sev === "string" && typeof parsed2.t === "string" && typeof parsed2.r === "string" && typeof parsed2.f === "string") {
27037
+ return { maxSeverity: parsed2.sev, latestDetectedAt: parsed2.t, repo: parsed2.r, file: parsed2.f };
27038
+ }
27039
+ return null;
26997
27040
  }
27041
+ function firstLocationAfter(sorted, cursor) {
27042
+ const index = sorted.findIndex((l) => compareLocationOrder(l, cursor) > 0);
27043
+ return index === -1 ? sorted.length : index;
27044
+ }
27045
+ function findDeepLinkedLocation(sorted, page, id) {
27046
+ if (page.some((l) => l.id === id)) return void 0;
27047
+ return sorted.find((l) => l.id === id);
27048
+ }
27049
+ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS category,
27050
+ d.severity AS severity, f.masked_match AS masked_match,
27051
+ f.action_taken AS action_taken, f.confidence AS confidence,
27052
+ e.started_at AS occurred_at,
27053
+ e.source_tool AS source_tool,
27054
+ e.repo AS repo,
27055
+ e.file_path AS file,
27056
+ e.tool_name AS tool_name,
27057
+ f.audit_event_id AS event_id, e.root_session_id AS session_id,
27058
+ e.event_type AS kind, f.finding_key AS finding_key,
27059
+ ${latestResolutionStatusSql("f")} AS latest_status`;
26998
27060
  var DAY_MS3 = 864e5;
26999
27061
  var SqliteFindingsRepository = class {
27000
27062
  constructor(db) {
@@ -27115,30 +27177,26 @@ var SqliteFindingsRepository = class {
27115
27177
  );
27116
27178
  }
27117
27179
  /**
27118
- * Grouped findings for the dashboard — joins inspection_findings⋈audit_events
27119
- * ⋈inspection_definitions (repo/file/toolName from the audit event's
27120
- * attributes bag, rule_id/category/severity from the definition), scoped to
27121
- * the four capture kinds (audit_events also holds structural/reconciler/scan
27122
- * rows this list must never surface), groups by ruleId, computes
27123
- * per-filter-excluded facets, applies the requested filters, and sorts by
27124
- * severity then recency. Filtering
27125
- * and faceting run in JS via the shared @akasecurity/schema helpers. `totals`
27126
- * reflect the full filtered set; `items` is the requested
27127
- * page (default 50); no cursor (nextCursor is always null). Under a `status`
27128
- * filter, `totals.findings` counts only instances whose derived status was
27129
- * requested, and each item's instance preview is narrowed the same way.
27180
+ * Finding TYPES for the dashboard — one row per rule, scoped to the four
27181
+ * capture kinds (audit_events also holds structural/reconciler/scan rows this
27182
+ * list must never surface), with per-filter-excluded facets, the requested
27183
+ * filters applied, and sorted by severity then recency. Filtering and faceting
27184
+ * run in JS via the shared @akasecurity/schema helpers. `totals` reflect the
27185
+ * full filtered set; `items` is the requested page (default 50), keyset-paged.
27186
+ * Under a `status` filter, `totals.findings` counts only findings whose
27187
+ * derived status was requested.
27188
+ *
27189
+ * ONE read, which materializes no findings: a single aggregate per rule_id,
27190
+ * folding EVERY finding into the numbers a type row and the filters need
27191
+ * (count, severity, category, providers, actions, statuses, latest, search
27192
+ * text). The findings OF a type come from listFindingInstances scoped to
27193
+ * `subtype`, so neither list bounds the other and no per-type cap exists.
27130
27194
  *
27131
- * Two reads, neither of which materializes a row per finding:
27132
- * 1. one aggregate row per rule_id, folding EVERY instance into the numbers
27133
- * the group and the filters need (count, providers, actions, statuses,
27134
- * latest, search text);
27135
- * 2. each group's newest PREVIEW_INSTANCES_PER_GROUP instances, which
27136
- * populate `instances` for the table's expanded rows.
27137
27195
  * The aggregates carry raw DB values and are translated by the same
27138
- * @akasecurity/schema mappers the row path uses, so no enum mapping or status
27139
- * rule is ever restated in SQL.
27196
+ * @akasecurity/schema mappers every other path uses, so no enum mapping or
27197
+ * status rule is ever restated in SQL.
27140
27198
  */
27141
- listGroupedFindings(query) {
27199
+ listFindingTypes(query) {
27142
27200
  const sessionPredicate = query.sessionId ? ` AND e.root_session_id = :sessionId` : "";
27143
27201
  const fromMs = query.from === void 0 ? void 0 : isoToEpochMillis(query.from);
27144
27202
  const fromPredicate = fromMs === void 0 ? "" : ` AND e.started_at >= :fromMs`;
@@ -27151,12 +27209,7 @@ var SqliteFindingsRepository = class {
27151
27209
  predicate,
27152
27210
  params: sessionParams
27153
27211
  });
27154
- const rows = this.previewRows(aggregates, {
27155
- sessionId: query.sessionId,
27156
- from: query.from
27157
- });
27158
- const groupable = rows.map(toFlatFindingRow);
27159
- const allGroups = buildFindingGroups(groupable, { aggregates });
27212
+ const allTypes = buildFindingTypes(aggregates);
27160
27213
  const filterOpts = {
27161
27214
  severity: query.severity,
27162
27215
  providers: query.provider,
@@ -27165,30 +27218,25 @@ var SqliteFindingsRepository = class {
27165
27218
  subtype: query.subtype,
27166
27219
  q: query.q
27167
27220
  };
27168
- const facets = computeFindingFacets(allGroups, filterOpts);
27169
- const sorted = sortFindingGroups(applyFindingFilters(allGroups, filterOpts));
27221
+ const facets = computeFindingFacets(allTypes, filterOpts);
27222
+ const sorted = sortFindingTypes(applyFindingFilters(allTypes, filterOpts));
27170
27223
  const statusFilter = query.status ?? [];
27171
27224
  const totals = {
27172
- findings: sorted.reduce((acc, g) => {
27173
- if (statusFilter.length === 0) return acc + g.instanceCount;
27174
- const agg = aggregates.get(g.id);
27175
- return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ?? g.instanceCount : g.instanceCount);
27225
+ findings: sorted.reduce((acc, t) => {
27226
+ if (statusFilter.length === 0) return acc + t.instanceCount;
27227
+ const agg = aggregates.get(t.id);
27228
+ return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ?? t.instanceCount : t.instanceCount);
27176
27229
  }, 0),
27177
- groups: sorted.length
27230
+ types: sorted.length
27178
27231
  };
27179
- const limit = query.limit ?? DEFAULT_GROUPED_FINDINGS_LIMIT;
27232
+ const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
27180
27233
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
27181
27234
  const start = cursor === null ? 0 : firstAfter(sorted, cursor);
27182
27235
  const page = sorted.slice(start, start + limit);
27183
27236
  const lastOnPage = page.at(-1);
27184
27237
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
27185
27238
  const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinked(sorted, page, query.includeId);
27186
- const statusSet = statusFilter.length > 0 ? new Set(statusFilter) : null;
27187
- const narrow = (g) => statusSet ? {
27188
- ...g,
27189
- instances: g.instances.filter((i) => i.status !== void 0 && statusSet.has(i.status))
27190
- } : g;
27191
- const items = [...page, ...deepLinked ? [deepLinked] : []].map(narrow);
27239
+ const items = [...page, ...deepLinked ? [deepLinked] : []];
27192
27240
  return Promise.resolve({
27193
27241
  totals,
27194
27242
  facets,
@@ -27199,7 +27247,7 @@ var SqliteFindingsRepository = class {
27199
27247
  }
27200
27248
  /**
27201
27249
  * One row per rule_id, folding EVERY instance of the group into the values
27202
- * buildFindingGroups cannot recover from a preview. Bounded by the number of
27250
+ * buildFindingTypes cannot recover from an aggregate. Bounded by the number of
27203
27251
  * distinct rule_ids (the installed packs' rules), not by the store's size.
27204
27252
  *
27205
27253
  * A single scan, folded in two levels: the inner SELECT groups by
@@ -27293,13 +27341,25 @@ var SqliteFindingsRepository = class {
27293
27341
  });
27294
27342
  }
27295
27343
  /**
27296
- * The same findings folded by location: repository, then file within it.
27344
+ * The same findings folded by WHERE they live — one row per (repo, file) pair.
27297
27345
  *
27298
27346
  * The grouping keys come from the capturing event's attributes, which is what
27299
- * the local store relates a finding to — there is no finding↔asset row to
27300
- * group by instead. A repo or file the event did not record folds into the
27301
- * empty-string bucket, which the view renders but does not link, since no
27302
- * filter can name it.
27347
+ * the local store relates a finding to; there is no finding↔asset row to group
27348
+ * by instead. A repo or file the event did not record folds into the
27349
+ * empty-string bucket, which is a real location like any other: it is listed,
27350
+ * it is selectable, and its `?loc=` token is as good as any other row's.
27351
+ *
27352
+ * ONE flat list rather than repos nesting files. A rollup can only be paged by
27353
+ * repo, which leaves the file list inside it unbounded — the shape the by-type
27354
+ * list was rebuilt to remove — and two-level pagination inside an
27355
+ * expand/collapse table is what pushed that view to master/detail in the first
27356
+ * place.
27357
+ *
27358
+ * Every filter narrows the FINDINGS and the locations fall out of what
27359
+ * survives, so each row's `instanceCount` is exactly what listFindingInstances
27360
+ * reports for the same filters scoped to that pair. The view depends on it:
27361
+ * one toolbar sits over both panels precisely because a location owns none of
27362
+ * its fields.
27303
27363
  */
27304
27364
  listFindingLocations(query) {
27305
27365
  const opts = {
@@ -27311,13 +27371,16 @@ var SqliteFindingsRepository = class {
27311
27371
  tools: query.tool,
27312
27372
  q: query.q
27313
27373
  };
27314
- const limit = query.limit ?? DEFAULT_LOCATIONS_LIMIT;
27374
+ const limit = query.limit ?? DEFAULT_FINDING_LOCATIONS_LIMIT;
27375
+ const cursor = query.cursor === void 0 ? null : decodeLocationCursor(query.cursor);
27315
27376
  const byRepo = /* @__PURE__ */ new Map();
27377
+ const accumulator = createInstanceFacetAccumulator(opts);
27316
27378
  let total = 0;
27317
27379
  for (const row of this.scanFindingRows({
27318
27380
  sessionId: query.sessionId,
27319
27381
  from: query.from
27320
27382
  })) {
27383
+ accumulator.add(row);
27321
27384
  if (!matchesInstanceFilters(row, opts)) continue;
27322
27385
  total += 1;
27323
27386
  let files = byRepo.get(row.repo);
@@ -27332,103 +27395,35 @@ var SqliteFindingsRepository = class {
27332
27395
  }
27333
27396
  addToLocation(acc, row);
27334
27397
  }
27335
- let fileCount = 0;
27336
- const repos = [...byRepo.entries()].map(([repo, files]) => {
27337
- fileCount += files.size;
27338
- const fileRows = [...files.entries()].map(([file2, acc]) => ({
27339
- file: file2,
27340
- instanceCount: acc.instanceCount,
27341
- maxSeverity: acc.maxSeverity,
27342
- latestDetectedAt: acc.latestDetectedAt,
27343
- ...foldGroupStatus(acc.statuses) === void 0 ? {} : { status: foldGroupStatus(acc.statuses) },
27344
- ruleIds: [...acc.ruleIds].slice(0, LOCATION_RULE_IDS_CAP)
27345
- })).sort(compareLocationOrder);
27346
- const rollup = fileRows.reduce(
27347
- (a, f) => ({
27348
- instanceCount: a.instanceCount + f.instanceCount,
27349
- maxSeverity: compareLocationOrder(f, a) < 0 ? f.maxSeverity : a.maxSeverity,
27350
- latestDetectedAt: f.latestDetectedAt > a.latestDetectedAt ? f.latestDetectedAt : a.latestDetectedAt
27351
- }),
27352
- {
27353
- instanceCount: 0,
27354
- maxSeverity: fileRows[0]?.maxSeverity ?? "low",
27355
- latestDetectedAt: ""
27356
- }
27357
- );
27358
- const statuses = fileRows.map((f) => f.status);
27359
- const folded = foldGroupStatus(statuses);
27360
- return {
27361
- repo,
27362
- instanceCount: rollup.instanceCount,
27363
- maxSeverity: rollup.maxSeverity,
27364
- latestDetectedAt: rollup.latestDetectedAt,
27365
- ...folded === void 0 ? {} : { status: folded },
27366
- files: fileRows
27367
- };
27368
- });
27369
- repos.sort(compareLocationOrder);
27398
+ const sorted = [];
27399
+ for (const [repo, files] of byRepo) {
27400
+ for (const [file2, acc] of files) {
27401
+ const status = foldGroupStatus(acc.statuses);
27402
+ sorted.push({
27403
+ id: encodeLocationId(repo, file2),
27404
+ repo,
27405
+ file: file2,
27406
+ instanceCount: acc.instanceCount,
27407
+ maxSeverity: acc.maxSeverity,
27408
+ latestDetectedAt: acc.latestDetectedAt,
27409
+ ...status === void 0 ? {} : { status },
27410
+ ruleIds: [...acc.ruleIds]
27411
+ });
27412
+ }
27413
+ }
27414
+ sorted.sort(compareLocationOrder);
27415
+ const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
27416
+ const page = sorted.slice(start, start + limit);
27417
+ const lastOnPage = page.at(-1);
27418
+ const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
27419
+ const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinkedLocation(sorted, page, query.includeId);
27370
27420
  return Promise.resolve({
27371
- totals: { findings: total, repos: repos.length, files: fileCount },
27372
- items: repos.slice(0, limit),
27373
- hasMore: repos.length > limit
27421
+ totals: { findings: total, locations: sorted.length },
27422
+ facets: accumulator.facets(),
27423
+ items: [...page, ...deepLinked ? [deepLinked] : []],
27424
+ nextCursor
27374
27425
  });
27375
27426
  }
27376
- /**
27377
- * Each group's newest instances, for the table's expanded rows.
27378
- *
27379
- * ONE index-ordered scan with early termination, and the shape is the point.
27380
- * The natural spelling — `ROW_NUMBER() OVER (PARTITION BY rule_id ORDER BY
27381
- * started_at DESC)` then `WHERE rn <= cap` — sorts EVERY finding in scope
27382
- * through a temp B-tree to keep a bounded preview of each group, and then
27383
- * sorts the survivors again for the page order. Both sorts grow with the
27384
- * store while the answer does not.
27385
- *
27386
- * Instead the scan walks `audit_events` newest-first off `idx_audit_started_at`
27387
- * (or the session or window index the scope names — see `findingScanSql`),
27388
- * which is already the order the page wants, and keeps rows per rule until
27389
- * each rule has as many as it can show. The aggregate the caller already holds
27390
- * says how many that is: `min(instanceCount, PREVIEW_INSTANCES_PER_GROUP)`
27391
- * per rule, summed, is the number of rows this scan has to find, and it stops
27392
- * on the last one. That sum is bounded by `rules * PREVIEW_INSTANCES_PER_GROUP`
27393
- * (8,000 at this repo's 40-rule bench corpus), not by a fixed row count — a
27394
- * store with many firing rules widens it. The bound that DOES hold
27395
- * unconditionally is the sorted form's floor: this scan visits at most as
27396
- * many rows as `ROW_NUMBER() OVER (PARTITION BY rule_id …)` would have
27397
- * sorted, and stops the moment every rule has its cap, where the sorted form
27398
- * sorts the whole scope regardless. The true worst case — the rarest rule's
27399
- * wanted instances sitting at the tail of the scope — is one pass over
27400
- * everything in scope with a block sort of the id tie-break only, never a
27401
- * sort of the scope, which is still that floor.
27402
- *
27403
- * A row whose rule the aggregate did not see is skipped: the two statements
27404
- * run without a shared snapshot, so a capture landing between them can add a
27405
- * rule here that has no counts there, and the counts are what the group is
27406
- * built from.
27407
- */
27408
- previewRows(aggregates, scope) {
27409
- const wanted = /* @__PURE__ */ new Map();
27410
- let remaining = 0;
27411
- for (const [ruleId, agg] of aggregates) {
27412
- const n = Math.min(agg.instanceCount, PREVIEW_INSTANCES_PER_GROUP);
27413
- wanted.set(ruleId, n);
27414
- remaining += n;
27415
- }
27416
- const rows = [];
27417
- if (remaining === 0) return rows;
27418
- const { sql, params } = this.findingScanSql(scope);
27419
- const taken = /* @__PURE__ */ new Map();
27420
- for (const r of iterateRows(this.db.prepare(sql), params)) {
27421
- const want = wanted.get(r.rule_id);
27422
- if (want === void 0) continue;
27423
- const have = taken.get(r.rule_id) ?? 0;
27424
- if (have >= want) continue;
27425
- taken.set(r.rule_id, have + 1);
27426
- rows.push(r);
27427
- remaining -= 1;
27428
- if (remaining === 0) break;
27429
- }
27430
- return rows;
27431
- }
27432
27427
  /**
27433
27428
  * Every finding in scope as a FlatFindingRow, newest first, streamed.
27434
27429
  *
@@ -27455,6 +27450,33 @@ var SqliteFindingsRepository = class {
27455
27450
  yield toFlatFindingRow(r);
27456
27451
  }
27457
27452
  }
27453
+ /**
27454
+ * One finding by its own id, or null when no such row exists.
27455
+ *
27456
+ * A primary-key seek on `inspection_findings`, so its cost does not grow with
27457
+ * the store — and, unlike anything derived from a list page, it resolves a
27458
+ * finding of ANY age. That is what the Findings page's one-shot `?finding=`
27459
+ * deep link needs: the id it carries may name a finding thousands of rows
27460
+ * older than anything a first page holds.
27461
+ *
27462
+ * Deliberately UNFILTERED — no capture-kind, session or time predicate. It
27463
+ * RESOLVES an id; whether that row would survive the list's current filters is
27464
+ * a different question, and hiding the target because a filter excludes it is
27465
+ * worse than showing it.
27466
+ *
27467
+ * `groupId` on the result IS the rule id, so this one read answers both "which
27468
+ * type should the list select?" and "what does the drawer show?".
27469
+ */
27470
+ findingInstance(id) {
27471
+ const row = this.db.prepare(
27472
+ `SELECT ${FINDING_ROW_COLUMNS_SQL}
27473
+ FROM inspection_findings f
27474
+ JOIN audit_events e ON e.id = f.audit_event_id
27475
+ JOIN inspection_definitions d ON d.id = f.inspection_definition_id
27476
+ WHERE f.id = ?`
27477
+ ).get(id);
27478
+ return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
27479
+ }
27458
27480
  /**
27459
27481
  * The one statement both instance-level scans run: every finding in scope,
27460
27482
  * joined to its event and definition, newest first.
@@ -27488,17 +27510,7 @@ var SqliteFindingsRepository = class {
27488
27510
  conditions.push("e.started_at >= ?");
27489
27511
  params.push(isoToEpochMillis(scope.from));
27490
27512
  }
27491
- const sql = `SELECT f.id AS id, d.rule_id AS rule_id, d.category AS category,
27492
- d.severity AS severity, f.masked_match AS masked_match,
27493
- f.action_taken AS action_taken, f.confidence AS confidence,
27494
- e.started_at AS occurred_at,
27495
- e.source_tool AS source_tool,
27496
- e.repo AS repo,
27497
- e.file_path AS file,
27498
- e.tool_name AS tool_name,
27499
- f.audit_event_id AS event_id, e.root_session_id AS session_id,
27500
- e.event_type AS kind, f.finding_key AS finding_key,
27501
- ${latestResolutionStatusSql("f")} AS latest_status
27513
+ const sql = `SELECT ${FINDING_ROW_COLUMNS_SQL}
27502
27514
  FROM audit_events e
27503
27515
  CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
27504
27516
  CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
@@ -27512,6 +27524,26 @@ var SqliteFindingsRepository = class {
27512
27524
  group_concat(DISTINCT 'via ' || e.tool_name) AS tool_names` : `, NULL AS repos, NULL AS files, NULL AS tool_names`;
27513
27525
  const rows = this.db.prepare(
27514
27526
  `SELECT rule_id,
27527
+ -- BARE columns beside max(latest_at), which is deliberate and
27528
+ -- is SQLite's documented behaviour: with a single min()/max()
27529
+ -- in an aggregate query, every bare column takes its value from
27530
+ -- the row that produced the extremum. So these are the severity
27531
+ -- and category of the definition whose finding is NEWEST, which
27532
+ -- is what the row-based build they replaced read off its first
27533
+ -- (newest-first) row.
27534
+ --
27535
+ -- min() is WRONG here and was the defect: inspection_definitions
27536
+ -- holds one row per rule VERSION (see its writer \u2014 a version bump
27537
+ -- mints a new row), so a rule whose severity moved between
27538
+ -- versions has several, and min() picks the ALPHABETICALLY
27539
+ -- smallest \u2014 'low' over 'medium', but 'critical' over 'high'.
27540
+ -- That is arbitrary in direction, and it feeds the badge, the
27541
+ -- filter, the facet counts and the primary sort key.
27542
+ --
27543
+ -- Adding a second min()/max() aggregate here would make these
27544
+ -- bare columns ambiguous again; keep max(latest_at) the only one.
27545
+ severity,
27546
+ category,
27515
27547
  sum(tuple_count) AS instance_count,
27516
27548
  max(latest_at) AS latest_at,
27517
27549
  group_concat(source_tools) AS source_tools,
@@ -27522,6 +27554,14 @@ var SqliteFindingsRepository = class {
27522
27554
  group_concat(tool_names) AS tool_names
27523
27555
  FROM (
27524
27556
  SELECT d.rule_id AS rule_id,
27557
+ -- Severity and category are columns of the DEFINITION, and
27558
+ -- a rule can have SEVERAL definitions (one per version), so
27559
+ -- these are grouped on below and resolved to the newest
27560
+ -- firing version by the outer query's bare-column select.
27561
+ -- They ride the aggregate because the type build has no rows
27562
+ -- to read them off \u2014 see buildFindingTypes.
27563
+ d.severity AS severity,
27564
+ d.category AS category,
27525
27565
  e.event_type || '${TUPLE_SEP}' ||
27526
27566
  (CASE WHEN f.finding_key IS NULL THEN '' ELSE 'k' END) || '${TUPLE_SEP}' ||
27527
27567
  coalesce(latest.status, '') AS status_tuple,
@@ -27536,7 +27576,7 @@ var SqliteFindingsRepository = class {
27536
27576
  LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
27537
27577
  ON latest.finding_key = f.finding_key
27538
27578
  ${scope.predicate}
27539
- GROUP BY d.rule_id, status_tuple
27579
+ GROUP BY d.rule_id, d.severity, d.category, status_tuple
27540
27580
  )
27541
27581
  GROUP BY rule_id`
27542
27582
  ).all(scope.params);
@@ -27545,6 +27585,8 @@ var SqliteFindingsRepository = class {
27545
27585
  r.rule_id,
27546
27586
  {
27547
27587
  instanceCount: r.instance_count,
27588
+ severity: r.severity,
27589
+ category: r.category,
27548
27590
  sourceTools: splitConcat(r.source_tools),
27549
27591
  actionsTaken: splitConcat(r.actions_taken),
27550
27592
  statusInputs: splitConcat(r.status_inputs).map((tuple2) => {
@@ -27561,7 +27603,7 @@ var SqliteFindingsRepository = class {
27561
27603
  latestDetectedAt: epochMillisToIso(r.latest_at),
27562
27604
  // Free text only — joined and substring-matched, so group_concat's
27563
27605
  // commas need no unpicking (a repo/path containing one still matches).
27564
- // Left undefined (not '') when unfetched, so buildFindingGroups can
27606
+ // Left undefined (not '') when unfetched, so buildFindingTypes can
27565
27607
  // tell "no q this request" from "a group with no repo/file at all"
27566
27608
  // and skip priming a haystack nothing will read.
27567
27609
  ...withSearchText ? {
@@ -27713,6 +27755,12 @@ var SqliteHistorySyncRepository = class {
27713
27755
  this.markOwedStmt = db.prepare(
27714
27756
  `UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
27715
27757
  );
27758
+ this.markCaptureBacklogOwedStmt = db.prepare(
27759
+ `UPDATE audit_events SET outbox_owed = 1
27760
+ WHERE synced_at IS NULL
27761
+ AND event_type IN (${CAPTURE_TYPE_LIST})
27762
+ AND started_at < :before`
27763
+ );
27716
27764
  this.stampStmt = db.prepare(
27717
27765
  `UPDATE audit_events SET synced_at = :at, sync_claimed_at = NULL WHERE id = :id`
27718
27766
  );
@@ -27761,7 +27809,9 @@ var SqliteHistorySyncRepository = class {
27761
27809
  );
27762
27810
  this.disownCapturesStmt = db.prepare(
27763
27811
  `UPDATE audit_events SET outbox_owed = NULL
27764
- WHERE outbox_owed IS NOT NULL AND event_type IN (${CAPTURE_TYPE_LIST})`
27812
+ WHERE outbox_owed IS NOT NULL
27813
+ AND event_type IN (${CAPTURE_TYPE_LIST})
27814
+ AND started_at < :attachedAt`
27765
27815
  );
27766
27816
  this.rearmStmt = db.prepare(
27767
27817
  `UPDATE audit_events SET synced_at = NULL
@@ -27837,6 +27887,7 @@ var SqliteHistorySyncRepository = class {
27837
27887
  freezeBoundaryStmt;
27838
27888
  captureRowsStmt;
27839
27889
  markOwedStmt;
27890
+ markCaptureBacklogOwedStmt;
27840
27891
  captureSkipCountStmt;
27841
27892
  disownCapturesStmt;
27842
27893
  partitionStmt;
@@ -27900,6 +27951,23 @@ var SqliteHistorySyncRepository = class {
27900
27951
  markCaptureOwed(id) {
27901
27952
  this.markOwedStmt.run({ id });
27902
27953
  }
27954
+ /**
27955
+ * Mark every capture already on disk as owed, as of `before`.
27956
+ *
27957
+ * The consent-time backfill, called once from `aka attach` when a human
27958
+ * grants existing-history consent — never from an ongoing drain pass, and
27959
+ * never inferred from a boundary that could later move. `before` is the
27960
+ * caller's own "now" at the moment consent was granted, so what this marks
27961
+ * is exactly the backlog the consent prompt already counted, not whatever a
27962
+ * later re-attach or key rotation might widen it to.
27963
+ *
27964
+ * Returns how many rows matched, for the caller to log or test against. Not a
27965
+ * count of NEWLY marked rows — a row still unsynced from an earlier call
27966
+ * matches again and is counted again, the same as `UPDATE`'s own `changes`.
27967
+ */
27968
+ markCaptureBacklogOwed(before) {
27969
+ return Number(this.markCaptureBacklogOwedStmt.run({ before }).changes);
27970
+ }
27903
27971
  /** Record delivery. Called only AFTER the far side has accepted the rows. */
27904
27972
  markSynced(ids, atMs) {
27905
27973
  this.stampAll(ids, atMs);
@@ -28016,15 +28084,42 @@ var SqliteHistorySyncRepository = class {
28016
28084
  *
28017
28085
  * Delivery is a fact about ONE recipient: rows sent to the deployment a
28018
28086
  * machine has just left are undelivered as far as the new one is concerned.
28019
- * All three in one transaction, so a crash between them cannot leave stamps
28020
- * attributed to the wrong deployment, or a boundary that belongs to another.
28087
+ * All four in one transaction, so a crash between them cannot leave stamps
28088
+ * attributed to the wrong deployment, a boundary that belongs to another, or
28089
+ * a disown with no re-mark to follow it.
28021
28090
  *
28022
28091
  * The boundary is written HERE and only here, which is what freezes it: a
28023
28092
  * re-attach to the SAME deployment (a key rotation) leaves the fingerprint
28024
28093
  * unchanged, so this never runs and the backlog does not widen back over rows
28025
28094
  * the live path has since delivered.
28095
+ *
28096
+ * `backfillCapturesBefore` is the caller's OWN "now" at the instant a human
28097
+ * granted existing-history consent for the deployment this call is arming —
28098
+ * a DIFFERENT instant from `backlogBefore`: the re-mark boundary is the GRANT
28099
+ * instant, `backlogBefore` is the ATTACH instant, and the two can be far
28100
+ * apart. Passed only when that grant is valid, since this method has no way
28101
+ * to check consent itself and must not mark a row owed for a machine that
28102
+ * never agreed to it. Applied AFTER the disown above, in the SAME
28103
+ * transaction: what the disown clears is every marker below `backlogBefore`,
28104
+ * which includes this deployment's OWN pre-attach rows — `aka attach` calls
28105
+ * `seedCaptureBacklogOwed` at the attach instant, so every row it marks sits
28106
+ * on the cleared side of that bound — and the re-mark in the same
28107
+ * transaction is what puts those rows back. A crash between the two cannot
28108
+ * strand the ledger disowned with nothing re-marked — the transaction either
28109
+ * lands whole or not at all, and a fingerprint mismatch that has not yet
28110
+ * committed re-enters this method on the very next pass. Omit it (the
28111
+ * structural-only tests do) to exercise the disown in isolation.
28112
+ *
28113
+ * The disown is bounded by `backlogBefore`, which is what keeps it from
28114
+ * touching a marker the NEW deployment's OWN live path has already set: B's
28115
+ * live path can mark a capture owed from the moment `aka attach` writes the
28116
+ * descriptor, before the drain's first pass ever reaches this method, and
28117
+ * such a row sits at or after the bound rather than below it. What keeps the
28118
+ * disown from eating THIS SAME CALL's own re-mark is the order, not the
28119
+ * bound — disown runs first, re-mark second, both inside the one
28120
+ * transaction above.
28026
28121
  */
28027
- rearmFor(fingerprint, backlogBefore) {
28122
+ rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
28028
28123
  this.ensureRowStmt.run();
28029
28124
  withTransaction(
28030
28125
  this.db,
@@ -28032,7 +28127,10 @@ var SqliteHistorySyncRepository = class {
28032
28127
  const previous = getRow(this.fingerprintStmt)?.fingerprint;
28033
28128
  this.rearmStmt.run();
28034
28129
  if (previous !== null && previous !== void 0 && previous !== fingerprint) {
28035
- this.disownCapturesStmt.run();
28130
+ this.disownCapturesStmt.run({ attachedAt: backlogBefore });
28131
+ }
28132
+ if (backfillCapturesBefore !== void 0) {
28133
+ this.markCaptureBacklogOwedStmt.run({ before: backfillCapturesBefore });
28036
28134
  }
28037
28135
  this.setFingerprintStmt.run({ fingerprint, backlogBefore });
28038
28136
  },
@@ -28312,7 +28410,8 @@ function managedSettingsPaths(platform2 = process.platform) {
28312
28410
  }
28313
28411
  return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
28314
28412
  }
28315
- function readManagedSettings(paths = managedSettingsPaths()) {
28413
+ var testOnlyManagedPaths = null;
28414
+ function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPaths()) {
28316
28415
  for (const path of paths) {
28317
28416
  let text;
28318
28417
  try {
@@ -30792,7 +30891,7 @@ function toUtcDateString(ms) {
30792
30891
  return new Date(ms).toISOString().slice(0, 10);
30793
30892
  }
30794
30893
  function isTimeseriesSeverity(s) {
30795
- return s === "critical" || s === "high" || s === "medium";
30894
+ return s === "critical" || s === "high" || s === "medium" || s === "low";
30796
30895
  }
30797
30896
  var SqliteSecurityRepository = class {
30798
30897
  constructor(db, now = () => Date.now()) {
@@ -30921,12 +31020,16 @@ var SqliteSecurityRepository = class {
30921
31020
  const now = this.now();
30922
31021
  const windowStart = startOfUtcDay2(now) - (lenDays - 1) * DAY_MS4;
30923
31022
  const rows = this.findingsInRange(windowStart, now);
30924
- const points = Array.from({ length: numBuckets }, (_, i) => ({
30925
- timestamp: toUtcDateString(windowStart + i * bucketMs),
30926
- critical: 0,
30927
- high: 0,
30928
- medium: 0
30929
- }));
31023
+ const points = Array.from(
31024
+ { length: numBuckets },
31025
+ (_, i) => ({
31026
+ timestamp: toUtcDateString(windowStart + i * bucketMs),
31027
+ critical: 0,
31028
+ high: 0,
31029
+ medium: 0,
31030
+ low: 0
31031
+ })
31032
+ );
30930
31033
  for (const r of rows) {
30931
31034
  const idx = Math.floor((r.occurredAt - windowStart) / bucketMs);
30932
31035
  const bucket = points[idx];
@@ -31144,6 +31247,7 @@ var SqliteSecurityRepository = class {
31144
31247
  `SELECT f.finding_key AS finding_key,
31145
31248
  d.rule_id AS rule_id,
31146
31249
  d.severity AS severity,
31250
+ e.repo AS repo,
31147
31251
  e.file_path AS path,
31148
31252
  COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
31149
31253
  latest.resolved_at AS latest_resolved_at
@@ -31163,6 +31267,7 @@ var SqliteSecurityRepository = class {
31163
31267
  const items = rows.map((r) => ({
31164
31268
  findingKey: r.finding_key,
31165
31269
  ruleId: r.rule_id,
31270
+ repo: r.repo ?? "",
31166
31271
  severity: r.severity,
31167
31272
  path: r.path ?? "",
31168
31273
  resolvedAt: new Date(r.latest_resolved_at).toISOString(),
@@ -31172,13 +31277,66 @@ var SqliteSecurityRepository = class {
31172
31277
  }));
31173
31278
  return Promise.resolve({ items });
31174
31279
  }
31280
+ /**
31281
+ * Per-rule tallies of the findings that are still OPEN, whole-store.
31282
+ *
31283
+ * Scoped by status rather than by time, because the card this feeds is a to-do
31284
+ * list: a secret committed three weeks ago and never rotated is still the most
31285
+ * important thing to fix, and any window hides it. It carried a "newest N
31286
+ * findings" cap and then a range; the first meant a different span on every
31287
+ * machine, and the second reported "no recommendations" over live exposure.
31288
+ *
31289
+ * `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
31290
+ * so a row's count is exactly what `?status=open&type=<rule>` returns. Note that
31291
+ * is NOT `severitySummary`'s `openAtRest`, which keeps dismissed findings (a
31292
+ * dismissal is a judgement, not a remediation) and drops untracked legacy rows.
31293
+ * The two answer different questions and only this one has to match a link.
31294
+ *
31295
+ * Aggregated in SQL: the result is O(distinct rule × category × severity), so a
31296
+ * whole-store scope costs a grouped scan rather than a row per finding.
31297
+ */
31298
+ recommendationInputs() {
31299
+ const rows = allRows(
31300
+ this.db.prepare(
31301
+ `SELECT d.rule_id AS rule_id,
31302
+ d.category AS category,
31303
+ d.severity AS severity,
31304
+ COUNT(*) AS count
31305
+ FROM inspection_findings f
31306
+ JOIN audit_events e ON e.id = f.audit_event_id
31307
+ JOIN inspection_definitions d ON d.id = f.inspection_definition_id
31308
+ LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
31309
+ ON latest.finding_key = f.finding_key
31310
+ WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
31311
+ AND e.event_type = 'code_change'
31312
+ AND (
31313
+ f.finding_key IS NULL
31314
+ OR latest.status IS NULL
31315
+ OR latest.status NOT IN ('resolved', 'dismissed')
31316
+ )
31317
+ GROUP BY d.rule_id, d.category, d.severity`
31318
+ )
31319
+ );
31320
+ return Promise.resolve(
31321
+ rows.map((r) => ({
31322
+ ruleId: r.rule_id,
31323
+ category: r.category,
31324
+ severity: r.severity,
31325
+ count: r.count
31326
+ }))
31327
+ );
31328
+ }
31175
31329
  // Findings whose parent event occurred in [fromMs, toMs), with the parent's
31176
31330
  // epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
31177
31331
  // numeric and the JS aggregations bucket/split on ms directly.
31178
31332
  findingsInRange(fromMs, toMs) {
31179
31333
  const rows = allRows(
31180
31334
  this.db.prepare(
31181
- `SELECT e.started_at AS occurred_at, d.severity AS severity, f.action_taken AS action_taken
31335
+ // `rule_id`/`category` cost nothing extra: inspection_definitions is already
31336
+ // joined for `severity`, so they are two more columns off a row this read
31337
+ // already fetches. They feed the recommended-actions rollup.
31338
+ `SELECT e.started_at AS occurred_at, d.severity AS severity, f.action_taken AS action_taken,
31339
+ d.rule_id AS rule_id, d.category AS category
31182
31340
  FROM inspection_findings f
31183
31341
  JOIN audit_events e ON e.id = f.audit_event_id
31184
31342
  JOIN inspection_definitions d ON d.id = f.inspection_definition_id
@@ -31191,7 +31349,9 @@ var SqliteSecurityRepository = class {
31191
31349
  return rows.map((r) => ({
31192
31350
  occurredAt: r.occurred_at,
31193
31351
  severity: r.severity,
31194
- actionTaken: r.action_taken
31352
+ actionTaken: r.action_taken,
31353
+ ruleId: r.rule_id,
31354
+ category: r.category
31195
31355
  }));
31196
31356
  }
31197
31357
  };
@@ -32361,6 +32521,43 @@ function openLocalDatabase(dir) {
32361
32521
  };
32362
32522
  }
32363
32523
 
32524
+ // ../../packages/persistence/src/egress-wire.ts
32525
+ import { createHash as createHash3 } from "crypto";
32526
+ function hashProjectKey(projectKey) {
32527
+ return createHash3("sha256").update(projectKey, "utf8").digest("hex");
32528
+ }
32529
+ function toIngestHit(hit) {
32530
+ return {
32531
+ host: hit.host,
32532
+ kind: hit.kind,
32533
+ name: hit.name,
32534
+ category: hit.category,
32535
+ trust: hit.trust,
32536
+ network: hit.network,
32537
+ method: hit.method,
32538
+ transport: hit.transport,
32539
+ url: hit.url,
32540
+ template: hit.template,
32541
+ dataClass: hit.dataClass,
32542
+ site: {
32543
+ file: hit.site.file,
32544
+ line: hit.site.line,
32545
+ dynamic: hit.site.dynamic,
32546
+ vendored: hit.site.vendored
32547
+ }
32548
+ };
32549
+ }
32550
+ function toEgressIngestRequest(input2) {
32551
+ const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
32552
+ const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
32553
+ return {
32554
+ projectKey: hashProjectKey(input2.projectKey),
32555
+ project: input2.project,
32556
+ reconcile,
32557
+ hits: hits.map(toIngestHit)
32558
+ };
32559
+ }
32560
+
32364
32561
  // ../../packages/persistence/src/exception-policy.ts
32365
32562
  var UserGrantPolicyProvider = class {
32366
32563
  #exceptions;
@@ -32382,13 +32579,13 @@ var UserGrantPolicyProvider = class {
32382
32579
  };
32383
32580
 
32384
32581
  // ../../packages/persistence/src/finding-key.ts
32385
- import { createHash as createHash3 } from "crypto";
32582
+ import { createHash as createHash4 } from "crypto";
32386
32583
  function normalizeFilePath(filePath) {
32387
32584
  return filePath.replaceAll("\\", "/");
32388
32585
  }
32389
32586
  function computeFindingKey(input2) {
32390
32587
  const normalizedPath = normalizeFilePath(input2.filePath);
32391
- return createHash3("sha256").update(`${input2.ruleId}\0${normalizedPath}\0${input2.valueFingerprint}`).digest("hex");
32588
+ return createHash4("sha256").update(`${input2.ruleId}\0${normalizedPath}\0${input2.valueFingerprint}`).digest("hex");
32392
32589
  }
32393
32590
 
32394
32591
  // ../../packages/persistence/src/fingerprint.ts
@@ -32514,14 +32711,18 @@ function fingerprintValue(key, raw) {
32514
32711
  return createHmac("sha256", key.material).update(raw, "utf8").digest("hex");
32515
32712
  }
32516
32713
 
32517
- // ../../packages/persistence/src/history-preview.ts
32714
+ // ../../packages/persistence/src/history-backfill.ts
32518
32715
  import { existsSync as existsSync4 } from "fs";
32519
32716
  import { join as join9 } from "path";
32717
+
32718
+ // ../../packages/persistence/src/history-preview.ts
32719
+ import { existsSync as existsSync5 } from "fs";
32720
+ import { join as join10 } from "path";
32520
32721
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
32521
32722
 
32522
32723
  // ../../packages/persistence/src/store-symlinks.ts
32523
- import { existsSync as existsSync5, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
32524
- import { dirname as dirname3, join as join10, resolve } from "path";
32724
+ import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
32725
+ import { dirname as dirname3, join as join11, resolve } from "path";
32525
32726
  var STORE_DB = "the store database (including the prompt corpus)";
32526
32727
  var STORE_SETTINGS = "your settings file";
32527
32728
  function storeContents(home) {
@@ -32530,7 +32731,7 @@ function storeContents(home) {
32530
32731
  [settingsDir(home), STORE_SETTINGS],
32531
32732
  [dataDir(home), STORE_DB],
32532
32733
  [keysDir(home), "the vault key"],
32533
- [join10(settingsDir(home), "settings.json"), STORE_SETTINGS],
32734
+ [join11(settingsDir(home), "settings.json"), STORE_SETTINGS],
32534
32735
  [dbPath(home), STORE_DB]
32535
32736
  ]);
32536
32737
  }
@@ -32545,7 +32746,7 @@ function symlinkedStorePaths(home, platform2 = process.platform) {
32545
32746
  holds,
32546
32747
  // existsSync follows the link, so a target that is gone reads as
32547
32748
  // absent here while lstat above still sees the link itself.
32548
- missing: !existsSync5(path),
32749
+ missing: !existsSync6(path),
32549
32750
  mode: targetMode(path, platform2)
32550
32751
  }
32551
32752
  ];
@@ -32682,7 +32883,7 @@ function formatPointer(category, keyVersion, pointerId, tag) {
32682
32883
  import { execFileSync } from "child_process";
32683
32884
  import { randomBytes as randomBytes2 } from "crypto";
32684
32885
  import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
32685
- import { join as join11 } from "path";
32886
+ import { join as join12 } from "path";
32686
32887
  var VAULT_OCCUPANT_REASON = {
32687
32888
  symlink: "the path is a symlink; remove it so a keyring can be created",
32688
32889
  gone: "the path was occupied but holds no keyring (removed while it was being created)",
@@ -32781,7 +32982,7 @@ function claimRotationLock(lock, owner) {
32781
32982
  throw asError(err);
32782
32983
  }
32783
32984
  try {
32784
- writeFileSync3(join11(lock, LOCK_OWNER_FILE), `${owner}
32985
+ writeFileSync3(join12(lock, LOCK_OWNER_FILE), `${owner}
32785
32986
  `, { mode: DATA_FILE_MODE });
32786
32987
  return true;
32787
32988
  } catch (err) {
@@ -32790,7 +32991,7 @@ function claimRotationLock(lock, owner) {
32790
32991
  }
32791
32992
  }
32792
32993
  function acquireRotationLock(keysDir2) {
32793
- const lock = join11(keysDir2, `${VAULT_KEY_FILENAME}.lock`);
32994
+ const lock = join12(keysDir2, `${VAULT_KEY_FILENAME}.lock`);
32794
32995
  const owner = randomBytes2(16).toString("hex");
32795
32996
  if (claimRotationLock(lock, owner)) return { lock, owner };
32796
32997
  let held;
@@ -32817,7 +33018,7 @@ function acquireRotationLock(keysDir2) {
32817
33018
  }
32818
33019
  function releaseRotationLock(lease) {
32819
33020
  try {
32820
- if (readFileSync7(join11(lease.lock, LOCK_OWNER_FILE), "utf8").trim() !== lease.owner) return;
33021
+ if (readFileSync7(join12(lease.lock, LOCK_OWNER_FILE), "utf8").trim() !== lease.owner) return;
32821
33022
  } catch {
32822
33023
  return;
32823
33024
  }
@@ -32838,7 +33039,7 @@ var FileKeyProvider = class {
32838
33039
  this.#keysDir = keysDir2;
32839
33040
  }
32840
33041
  get filePath() {
32841
- return join11(this.#keysDir, VAULT_KEY_FILENAME);
33042
+ return join12(this.#keysDir, VAULT_KEY_FILENAME);
32842
33043
  }
32843
33044
  loadOrCreate() {
32844
33045
  return asAsync(() => {
@@ -33503,55 +33704,19 @@ var SecretVault = class {
33503
33704
  };
33504
33705
 
33505
33706
  // ../../packages/persistence/src/warn-era-cap.ts
33506
- import { existsSync as existsSync6, writeFileSync as writeFileSync4 } from "fs";
33507
- import { join as join12 } from "path";
33707
+ import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
33708
+ import { join as join13 } from "path";
33508
33709
  var MARKER = "warn-era-capped";
33509
33710
  function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
33510
33711
  if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
33511
- const marker = join12(dataDir2, MARKER);
33512
- if (existsSync6(marker)) return { capped: 0, skipped: "already-run" };
33712
+ const marker = join13(dataDir2, MARKER);
33713
+ if (existsSync7(marker)) return { capped: 0, skipped: "already-run" };
33513
33714
  const capped = db.policies.capCategoryActions();
33514
33715
  writeFileSync4(marker, `${new Date(Date.now()).toISOString()}
33515
33716
  `, { mode: DATA_FILE_MODE });
33516
33717
  return { capped };
33517
33718
  }
33518
33719
 
33519
- // ../../packages/plugin-runtime/src/attached/egress-wire.ts
33520
- function hashProjectKey(projectKey) {
33521
- return createHash4("sha256").update(projectKey, "utf8").digest("hex");
33522
- }
33523
- function toIngestHit(hit) {
33524
- return {
33525
- host: hit.host,
33526
- kind: hit.kind,
33527
- name: hit.name,
33528
- category: hit.category,
33529
- trust: hit.trust,
33530
- network: hit.network,
33531
- method: hit.method,
33532
- transport: hit.transport,
33533
- url: hit.url,
33534
- template: hit.template,
33535
- dataClass: hit.dataClass,
33536
- site: {
33537
- file: hit.site.file,
33538
- line: hit.site.line,
33539
- dynamic: hit.site.dynamic,
33540
- vendored: hit.site.vendored
33541
- }
33542
- };
33543
- }
33544
- function toEgressIngestRequest(input2) {
33545
- const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
33546
- const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
33547
- return {
33548
- projectKey: hashProjectKey(input2.projectKey),
33549
- project: input2.project,
33550
- reconcile,
33551
- hits: hits.map(toIngestHit)
33552
- };
33553
- }
33554
-
33555
33720
  // ../../packages/remote/src/http.ts
33556
33721
  import { request as httpRequest } from "http";
33557
33722
  import { request as httpsRequest } from "https";
@@ -33831,6 +33996,7 @@ function createRemoteClient(options) {
33831
33996
  url: url2(ROUTES.shares),
33832
33997
  body: JSON.stringify(validated.data)
33833
33998
  });
33999
+ if (response.status === 404) throw new RemoteRouteAbsent(ROUTES.shares);
33834
34000
  okBody(response);
33835
34001
  },
33836
34002
  async pollCommand() {
@@ -33853,19 +34019,51 @@ function createRemoteClient(options) {
33853
34019
  };
33854
34020
  }
33855
34021
 
33856
- // ../../packages/plugin-runtime/src/attached/failure.ts
34022
+ // ../../packages/remote/src/failure-kind.ts
33857
34023
  function statusOf(err) {
33858
34024
  if (typeof err !== "object" || err === null || !("status" in err)) return null;
33859
34025
  const { status } = err;
33860
34026
  if (typeof status !== "number" || !Number.isInteger(status)) return null;
33861
34027
  return status >= 100 && status <= 599 ? status : null;
33862
34028
  }
33863
- function classifyFailure(err) {
33864
- switch (statusOf(err)) {
34029
+ function nameOf(err) {
34030
+ if (typeof err !== "object" || err === null || !("name" in err)) return null;
34031
+ return typeof err.name === "string" ? err.name : null;
34032
+ }
34033
+ function classifyRemoteFailure(err) {
34034
+ switch (nameOf(err)) {
34035
+ case "RemoteRouteAbsent":
34036
+ return "route-absent";
34037
+ case "RemoteRequestInvalid":
34038
+ return "invalid-request";
34039
+ case "RemoteResponseInvalid":
34040
+ return "rejected";
34041
+ default:
34042
+ break;
34043
+ }
34044
+ const status = statusOf(err);
34045
+ if (status === null) return "unreachable";
34046
+ switch (status) {
33865
34047
  case 401:
33866
34048
  return "unauthorized";
33867
34049
  case 403:
33868
34050
  return "forbidden";
34051
+ case 429:
34052
+ return "unreachable";
34053
+ case 404:
34054
+ return "unreachable";
34055
+ default:
34056
+ return status >= 400 && status <= 499 ? "rejected" : "unreachable";
34057
+ }
34058
+ }
34059
+
34060
+ // ../../packages/plugin-runtime/src/attached/failure.ts
34061
+ function classifyFailure(err) {
34062
+ switch (classifyRemoteFailure(err)) {
34063
+ case "unauthorized":
34064
+ return "unauthorized";
34065
+ case "forbidden":
34066
+ return "forbidden";
33869
34067
  default:
33870
34068
  return "unreachable";
33871
34069
  }
@@ -33888,10 +34086,10 @@ function withTimeout(promise2, ms) {
33888
34086
 
33889
34087
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
33890
34088
  import { readFileSync as readFileSync8 } from "fs";
33891
- import { join as join13 } from "path";
34089
+ import { join as join14 } from "path";
33892
34090
  var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
33893
34091
  function forwardDropsPath(dataDir2) {
33894
- return join13(dataDir2, FORWARD_DROPS_FILENAME);
34092
+ return join14(dataDir2, FORWARD_DROPS_FILENAME);
33895
34093
  }
33896
34094
  function recordForwardDrops(dataDir2, count, nowMs) {
33897
34095
  if (count <= 0) return;
@@ -33927,13 +34125,13 @@ function readForwardDrops(dataDir2) {
33927
34125
 
33928
34126
  // ../../packages/plugin-runtime/src/attached/forward-policy.ts
33929
34127
  import { randomUUID as randomUUID15 } from "crypto";
33930
- import { readFileSync as readFileSync14 } from "fs";
34128
+ import { readFileSync as readFileSync15 } from "fs";
33931
34129
  import { readFile, rename, writeFile } from "fs/promises";
33932
- import { join as join22 } from "path";
34130
+ import { join as join24 } from "path";
33933
34131
 
33934
34132
  // ../../packages/plugin-sdk/src/config.ts
33935
- import { existsSync as existsSync7 } from "fs";
33936
- import { join as join14 } from "path";
34133
+ import { existsSync as existsSync8 } from "fs";
34134
+ import { join as join15 } from "path";
33937
34135
 
33938
34136
  // ../../packages/plugin-sdk/src/provider-env.ts
33939
34137
  var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
@@ -33987,8 +34185,8 @@ function resolveProvider() {
33987
34185
  function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
33988
34186
  try {
33989
34187
  ensureLayoutDirSync(base);
33990
- const settingsFile = join14(settingsDir(base), "settings.json");
33991
- if (existsSync7(settingsFile)) tightenFile(settingsFile);
34188
+ const settingsFile = join15(settingsDir(base), "settings.json");
34189
+ if (existsSync8(settingsFile)) tightenFile(settingsFile);
33992
34190
  } catch {
33993
34191
  }
33994
34192
  migrateLegacyLayout(base);
@@ -34013,7 +34211,7 @@ function resolveProviderSafe(resolveProviderFn) {
34013
34211
  // ../../packages/plugin-sdk/src/config-inventory.ts
34014
34212
  import { readdirSync as readdirSync2, readFileSync as readFileSync10, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
34015
34213
  import { homedir as homedir2 } from "os";
34016
- import { basename as basename3, join as join16 } from "path";
34214
+ import { basename as basename3, join as join17 } from "path";
34017
34215
 
34018
34216
  // ../../packages/detections/src/egress/registry.ts
34019
34217
  var EXTRACTOR_VERSION = "1";
@@ -37105,8 +37303,8 @@ function uniqueRuleIds(findings) {
37105
37303
  }
37106
37304
 
37107
37305
  // ../../packages/plugin-sdk/src/repo.ts
37108
- import { existsSync as existsSync8, readFileSync as readFileSync9, statSync as statSync6 } from "fs";
37109
- import { basename as basename2, dirname as dirname4, isAbsolute, join as join15, sep as sep2 } from "path";
37306
+ import { existsSync as existsSync9, readFileSync as readFileSync9, statSync as statSync6 } from "fs";
37307
+ import { basename as basename2, dirname as dirname4, isAbsolute, join as join16, sep as sep2 } from "path";
37110
37308
  function resolveRepo(cwd) {
37111
37309
  try {
37112
37310
  const root = findGitRoot(cwd);
@@ -37121,32 +37319,32 @@ function resolveRepo(cwd) {
37121
37319
  function findGitRoot(start) {
37122
37320
  let dir = start;
37123
37321
  for (; ; ) {
37124
- if (existsSync8(join15(dir, ".git"))) return dir;
37322
+ if (existsSync9(join16(dir, ".git"))) return dir;
37125
37323
  const parent = dirname4(dir);
37126
37324
  if (parent === dir) return void 0;
37127
37325
  dir = parent;
37128
37326
  }
37129
37327
  }
37130
37328
  function resolveGitContext(root) {
37131
- const dotGit = join15(root, ".git");
37329
+ const dotGit = join16(root, ".git");
37132
37330
  try {
37133
37331
  if (statSync6(dotGit).isDirectory()) {
37134
- return { configPath: join15(dotGit, "config"), headRoot: root };
37332
+ return { configPath: join16(dotGit, "config"), headRoot: root };
37135
37333
  }
37136
37334
  } catch {
37137
37335
  return void 0;
37138
37336
  }
37139
37337
  const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
37140
37338
  if (!target) return void 0;
37141
- const gitdir = isAbsolute(target) ? target : join15(root, target);
37142
- if (existsSync8(join15(gitdir, "config"))) {
37143
- return { configPath: join15(gitdir, "config"), headRoot: root };
37339
+ const gitdir = isAbsolute(target) ? target : join16(root, target);
37340
+ if (existsSync9(join16(gitdir, "config"))) {
37341
+ return { configPath: join16(gitdir, "config"), headRoot: root };
37144
37342
  }
37145
- const commonRaw = safeRead(join15(gitdir, "commondir"))?.trim();
37343
+ const commonRaw = safeRead(join16(gitdir, "commondir"))?.trim();
37146
37344
  if (!commonRaw) return void 0;
37147
- const commonGitDir = isAbsolute(commonRaw) ? commonRaw : join15(gitdir, commonRaw);
37345
+ const commonGitDir = isAbsolute(commonRaw) ? commonRaw : join16(gitdir, commonRaw);
37148
37346
  const headRoot = basename2(commonGitDir) === ".git" ? dirname4(commonGitDir) : root;
37149
- return { configPath: join15(commonGitDir, "config"), headRoot };
37347
+ return { configPath: join16(commonGitDir, "config"), headRoot };
37150
37348
  }
37151
37349
  function safeRead(path) {
37152
37350
  try {
@@ -37216,7 +37414,7 @@ function buildIngestEvent(input2) {
37216
37414
  }
37217
37415
 
37218
37416
  // ../../packages/plugin-sdk/src/isolated-scan.ts
37219
- import { existsSync as existsSync9 } from "fs";
37417
+ import { existsSync as existsSync10 } from "fs";
37220
37418
  import { fileURLToPath } from "url";
37221
37419
  import { Worker } from "worker_threads";
37222
37420
  var ISOLATED_SCAN_BUDGET_MS = 2e3;
@@ -37230,7 +37428,7 @@ function resolveWorkerUrl() {
37230
37428
  for (const name of ["scan-worker.js", "scan-worker.ts"]) {
37231
37429
  const candidate = new URL(name, import.meta.url);
37232
37430
  try {
37233
- if (existsSync9(fileURLToPath(candidate))) {
37431
+ if (existsSync10(fileURLToPath(candidate))) {
37234
37432
  resolvedWorkerUrl = candidate;
37235
37433
  return candidate;
37236
37434
  }
@@ -37693,13 +37891,9 @@ function createGuardedScanner(partition, gateway, opts) {
37693
37891
  };
37694
37892
  }
37695
37893
 
37696
- // ../../packages/plugin-sdk/src/ignore-layers.ts
37697
- var import_ignore = __toESM(require_ignore(), 1);
37698
- import { readFileSync as readFileSync11 } from "fs";
37699
- import { join as join17 } from "path";
37700
-
37701
- // ../../packages/plugin-sdk/src/inventory-resolver.ts
37702
- import { arch, hostname as hostname4, platform, release } from "os";
37894
+ // ../../packages/plugin-sdk/src/host-floor.ts
37895
+ import { readFileSync as readFileSync12 } from "fs";
37896
+ import { join as join19 } from "path";
37703
37897
 
37704
37898
  // ../../packages/plugin-sdk/src/model-governance.ts
37705
37899
  import {
@@ -37707,16 +37901,138 @@ import {
37707
37901
  fstatSync,
37708
37902
  mkdirSync as mkdirSync2,
37709
37903
  openSync as openSync2,
37710
- readFileSync as readFileSync12,
37904
+ readFileSync as readFileSync11,
37711
37905
  readSync,
37712
37906
  writeFileSync as writeFileSync5
37713
37907
  } from "fs";
37714
37908
  import { join as join18 } from "path";
37715
37909
  var TAIL_BYTES = 256 * 1024;
37910
+ function readTail(path) {
37911
+ const fd = openSync2(path, "r");
37912
+ try {
37913
+ const { size } = fstatSync(fd);
37914
+ if (size <= TAIL_BYTES) return { text: readFileSync11(fd, "utf8"), truncated: false };
37915
+ const buffer = Buffer.allocUnsafe(TAIL_BYTES);
37916
+ let filled = 0;
37917
+ while (filled < TAIL_BYTES) {
37918
+ const n = readSync(fd, buffer, filled, TAIL_BYTES - filled, size - TAIL_BYTES + filled);
37919
+ if (n === 0) break;
37920
+ filled += n;
37921
+ }
37922
+ return { text: buffer.subarray(0, filled).toString("utf8"), truncated: true };
37923
+ } finally {
37924
+ closeSync2(fd);
37925
+ }
37926
+ }
37927
+ function modelFromTranscriptTail(transcriptPath, fromRecord) {
37928
+ if (transcriptPath === void 0 || transcriptPath === "") return void 0;
37929
+ try {
37930
+ const { text: slice, truncated } = readTail(transcriptPath);
37931
+ const lines = slice.split("\n");
37932
+ if (truncated) lines.shift();
37933
+ for (let i = lines.length - 1; i >= 0; i--) {
37934
+ const line = lines[i];
37935
+ if (line === void 0 || line === "") continue;
37936
+ let parsed2;
37937
+ try {
37938
+ parsed2 = JSON.parse(line);
37939
+ } catch {
37940
+ continue;
37941
+ }
37942
+ const model = fromRecord(parsed2);
37943
+ if (model !== void 0 && model !== "") return model;
37944
+ }
37945
+ return void 0;
37946
+ } catch {
37947
+ return void 0;
37948
+ }
37949
+ }
37950
+
37951
+ // ../../packages/plugin-sdk/src/host-floor.ts
37952
+ var HOST_FEATURE = {
37953
+ ModelSwitch: "model-switch",
37954
+ VaultPointerDisplay: "vault-pointer-display"
37955
+ };
37956
+ var HOST_FLOORS = {
37957
+ [HOST_FEATURE.ModelSwitch]: {
37958
+ label: "model-switch protection",
37959
+ hookEvents: ["PreModelSwitch", "PostModelSwitch"],
37960
+ since: "2.1.251"
37961
+ },
37962
+ [HOST_FEATURE.VaultPointerDisplay]: {
37963
+ label: "vault pointer display",
37964
+ hookEvents: ["MessageDisplay"],
37965
+ since: "2.1.152"
37966
+ }
37967
+ };
37968
+ var hostVersionFromRecord = (record2) => {
37969
+ if (typeof record2 !== "object" || record2 === null) return void 0;
37970
+ const { version: version2 } = record2;
37971
+ return typeof version2 === "string" && version2 !== "" ? version2 : void 0;
37972
+ };
37973
+ function hostVersionFromTranscript(transcriptPath) {
37974
+ return modelFromTranscriptTail(transcriptPath, hostVersionFromRecord);
37975
+ }
37976
+ function hostFloorGaps(hostVersion) {
37977
+ if (hostVersion === void 0) return [];
37978
+ const gaps = [];
37979
+ for (const [feature, row] of Object.entries(HOST_FLOORS)) {
37980
+ if (compareBinaryVersions(hostVersion, row.since) < 0) {
37981
+ gaps.push({ feature, label: row.label, since: row.since });
37982
+ }
37983
+ }
37984
+ return gaps;
37985
+ }
37986
+ function requiredHostVersion(gaps) {
37987
+ let highest;
37988
+ for (const gap of gaps) {
37989
+ if (highest === void 0 || compareBinaryVersions(gap.since, highest) > 0) highest = gap.since;
37990
+ }
37991
+ return highest;
37992
+ }
37993
+ function hostFloorNotice(hostVersion) {
37994
+ if (hostVersion === void 0) return null;
37995
+ const gaps = hostFloorGaps(hostVersion);
37996
+ const required2 = requiredHostVersion(gaps);
37997
+ if (required2 === void 0) return null;
37998
+ return `This Claude Code (${hostVersion}) is older than AKA needs \u2014 some of AKA's protections are inactive in this session. Update Claude Code to ${required2} or newer to turn them on. Everything else AKA does is working normally. Run \`aka status\` for detail.`;
37999
+ }
38000
+ var HOST_VERSION_MARKER = "host-version.json";
38001
+ function recordHostVersion(dataDir2, version2) {
38002
+ if (version2 === void 0 || !isParseableBinaryVersion(version2)) return;
38003
+ try {
38004
+ const current = readHostVersionCache(dataDir2);
38005
+ if (current !== null && compareBinaryVersions(version2, current.version) <= 0) return;
38006
+ const cache = { version: version2, observedAt: Date.now() };
38007
+ ensureDataDirSync(dataDir2);
38008
+ writeOwnerOnlyFileSync(join19(dataDir2, HOST_VERSION_MARKER), JSON.stringify(cache));
38009
+ } catch {
38010
+ }
38011
+ }
38012
+ function readHostVersionCache(dataDir2) {
38013
+ try {
38014
+ const parsed2 = JSON.parse(readFileSync12(join19(dataDir2, HOST_VERSION_MARKER), "utf8"));
38015
+ if (typeof parsed2 !== "object" || parsed2 === null) return null;
38016
+ const { version: version2, observedAt } = parsed2;
38017
+ if (typeof version2 !== "string" || !isParseableBinaryVersion(version2)) return null;
38018
+ if (typeof observedAt !== "number" || !Number.isFinite(observedAt)) return null;
38019
+ return { version: version2, observedAt };
38020
+ } catch {
38021
+ return null;
38022
+ }
38023
+ }
38024
+
38025
+ // ../../packages/plugin-sdk/src/ignore-layers.ts
38026
+ var import_ignore = __toESM(require_ignore(), 1);
38027
+ import { readFileSync as readFileSync13 } from "fs";
38028
+ import { join as join20 } from "path";
38029
+
38030
+ // ../../packages/plugin-sdk/src/inventory-resolver.ts
38031
+ import { arch, hostname as hostname4, platform, release } from "os";
37716
38032
 
37717
38033
  // ../../packages/plugin-sdk/src/nudge.ts
37718
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
37719
- import { join as join19 } from "path";
38034
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
38035
+ import { join as join21 } from "path";
37720
38036
 
37721
38037
  // ../../packages/plugin-sdk/src/paths.ts
37722
38038
  import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
@@ -37758,8 +38074,8 @@ function createPolicyResolver(bundle) {
37758
38074
  }
37759
38075
 
37760
38076
  // ../../packages/plugin-sdk/src/project-files.ts
37761
- import { existsSync as existsSync10, readdirSync as readdirSync4 } from "fs";
37762
- import { basename as basename5, join as join20 } from "path";
38077
+ import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
38078
+ import { basename as basename5, join as join22 } from "path";
37763
38079
 
37764
38080
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
37765
38081
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -37790,6 +38106,14 @@ var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
37790
38106
  // ../../packages/plugin-sdk/src/runtime.ts
37791
38107
  import { randomUUID as randomUUID14 } from "crypto";
37792
38108
  var ENFORCEMENT_CEILING_ENABLED = false;
38109
+ function applyEnforcementCeiling(action, policyMode, enabled) {
38110
+ if (!enabled || policyMode !== "warn") return action;
38111
+ return action === "block" || action === "redact" ? "warn" : action;
38112
+ }
38113
+ function resolveEnforcedAction(action, opts) {
38114
+ const degraded = !opts.rewritable && action === "redact" ? builtinPolicyToAction(opts.redactFallback) : action;
38115
+ return applyEnforcementCeiling(degraded, opts.policyMode, opts.ceilingEnabled);
38116
+ }
37793
38117
  function startTiming() {
37794
38118
  try {
37795
38119
  return performance.now();
@@ -37898,12 +38222,12 @@ function createPluginRuntime(gateway, settings, opts) {
37898
38222
  }
37899
38223
  function actionForFinding(finding, excepted, rewritable = true) {
37900
38224
  if (excepted?.has(finding)) return "allow";
37901
- const action = resolveAction(finding.ruleId, finding.category);
37902
- if (!rewritable && action === "redact") return builtinPolicyToAction(redactFallback);
37903
- if (ENFORCEMENT_CEILING_ENABLED && policyMode === "warn" && (action === "block" || action === "redact")) {
37904
- return "warn";
37905
- }
37906
- return action;
38225
+ return resolveEnforcedAction(resolveAction(finding.ruleId, finding.category), {
38226
+ policyMode,
38227
+ redactFallback,
38228
+ rewritable,
38229
+ ceilingEnabled: ENFORCEMENT_CEILING_ENABLED
38230
+ });
37907
38231
  }
37908
38232
  function decide(findings, text, excepted, rewritable = true) {
37909
38233
  if (findings.length === 0) return { action: "log", text, findings: [] };
@@ -38152,7 +38476,7 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
38152
38476
 
38153
38477
  // ../../packages/plugin-sdk/src/throttle.ts
38154
38478
  import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
38155
- import { join as join21 } from "path";
38479
+ import { join as join23 } from "path";
38156
38480
 
38157
38481
  // ../../packages/plugin-sdk/src/tokenize.ts
38158
38482
  function redactedPlaceholder(category) {
@@ -38505,7 +38829,7 @@ function parseBreakerState(raw, nowMs) {
38505
38829
  }
38506
38830
  function createForwardPolicy(deps) {
38507
38831
  const now = deps.now ?? (() => Date.now());
38508
- const file2 = join22(deps.dir, STATE_FILENAME);
38832
+ const file2 = join24(deps.dir, STATE_FILENAME);
38509
38833
  let state = null;
38510
38834
  let loading = null;
38511
38835
  async function readState() {
@@ -39227,8 +39551,8 @@ function toolAuditEvent(input2) {
39227
39551
  }
39228
39552
 
39229
39553
  // ../../packages/plugin-runtime/src/attached/history-state.ts
39230
- import { readFileSync as readFileSync15 } from "fs";
39231
- import { join as join23 } from "path";
39554
+ import { readFileSync as readFileSync16 } from "fs";
39555
+ import { join as join25 } from "path";
39232
39556
 
39233
39557
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
39234
39558
  import { createHash as createHash6 } from "crypto";
@@ -39245,7 +39569,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
39245
39569
  var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
39246
39570
 
39247
39571
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
39248
- import { readFileSync as readFileSync16 } from "fs";
39572
+ import { readFileSync as readFileSync17 } from "fs";
39249
39573
  function createPluginBlock(build, policyStore) {
39250
39574
  return async () => {
39251
39575
  const cached2 = await policyStore.read();
@@ -39264,7 +39588,7 @@ function createPluginBlock(build, policyStore) {
39264
39588
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
39265
39589
  import { randomUUID as randomUUID16 } from "crypto";
39266
39590
  import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
39267
- import { join as join24 } from "path";
39591
+ import { join as join26 } from "path";
39268
39592
 
39269
39593
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
39270
39594
  import { rename as rename2 } from "fs/promises";
@@ -39288,7 +39612,7 @@ async function publishByRename(tmp, file2, move = rename2) {
39288
39612
 
39289
39613
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
39290
39614
  function createPolicyStore(dir = dataDir()) {
39291
- const file2 = join24(dir, "policy-cache.json");
39615
+ const file2 = join26(dir, "policy-cache.json");
39292
39616
  async function read() {
39293
39617
  try {
39294
39618
  const raw = await readFile2(file2, "utf8");
@@ -39519,11 +39843,11 @@ function readStorePosture(dbPath2) {
39519
39843
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
39520
39844
  import { randomUUID as randomUUID17 } from "crypto";
39521
39845
  import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
39522
- import { join as join25 } from "path";
39846
+ import { join as join27 } from "path";
39523
39847
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
39524
39848
  function createPostureStore(dir = settingsDir(), legacyDir) {
39525
- const file2 = join25(dir, "posture-state.json");
39526
- const legacyFile = legacyDir === void 0 ? null : join25(legacyDir, "posture-state.json");
39849
+ const file2 = join27(dir, "posture-state.json");
39850
+ const legacyFile = legacyDir === void 0 ? null : join27(legacyDir, "posture-state.json");
39527
39851
  async function persist(state) {
39528
39852
  await ensureDataDir(dir);
39529
39853
  const tmp = `${file2}.${randomUUID17()}.tmp`;
@@ -39591,8 +39915,8 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
39591
39915
  }
39592
39916
 
39593
39917
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
39594
- import { readFileSync as readFileSync17 } from "fs";
39595
- import { join as join26 } from "path";
39918
+ import { readFileSync as readFileSync18 } from "fs";
39919
+ import { join as join28 } from "path";
39596
39920
 
39597
39921
  // ../../packages/plugin-runtime/src/attached/status.ts
39598
39922
  var REFUSAL_LINES = {
@@ -40064,17 +40388,17 @@ var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
40064
40388
 
40065
40389
  // src/protocol/marker.ts
40066
40390
  import { randomBytes as randomBytes4 } from "crypto";
40067
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync18, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
40068
- import { join as join27 } from "path";
40391
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync19, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
40392
+ import { join as join29 } from "path";
40069
40393
  var MARKER_FILE = "protocol-marker";
40070
40394
  function mintMarker() {
40071
40395
  return randomBytes4(8).toString("hex");
40072
40396
  }
40073
40397
  function sessionProtocolMarker(dataDir2, sessionId) {
40074
40398
  if (!sessionId) return mintMarker();
40075
- const path = join27(dataDir2, MARKER_FILE);
40399
+ const path = join29(dataDir2, MARKER_FILE);
40076
40400
  try {
40077
- const stored = JSON.parse(readFileSync18(path, "utf8"));
40401
+ const stored = JSON.parse(readFileSync19(path, "utf8"));
40078
40402
  if (stored.sessionId === sessionId && typeof stored.marker === "string" && /^[0-9a-f]{16}$/.test(stored.marker)) {
40079
40403
  return stored.marker;
40080
40404
  }
@@ -40083,7 +40407,7 @@ function sessionProtocolMarker(dataDir2, sessionId) {
40083
40407
  const marker = mintMarker();
40084
40408
  try {
40085
40409
  mkdirSync5(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
40086
- const tmp = join27(dataDir2, `${MARKER_FILE}.tmp`);
40410
+ const tmp = join29(dataDir2, `${MARKER_FILE}.tmp`);
40087
40411
  writeFileSync8(tmp, JSON.stringify({ sessionId, marker }), { mode: DATA_FILE_MODE });
40088
40412
  renameSync5(tmp, path);
40089
40413
  } catch {
@@ -40136,6 +40460,68 @@ function userDisclosure(opts) {
40136
40460
  return sentences.join(" ");
40137
40461
  }
40138
40462
 
40463
+ // src/hooks/host-floor-notice.ts
40464
+ import { mkdirSync as mkdirSync6, readdirSync as readdirSync5, rmSync as rmSync7, statSync as statSync10, writeFileSync as writeFileSync9 } from "fs";
40465
+ import { join as join30 } from "path";
40466
+ var CLAIM_DIR = "host-floor-claims";
40467
+ var CLAIM_TTL_MS = 12 * 60 * 60 * 1e3;
40468
+ var CLAIM_SWEEP_MS = 7 * 24 * 60 * 60 * 1e3;
40469
+ function sweep(dir) {
40470
+ try {
40471
+ for (const name of readdirSync5(dir)) {
40472
+ const path = join30(dir, name);
40473
+ try {
40474
+ if (Date.now() - statSync10(path).mtimeMs > CLAIM_SWEEP_MS) rmSync7(path, { force: true });
40475
+ } catch {
40476
+ }
40477
+ }
40478
+ } catch {
40479
+ }
40480
+ }
40481
+ function tryClaim(dataDir2, sessionId) {
40482
+ if (sessionId === void 0 || sessionId === "") return () => void 0;
40483
+ const dir = join30(dataDir2, CLAIM_DIR);
40484
+ const path = join30(dir, encodeURIComponent(sessionId));
40485
+ try {
40486
+ if (Date.now() - statSync10(path).mtimeMs < CLAIM_TTL_MS) return null;
40487
+ rmSync7(path, { force: true });
40488
+ } catch {
40489
+ }
40490
+ try {
40491
+ mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
40492
+ writeFileSync9(path, String(Date.now()), { flag: "wx", mode: DATA_FILE_MODE });
40493
+ } catch (err) {
40494
+ if (err.code === "EEXIST") return null;
40495
+ return () => void 0;
40496
+ }
40497
+ sweep(dir);
40498
+ return () => {
40499
+ try {
40500
+ rmSync7(path, { force: true });
40501
+ } catch {
40502
+ }
40503
+ };
40504
+ }
40505
+ function warnIfHostBelowFloor(config2, sessionId, transcriptPath, write = (message) => void process.stderr.write(message)) {
40506
+ try {
40507
+ const release2 = tryClaim(config2.dataDir, sessionId);
40508
+ if (release2 === null) return;
40509
+ let settled = false;
40510
+ try {
40511
+ const version2 = hostVersionFromTranscript(transcriptPath);
40512
+ if (version2 === void 0) return;
40513
+ recordHostVersion(config2.dataDir, version2);
40514
+ const notice = hostFloorNotice(version2);
40515
+ if (notice !== null) write(`[aka] ${notice}
40516
+ `);
40517
+ settled = true;
40518
+ } finally {
40519
+ if (!settled) release2();
40520
+ }
40521
+ } catch {
40522
+ }
40523
+ }
40524
+
40139
40525
  // src/present.ts
40140
40526
  var SHADE = {
40141
40527
  light: "\u2591",
@@ -40389,8 +40775,8 @@ function baseMetadata(input2) {
40389
40775
  }
40390
40776
 
40391
40777
  // src/hooks/store-health.ts
40392
- import { mkdirSync as mkdirSync6, readFileSync as readFileSync19, writeFileSync as writeFileSync9 } from "fs";
40393
- import { dirname as dirname6, join as join28 } from "path";
40778
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync20, writeFileSync as writeFileSync10 } from "fs";
40779
+ import { dirname as dirname6, join as join31 } from "path";
40394
40780
  var STORE_REDIRECT_MARKER = "store-redirect-last-session";
40395
40781
  function markerDirs(dataDir2) {
40396
40782
  return [dataDir2, dirname6(dataDir2)];
@@ -40398,7 +40784,7 @@ function markerDirs(dataDir2) {
40398
40784
  function alreadyClaimed(dirs, marker, sessionId) {
40399
40785
  return dirs.some((dir) => {
40400
40786
  try {
40401
- return readFileSync19(join28(dir, marker), "utf8") === sessionId;
40787
+ return readFileSync20(join31(dir, marker), "utf8") === sessionId;
40402
40788
  } catch {
40403
40789
  return false;
40404
40790
  }
@@ -40407,8 +40793,8 @@ function alreadyClaimed(dirs, marker, sessionId) {
40407
40793
  function recordClaim(dirs, marker, sessionId) {
40408
40794
  for (const dir of dirs) {
40409
40795
  try {
40410
- mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
40411
- writeFileSync9(join28(dir, marker), sessionId, { mode: DATA_FILE_MODE });
40796
+ mkdirSync7(dir, { recursive: true, mode: DATA_DIR_MODE });
40797
+ writeFileSync10(join31(dir, marker), sessionId, { mode: DATA_FILE_MODE });
40412
40798
  return;
40413
40799
  } catch {
40414
40800
  }
@@ -40467,6 +40853,7 @@ async function main() {
40467
40853
  if (filePath) metadata.filePath = filePath;
40468
40854
  const config2 = loadConfig();
40469
40855
  warnIfStoreRedirected(config2, getString(input2, "session_id"));
40856
+ warnIfHostBelowFloor(config2, getString(input2, "session_id"), getString(input2, "transcript_path"));
40470
40857
  const gateway = resolveDataGateway(config2);
40471
40858
  const runtime = createPluginRuntime(gateway, config2.settings, { dataDir: config2.dataDir });
40472
40859
  const vaultGlue = isVaultConsentValid(config2.settings.vaultConsent) ? createVaultGlue() : null;