@capybara-hq/kernel 0.1.0-rc.116 → 0.1.0-rc.118

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.
Files changed (79) hide show
  1. package/dist/admin/usage.service.d.ts +4 -2
  2. package/dist/admin/usage.service.js +35 -15
  3. package/dist/catalog/catalog-content.d.ts +11 -0
  4. package/dist/catalog/catalog-content.js +1 -0
  5. package/dist/catalog/component-scope.service.js +2 -1
  6. package/dist/catalog/marketplaces.service.d.ts +1 -1
  7. package/dist/catalog/org-catalog.service.d.ts +1 -0
  8. package/dist/catalog/org-catalog.service.js +44 -2
  9. package/dist/catalog/plugin-install.d.ts +1 -0
  10. package/dist/catalog/plugin-install.js +11 -1
  11. package/dist/catalog/schema-path.d.ts +4 -6
  12. package/dist/catalog/schema-path.js +48 -21
  13. package/dist/channels/outbound.d.ts +5 -0
  14. package/dist/channels/outbound.js +6 -1
  15. package/dist/channels/supervisor.js +3 -0
  16. package/dist/conversations/conversations.controller.d.ts +1 -1
  17. package/dist/conversations/conversations.controller.js +1 -1
  18. package/dist/conversations/conversations.service.d.ts +4 -2
  19. package/dist/conversations/conversations.service.js +17 -3
  20. package/dist/conversations/events.d.ts +10 -1
  21. package/dist/conversations/events.js +8 -1
  22. package/dist/db/kernel-schema.d.ts +15 -1
  23. package/dist/devices/devices.controller.d.ts +5 -0
  24. package/dist/devices/devices.controller.js +20 -2
  25. package/dist/devices/devices.service.d.ts +11 -1
  26. package/dist/devices/devices.service.js +20 -0
  27. package/dist/evals/plan.d.ts +3 -1
  28. package/dist/evals/plan.js +25 -5
  29. package/dist/evals/runs.service.js +3 -2
  30. package/dist/evals/trajectory.js +1 -0
  31. package/dist/files/blob-references.d.ts +8 -0
  32. package/dist/files/blob-references.js +19 -0
  33. package/dist/files/blob-sweep.job.js +5 -23
  34. package/dist/files/library-files.service.js +8 -4
  35. package/dist/models/cache-write-usage.d.ts +3 -0
  36. package/dist/models/cache-write-usage.js +26 -0
  37. package/dist/models/images.js +5 -1
  38. package/dist/models/prices.d.ts +8 -6
  39. package/dist/models/prices.js +28 -3
  40. package/dist/orgs/settings.controller.d.ts +4 -17
  41. package/dist/orgs/settings.controller.js +5 -9
  42. package/dist/orgs/settings.service.d.ts +12 -0
  43. package/dist/orgs/settings.service.js +24 -0
  44. package/dist/platform/exclusions.js +11 -0
  45. package/dist/platform/ops/admin.ops.js +2 -2
  46. package/dist/platform/ops/conversations.ops.js +1 -1
  47. package/dist/platform/ops/devices.ops.js +21 -0
  48. package/dist/platform/ops/org-settings.ops.d.ts +3 -1
  49. package/dist/platform/ops/org-settings.ops.js +10 -10
  50. package/dist/runtime/context/build.d.ts +2 -0
  51. package/dist/runtime/context/build.js +9 -1
  52. package/dist/runtime/usage-report.js +3 -0
  53. package/dist/sandbox/legacy-retirement.d.ts +15 -0
  54. package/dist/sandbox/legacy-retirement.js +243 -3
  55. package/dist/sandbox/permission-instance-writes.d.ts +4 -1
  56. package/dist/sandbox/permission-instance-writes.js +55 -1
  57. package/dist/sandbox/providers.d.ts +6 -1
  58. package/dist/sandbox/providers.js +15 -1
  59. package/dist/sandbox/sandbox.service.d.ts +19 -3
  60. package/dist/sandbox/sandbox.service.js +167 -9
  61. package/dist/tools/builtins/sandbox/common.d.ts +2 -7
  62. package/dist/tools/builtins/sandbox/common.js +14 -8
  63. package/dist/tools/connector-tools-jobs.d.ts +3 -2
  64. package/dist/tools/connectors.service.d.ts +3 -1
  65. package/dist/tools/connectors.service.js +64 -12
  66. package/dist/tools/drift.d.ts +1 -1
  67. package/dist/tools/drift.js +13 -13
  68. package/dist/tools/pipeline.d.ts +4 -0
  69. package/dist/tools/pipeline.js +55 -16
  70. package/dist/ui/admin-ui.controller.d.ts +5 -2
  71. package/dist/ui/admin-ui.controller.js +14 -1
  72. package/dist/ui/ui.schemas.d.ts +9 -0
  73. package/dist/ui/ui.schemas.js +2 -0
  74. package/dist/ui/views.d.ts +1 -1
  75. package/dist/ui/views.js +4 -5
  76. package/package.json +3 -3
  77. package/src/migrations/0202_connector_endpoint_changed_at.sql +1 -0
  78. package/src/migrations/0203_model_cache_write_pricing.sql +5 -0
  79. package/src/migrations/0204_device_instance_retirement_identities.sql +46 -0
@@ -615,8 +615,15 @@ function loopbackAskRerunAfter(ask) {
615
615
  * the call's live loopback port grant (Full access or the review model granted the port to the
616
616
  * attempt that was refused it).
617
617
  */
618
- function rerunPoints(ask, grant) {
619
- const points = [serviceRerunAfter(ask), loopbackAskRerunAfter(ask), grant?.attempt ?? null];
618
+ /** The idempotency key of the `permission_reviewed` event tying a ready-grant rerun to a call. */
619
+ const loopbackReadyRerunIdemKey = (runId, callId) => `permission_reviewed:loopback_ready:${runId}:${callId}`;
620
+ function rerunPoints(ask, grant, readyRerun = null) {
621
+ const points = [
622
+ serviceRerunAfter(ask),
623
+ loopbackAskRerunAfter(ask),
624
+ grant?.attempt ?? null,
625
+ readyRerun,
626
+ ];
620
627
  return new Set(points.filter((p) => p !== null));
621
628
  }
622
629
  /** An ask whose approval runs the call again: it belongs to the attempt that asked. */
@@ -905,11 +912,12 @@ let ToolPipeline = class ToolPipeline {
905
912
  // the call's network ask (one per call) and its live loopback port grant
906
913
  const ask = await this.deps.approvals.networkForCall(ctx.runId, call.id);
907
914
  const grant = await this.loopbackGrantOf(ctx.runId, call.id);
915
+ const readyRerun = await this.readyLoopbackRerunOf(ctx.conversationId, ctx.runId, call.id);
908
916
  let attempt = rounds.length + 1;
909
917
  // each time the call ran again (after its network ask, browser use spec §7.1, or a loopback
910
918
  // grant or ask) took one attempt more: input rounds asked after a re-run come after it, so
911
919
  // every re-run point the count has passed adds one, in order
912
- const reruns = rerunPoints(ask, grant);
920
+ const reruns = rerunPoints(ask, grant, readyRerun);
913
921
  if (rounds.length > 0) {
914
922
  for (const p of [...reruns].sort((a, b) => a - b))
915
923
  if (attempt > p)
@@ -945,10 +953,13 @@ let ToolPipeline = class ToolPipeline {
945
953
  (!asksPerAttempt(ask) ||
946
954
  ask.detail?.attempt === attempt);
947
955
  const grantedHere = !askedHere && grant !== null && grant.attempt === attempt;
948
- if (askedHere || grantedHere) {
956
+ const readyRerunHere = !askedHere && !grantedHere && readyRerun === attempt;
957
+ if (askedHere || grantedHere || readyRerunHere) {
949
958
  const notes = askedHere && ask !== null
950
959
  ? settledNetworkNotes(ask, approvalHours(ask))
951
- : [loopbackGrantedNote(grant.port)];
960
+ : grantedHere
961
+ ? [loopbackGrantedNote(grant.port)]
962
+ : [];
952
963
  if (notes === null)
953
964
  return approvalWait(ask);
954
965
  const rerunsHere = !askedHere ||
@@ -2596,6 +2607,15 @@ let ToolPipeline = class ToolPipeline {
2596
2607
  async loopbackGrantOf(runId, callId) {
2597
2608
  return (await this.loopbackGrants?.forCall(runId, callId)) ?? null;
2598
2609
  }
2610
+ /**
2611
+ * The attempt that recorded a ready-grant loopback rerun for this call, or null when none did.
2612
+ */
2613
+ async readyLoopbackRerunOf(conversationId, runId, callId) {
2614
+ const ev = await this.deps.eventLog.findByIdem(conversationId, loopbackReadyRerunIdemKey(runId, callId));
2615
+ return ev?.type === "permission_reviewed"
2616
+ ? (ev.payload.loopback?.readyRerunAttempt ?? null)
2617
+ : null;
2618
+ }
2599
2619
  /**
2600
2620
  * A device service's loopback refusal (browser loopback port grants): the port of the person's
2601
2621
  * own device a service of an extension declaring `permissions.deviceAccess.loopbackPorts` was
@@ -2659,17 +2679,6 @@ let ToolPipeline = class ToolPipeline {
2659
2679
  port,
2660
2680
  };
2661
2681
  const live = await grants.liveForRoot(ctx.orgId, device.deviceId, serviceId, facts.rootConversationId);
2662
- if (live.some((g) => g.port === port)) {
2663
- // granted already (the panel, an earlier call): the service had not applied it yet, so the
2664
- // call runs again once; refused again (or granted to this call), its result stands
2665
- if (rerunning || (await grants.forCall(ctx.runId, call.id)) !== null)
2666
- return { kind: "write", notes: [loopbackNotAppliedNote(port)] };
2667
- await this.writeResultIn(ctx, call.id, toolKey, kept, [...pre], callAudit, []);
2668
- return { kind: "rerun", notes: [] };
2669
- }
2670
- // a call that ran again after its grant is not decided again (the port was closed meanwhile)
2671
- if (rerunning)
2672
- return { kind: "write", notes: [serviceAskedNote([hp])] };
2673
2682
  const binding = {
2674
2683
  orgId: facts.orgId,
2675
2684
  rootConversationId: facts.rootConversationId,
@@ -2687,6 +2696,36 @@ let ToolPipeline = class ToolPipeline {
2687
2696
  scopeRevision: facts.scopeRevision,
2688
2697
  authorityRevision: facts.authorityRevision,
2689
2698
  };
2699
+ if (live.some((g) => g.port === port)) {
2700
+ // granted already (the panel, an earlier call): the service had not applied it yet, so the
2701
+ // call runs again once; refused again (or granted to this call), its result stands
2702
+ if (rerunning || (await grants.forCall(ctx.runId, call.id)) !== null)
2703
+ return { kind: "write", notes: [loopbackNotAppliedNote(port)] };
2704
+ const readyCandidate = {
2705
+ binding,
2706
+ permissionScope: { writeDirectories: [], hosts: [] },
2707
+ scopeKind: "loopback-port",
2708
+ loopback: { service: serviceId, port, readyRerunAttempt: attempt },
2709
+ };
2710
+ const readyEvent = {
2711
+ type: "permission_reviewed",
2712
+ runId: ctx.runId,
2713
+ idemKey: loopbackReadyRerunIdemKey(ctx.runId, call.id),
2714
+ payload: {
2715
+ ...readyCandidate,
2716
+ candidateHash: permissionScopeHash(readyCandidate),
2717
+ outcome: "allow",
2718
+ reason: "Loopback port already granted for this conversation; retrying after the device applies it.",
2719
+ decisionSource: "rule",
2720
+ crossing: "loopback-port",
2721
+ },
2722
+ };
2723
+ await this.writeResultIn(ctx, call.id, toolKey, kept, [readyEvent, ...pre], callAudit, []);
2724
+ return { kind: "rerun", notes: [] };
2725
+ }
2726
+ // a call that ran again after its grant is not decided again (the port was closed meanwhile)
2727
+ if (rerunning)
2728
+ return { kind: "write", notes: [serviceAskedNote([hp])] };
2690
2729
  const reviewed = (outcome, reason, decisionSource) => {
2691
2730
  const candidate = {
2692
2731
  binding,
@@ -1,11 +1,11 @@
1
- import type { UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
1
+ import type { JsonValue, UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
2
2
  import type { FastifyReply, FastifyRequest } from "fastify";
3
3
  import type { z } from "zod";
4
4
  import { ApiTokenService } from "../identity/api-tokens.js";
5
5
  import { type Principal } from "../identity/principal.js";
6
6
  import { SessionService } from "../identity/sessions.js";
7
7
  import { EmbedTokens } from "./embed-token.js";
8
- import { ContributionParams, PlatformActionBody, PlatformViewQuery } from "./ui.schemas.js";
8
+ import { ContributionParams, PlatformActionBody, PlatformQueryBody, PlatformViewQuery } from "./ui.schemas.js";
9
9
  import { OrgUiStreams } from "./ui-stream.js";
10
10
  import { type UiArrangementSlot, type UiContributionItem, UiViews } from "./views.js";
11
11
  /**
@@ -45,6 +45,9 @@ export declare class AdminUiController {
45
45
  view: UiView;
46
46
  }>;
47
47
  action(principal: Principal, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof PlatformActionBody>): Promise<UiActionResult>;
48
+ query(principal: Principal, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof PlatformQueryBody>): Promise<{
49
+ data: JsonValue;
50
+ }>;
48
51
  embedToken(principal: Principal, { plugin, id }: z.infer<typeof ContributionParams>): Promise<{
49
52
  token: string;
50
53
  src: string;
@@ -15,7 +15,7 @@ import { SessionService } from "../identity/sessions.js";
15
15
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
16
16
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
17
17
  import { EMBED_TOKEN_TTL_SECONDS, EmbedTokens } from "./embed-token.js";
18
- import { ContributionParams, PlatformActionBody, PlatformViewQuery } from "./ui.schemas.js";
18
+ import { ContributionParams, PlatformActionBody, PlatformQueryBody, PlatformViewQuery, } from "./ui.schemas.js";
19
19
  import { OrgUiStreams } from "./ui-stream.js";
20
20
  import { BEARER_RE, embedSrc } from "./views.controller.js";
21
21
  import { UiViews } from "./views.js";
@@ -25,6 +25,8 @@ class AdminUiViewQueryDto extends createZodDto(PlatformViewQuery, "AdminUiViewQu
25
25
  }
26
26
  class AdminUiActionBodyDto extends createZodDto(PlatformActionBody, "AdminUiActionBody") {
27
27
  }
28
+ class AdminUiQueryBodyDto extends createZodDto(PlatformQueryBody, "AdminUiQueryBody") {
29
+ }
28
30
  /**
29
31
  * Extension UI in the admin console (UI slots spec §7, platform scope): the `platform.page`
30
32
  * contributions, for super admins only (`@SuperAdmin`, a person: service tokens are refused), with
@@ -85,6 +87,10 @@ let AdminUiController = class AdminUiController {
85
87
  ...(body.answer !== undefined && { answer: body.answer }),
86
88
  });
87
89
  }
90
+ async query(principal, { plugin, id }, body) {
91
+ const p = requireUser(principal);
92
+ return this.views.query({ scope: "platform", accountId: p.account.id, plugin, id, locale: body.locale }, { query: body.query, ...(body.params !== undefined && { params: body.params }) });
93
+ }
88
94
  async embedToken(principal, { plugin, id }) {
89
95
  const p = requireUser(principal);
90
96
  const target = await this.views.embed({
@@ -168,6 +174,13 @@ __decorate([
168
174
  __param(1, ZParam(AdminUiContributionParamsDto)),
169
175
  __param(2, ZBody(AdminUiActionBodyDto))
170
176
  ], AdminUiController.prototype, "action", null);
177
+ __decorate([
178
+ Post("query/:plugin/:id"),
179
+ HttpCode(200),
180
+ __param(0, CurrentPrincipal()),
181
+ __param(1, ZParam(AdminUiContributionParamsDto)),
182
+ __param(2, ZBody(AdminUiQueryBodyDto))
183
+ ], AdminUiController.prototype, "query", null);
171
184
  __decorate([
172
185
  Post("embeds/:plugin/:id/token"),
173
186
  HttpCode(200),
@@ -91,5 +91,14 @@ export declare const PlatformActionBody: z.ZodObject<{
91
91
  zh: "zh";
92
92
  }>>;
93
93
  }, z.core.$strip>;
94
+ /** `POST /api/v1/admin/ui/query/:plugin/:id`: a component query of a platform page (no context id). */
95
+ export declare const PlatformQueryBody: z.ZodObject<{
96
+ query: z.ZodString;
97
+ params: z.ZodOptional<z.ZodUnknown>;
98
+ locale: z.ZodDefault<z.ZodEnum<{
99
+ en: "en";
100
+ zh: "zh";
101
+ }>>;
102
+ }, z.core.$strip>;
94
103
  /** The slot catalog route the Platform operation `ui.slots` mirrors (`check:platform-ops` key). */
95
104
  export declare const UI_ROUTES: readonly RouteSchemas[];
@@ -87,5 +87,7 @@ export const EmbedTokenBody = z
87
87
  export const PlatformViewQuery = z.object({ locale: Locale });
88
88
  /** `POST /api/v1/admin/ui/actions/:plugin/:id`: an action of a platform page (no context id). */
89
89
  export const PlatformActionBody = ActionBody.omit({ conversationId: true, agentId: true });
90
+ /** `POST /api/v1/admin/ui/query/:plugin/:id`: a component query of a platform page (no context id). */
91
+ export const PlatformQueryBody = QueryBody.omit({ conversationId: true, agentId: true });
90
92
  /** The slot catalog route the Platform operation `ui.slots` mirrors (`check:platform-ops` key). */
91
93
  export const UI_ROUTES = [{ route: "GET /api/v1/ui/slots" }];
@@ -225,7 +225,7 @@ export declare class UiViews {
225
225
  * result that is not JSON or over `UI_LIMITS.componentQueryBytes` 502
226
226
  * `ui.query_result_too_large`.
227
227
  */
228
- query(t: UiOrgTarget, input: {
228
+ query(t: UiTarget, input: {
229
229
  query: string;
230
230
  params?: unknown;
231
231
  }): Promise<{
package/dist/ui/views.js CHANGED
@@ -488,18 +488,17 @@ let UiViews = class UiViews {
488
488
  throw new ApiError("ui.query_params_too_large", `params must be at most ${UI_LIMITS.componentQueryParamsBytes} bytes as JSON`);
489
489
  }
490
490
  const handler = resolved.entry.query;
491
- // an org target always resolves to org args
492
- const args = resolved.args;
491
+ const scopeField = t.scope === "platform" ? { scope: "platform" } : { orgId: t.orgId };
493
492
  const data = await callExtension({
494
493
  log: this.d.log,
495
494
  plugin: t.plugin,
496
495
  what: "query",
497
- fields: { plugin: t.plugin, contribution: t.id, query: input.query, orgId: t.orgId },
496
+ fields: { plugin: t.plugin, contribution: t.id, query: input.query, ...scopeField },
498
497
  timeoutMs: UI_QUERY_TIMEOUT_MS,
499
498
  failCode: "ui.query_failed",
500
499
  timeoutCode: "ui.query_timeout",
501
500
  failMessage: `Plugin ${t.plugin} failed to answer query ${input.query} of ${t.id}`,
502
- fn: (signal) => handler({ ...args, query: input.query, params, signal }),
501
+ fn: (signal) => handler({ ...resolved.args, query: input.query, params, signal }),
503
502
  });
504
503
  let json;
505
504
  try {
@@ -514,7 +513,7 @@ let UiViews = class UiViews {
514
513
  plugin: t.plugin,
515
514
  contribution: t.id,
516
515
  query: input.query,
517
- orgId: t.orgId,
516
+ ...scopeField,
518
517
  ...(bytes !== undefined && { bytes }),
519
518
  });
520
519
  throw new ApiError("ui.query_result_too_large", `Plugin ${t.plugin} returned a query result that is not JSON of at most ${UI_LIMITS.componentQueryBytes} bytes`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.116",
3
+ "version": "0.1.0-rc.118",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yaml": "^2.9.1",
67
67
  "yauzl": "3.4.0",
68
68
  "zod": "^4.6.7",
69
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.91"
69
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.93"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -75,7 +75,7 @@
75
75
  "@types/ws": "^8.18.2",
76
76
  "@types/yauzl": "3.4.0",
77
77
  "ws": "^8.22.0",
78
- "@capybara-hq/testing": "0.1.0-rc.50"
78
+ "@capybara-hq/testing": "0.1.0-rc.51"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsc -b"
@@ -0,0 +1 @@
1
+ ALTER TABLE connectors ADD COLUMN IF NOT EXISTS endpoint_changed_at timestamptz;
@@ -0,0 +1,5 @@
1
+ ALTER TABLE model_prices ADD COLUMN IF NOT EXISTS cache_write_per_mtok_by_ttl jsonb NOT NULL
2
+ DEFAULT '{}'::jsonb CHECK (jsonb_typeof(cache_write_per_mtok_by_ttl) = 'object');
3
+
4
+ ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS cache_write_by_ttl jsonb
5
+ CHECK (cache_write_by_ttl IS NULL OR jsonb_typeof(cache_write_by_ttl) = 'array');
@@ -0,0 +1,46 @@
1
+ -- Keep the exact local provider generation separately from the kernel's incarnation timestamp.
2
+ CREATE TABLE IF NOT EXISTS device_instance_retirement_identities (
3
+ org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
4
+ device_id text NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
5
+ provider text NOT NULL,
6
+ instance_generation text NOT NULL CHECK (instance_generation ~ '^[1-9][0-9]{0,15}$'),
7
+ provider_generation text NOT NULL CHECK (provider_generation ~ '^[1-9][0-9]{0,15}$'),
8
+ -- Kept separately from unconditional provider destruction evidence.
9
+ attested_at timestamptz,
10
+ PRIMARY KEY (org_id, device_id, provider, instance_generation),
11
+ UNIQUE (org_id, device_id, provider, provider_generation)
12
+ );
13
+
14
+ DROP POLICY IF EXISTS org_scope ON device_instance_retirement_identities;
15
+ CREATE POLICY org_scope ON device_instance_retirement_identities
16
+ USING (rls_admits(org_id)) WITH CHECK (rls_admits(org_id));
17
+
18
+ -- Older workers also add members. Reopen a proof-based resolution atomically with any addition,
19
+ -- so the existing finisher can never inherit authority for a member the check did not validate.
20
+ CREATE OR REPLACE FUNCTION reopen_local_retirement_proof() RETURNS trigger
21
+ LANGUAGE plpgsql SET search_path FROM CURRENT AS $$
22
+ BEGIN
23
+ UPDATE device_retirement_obligations AS o
24
+ SET state = 'quarantined', resolution = NULL, resolved_at = NULL,
25
+ reason = 'a retirement member has yet to be covered by checked machine evidence'
26
+ WHERE o.id = NEW.obligation_id
27
+ AND o.provider = 'device-local'
28
+ AND o.state = 'resolved'
29
+ AND o.resolution = 'provider-destroyed'
30
+ AND EXISTS (
31
+ SELECT 1 FROM device_instance_retirement_identities AS i
32
+ WHERE i.org_id = o.org_id AND i.device_id = o.device_id AND i.provider = o.provider
33
+ AND i.instance_generation = o.instance_generation AND i.attested_at IS NOT NULL
34
+ )
35
+ AND NOT EXISTS (
36
+ SELECT 1 FROM device_instance_destructions AS d
37
+ WHERE d.device_id = o.device_id AND d.provider = o.provider
38
+ AND d.instance_generation = o.instance_generation
39
+ );
40
+ RETURN NEW;
41
+ END
42
+ $$;
43
+
44
+ CREATE OR REPLACE TRIGGER device_retirement_proof_new_member
45
+ AFTER INSERT ON device_retirement_members
46
+ FOR EACH ROW EXECUTE FUNCTION reopen_local_retirement_proof();