@happyvertical/smrt-ingestion 0.57.20 → 0.57.21

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 (92) hide show
  1. package/FEEDBACK.md +33 -0
  2. package/PROPOSALS.md +127 -5
  3. package/README.md +42 -2
  4. package/REVIEW.md +339 -3
  5. package/agents/execution.md +15 -0
  6. package/dist/chunks/{execution-NoDh3pjs.js → execution-9CfjxX8I.js} +110 -22
  7. package/dist/chunks/execution-9CfjxX8I.js.map +1 -0
  8. package/dist/chunks/{proposal-errors-VxcTU6Db.js → extraction-CJ-zrbg0.js} +4 -10
  9. package/dist/chunks/extraction-CJ-zrbg0.js.map +1 -0
  10. package/dist/chunks/{feedback-CJB900iG.js → feedback-CuUzWKzP.js} +59 -18
  11. package/dist/chunks/feedback-CuUzWKzP.js.map +1 -0
  12. package/dist/chunks/reviewer-instruction-Db3jDN9a.js +33 -0
  13. package/dist/chunks/reviewer-instruction-Db3jDN9a.js.map +1 -0
  14. package/dist/dto.d.ts +6 -0
  15. package/dist/dto.d.ts.map +1 -1
  16. package/dist/execution-internal.d.ts +2 -0
  17. package/dist/execution-internal.d.ts.map +1 -1
  18. package/dist/execution.d.ts +43 -1
  19. package/dist/execution.d.ts.map +1 -1
  20. package/dist/execution.js +1 -1
  21. package/dist/feedback-dto.d.ts +6 -0
  22. package/dist/feedback-dto.d.ts.map +1 -1
  23. package/dist/feedback.d.ts +7 -0
  24. package/dist/feedback.d.ts.map +1 -1
  25. package/dist/manifest.json +19 -1
  26. package/dist/models.d.ts.map +1 -1
  27. package/dist/models.js +10 -1
  28. package/dist/models.js.map +1 -1
  29. package/dist/presented-filename.d.ts +11 -0
  30. package/dist/presented-filename.d.ts.map +1 -0
  31. package/dist/proposal-contracts.d.ts +31 -6
  32. package/dist/proposal-contracts.d.ts.map +1 -1
  33. package/dist/proposal-dto.d.ts +17 -0
  34. package/dist/proposal-dto.d.ts.map +1 -1
  35. package/dist/proposal-errors.d.ts +16 -0
  36. package/dist/proposal-errors.d.ts.map +1 -1
  37. package/dist/proposal-validation.d.ts +26 -0
  38. package/dist/proposal-validation.d.ts.map +1 -1
  39. package/dist/proposals.d.ts +5 -1
  40. package/dist/proposals.d.ts.map +1 -1
  41. package/dist/proposals.js +261 -69
  42. package/dist/proposals.js.map +1 -1
  43. package/dist/review-dto.d.ts +95 -2
  44. package/dist/review-dto.d.ts.map +1 -1
  45. package/dist/review-host.d.ts +52 -3
  46. package/dist/review-host.d.ts.map +1 -1
  47. package/dist/review-instruction-view.d.ts +12 -0
  48. package/dist/review-instruction-view.d.ts.map +1 -0
  49. package/dist/review-summary.d.ts.map +1 -1
  50. package/dist/reviewer-instruction.d.ts +20 -0
  51. package/dist/reviewer-instruction.d.ts.map +1 -0
  52. package/dist/server.d.ts +171 -4
  53. package/dist/server.d.ts.map +1 -1
  54. package/dist/server.js +835 -49
  55. package/dist/server.js.map +1 -1
  56. package/dist/smrt-knowledge.json +29 -21
  57. package/dist/sources/common.d.ts +11 -0
  58. package/dist/sources/common.d.ts.map +1 -1
  59. package/dist/sources/email.d.ts.map +1 -1
  60. package/dist/sources/http.d.ts.map +1 -1
  61. package/dist/sources/watch-folder.d.ts.map +1 -1
  62. package/dist/svelte/components/ActionReview.svelte +15 -46
  63. package/dist/svelte/components/ActionReview.svelte.d.ts.map +1 -1
  64. package/dist/svelte/components/CandidatePicker.svelte +72 -0
  65. package/dist/svelte/components/CandidatePicker.svelte.d.ts +15 -0
  66. package/dist/svelte/components/CandidatePicker.svelte.d.ts.map +1 -0
  67. package/dist/svelte/components/InboxView.svelte +14 -3
  68. package/dist/svelte/components/InboxView.svelte.d.ts +8 -1
  69. package/dist/svelte/components/InboxView.svelte.d.ts.map +1 -1
  70. package/dist/svelte/components/IntakeInbox.svelte +6 -3
  71. package/dist/svelte/components/IntakeInbox.svelte.d.ts +4 -1
  72. package/dist/svelte/components/IntakeInbox.svelte.d.ts.map +1 -1
  73. package/dist/svelte/components/IntakeReview.svelte +4 -2
  74. package/dist/svelte/components/IntakeReview.svelte.d.ts +2 -0
  75. package/dist/svelte/components/IntakeReview.svelte.d.ts.map +1 -1
  76. package/dist/svelte/components/ReviewView.svelte +403 -62
  77. package/dist/svelte/components/ReviewView.svelte.d.ts +2 -0
  78. package/dist/svelte/components/ReviewView.svelte.d.ts.map +1 -1
  79. package/dist/svelte/i18n.d.ts +17 -0
  80. package/dist/svelte/i18n.d.ts.map +1 -1
  81. package/dist/svelte/i18n.js +17 -0
  82. package/dist/svelte/index.d.ts +1 -1
  83. package/dist/svelte/index.d.ts.map +1 -1
  84. package/dist/svelte/view-utils.d.ts +2 -0
  85. package/dist/svelte/view-utils.d.ts.map +1 -1
  86. package/dist/svelte/view-utils.js +12 -0
  87. package/package.json +13 -13
  88. package/dist/chunks/execution-NoDh3pjs.js.map +0 -1
  89. package/dist/chunks/execution-internal-DWteDHM2.js +0 -7
  90. package/dist/chunks/execution-internal-DWteDHM2.js.map +0 -1
  91. package/dist/chunks/feedback-CJB900iG.js.map +0 -1
  92. package/dist/chunks/proposal-errors-VxcTU6Db.js.map +0 -1
@@ -83,6 +83,21 @@ each step review; changed preview/preconditions require a fresh review.
83
83
  Abort/continue follows the pinned public playbook definition, with fresh authority
84
84
  at every step.
85
85
 
86
+ Human corrections are the logical split and the reviewer instruction. Both are
87
+ minted only by their authenticated review API under reviewer authority, written
88
+ into a new immutable extraction configuration, and reach interpretation only as
89
+ a digest-verified copy. Neither grants handlers, candidates, permissions or
90
+ automation; `authorizeAutomatic` and preview/approval are unchanged for actions
91
+ produced under an instruction. Recording either supersedes current suggestions
92
+ and queues the existing dispatch stages (a new extraction revision, then
93
+ interpretation — provider extraction budget is spent per correction because the
94
+ predecessor pin is not reused); hosts wake their worker through
95
+ `onSplit`/`onInstruct` and rely on dispatch repair otherwise. While a stage is
96
+ queued/running the item reports `processing` regardless of earlier actions; a
97
+ failed stage (extraction or interpretation) exposes its safe category through
98
+ `getReinterpretationState`, and a retry anchored on the latest completed
99
+ generation carries forward any newer split correction.
100
+
86
101
  `continueIntakeReview` uses the existing jobs continuation context. Applications
87
102
  create tasks with owner, tenant and exact `{recordId, revision, inputKey}` binding
88
103
  and configure `authorizeMcpTask` to revalidate it. A continuation answer only wakes
@@ -1,4 +1,3 @@
1
- import { t as discoveryTransaction } from "./execution-internal-DWteDHM2.js";
2
1
  import { ObjectRegistry, detectEngine, isEmbeddedDatabase, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
3
2
  import { createHash, randomUUID } from "node:crypto";
4
3
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -45,6 +44,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
45
44
  }) : target, mod));
46
45
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
46
  //#endregion
47
+ //#region src/execution-internal.ts
48
+ var discoveryTransaction = /* @__PURE__ */ Symbol("ingestion.discoveryTransaction");
49
+ var generationSnapshotRead = /* @__PURE__ */ Symbol("ingestion.generationSnapshotRead");
50
+ var listReadGate = /* @__PURE__ */ Symbol("ingestion.listReadGate");
51
+ //#endregion
52
+ //#region src/proposal-errors.ts
53
+ var HandlerArgumentsInvalidError = class extends Error {
54
+ constructor(message) {
55
+ super(message);
56
+ this.name = "HandlerArgumentsInvalidError";
57
+ }
58
+ };
59
+ var GenerationSourceStaleError = class extends Error {
60
+ constructor() {
61
+ super("Generation source superseded");
62
+ this.name = "GenerationSourceStaleError";
63
+ }
64
+ };
65
+ var GenerationSnapshotStaleError = class extends Error {
66
+ constructor() {
67
+ super("Generation snapshot stale");
68
+ this.name = "GenerationSnapshotStaleError";
69
+ }
70
+ };
71
+ //#endregion
48
72
  //#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
49
73
  var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
50
74
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6583,26 +6607,53 @@ var IntakeExecutionService = class {
6583
6607
  ].includes(handler.capability.effect ?? "") || typeof handler.capability.idempotent !== "boolean" || typeof handler.capability.openWorld !== "boolean") throw new Error("Undeclared capability");
6584
6608
  return handler;
6585
6609
  }
6586
- validate(schema, value, limit) {
6610
+ /**
6611
+ * `arguments` marks arguments being previewed (operation preview, which
6612
+ * also carries corrections, and plan preview): only their schema refusal is
6613
+ * the correctable `HandlerArgumentsInvalidError`. Apply-time and
6614
+ * external-send revalidation and result-schema checks keep the plain error.
6615
+ */
6616
+ validate(schema, value, limit, arguments_ = false) {
6587
6617
  if (Buffer.byteLength(canonical(value)) > limit || schema.type !== "object" || schema.additionalProperties !== false) throw new Error("Invalid handler payload");
6588
- if (!this.ajv.compile(schema)(value)) throw new Error("Invalid handler payload");
6618
+ if (!this.ajv.compile(schema)(value)) throw arguments_ ? new HandlerArgumentsInvalidError("Invalid handler payload") : /* @__PURE__ */ new Error("Invalid handler payload");
6589
6619
  }
6590
- async access(db, item, handler, operation) {
6620
+ /**
6621
+ * The read-only half of `access`: current host authority, policy and
6622
+ * ceiling allowlists and the retention deadline they imply. It writes
6623
+ * nothing, so a listing may call it per (item, handler) without opening a
6624
+ * transaction per row.
6625
+ */
6626
+ async authority(db, item, handler, operation, onHostError) {
6591
6627
  const ceiling = this.ceiling(item);
6592
- const current = await this.config.authorize({
6593
- db,
6594
- scope: this.scope,
6595
- itemId: String(item.id),
6596
- capturedCeiling: ceiling,
6597
- operation,
6598
- handlerId: handler.id
6599
- });
6628
+ let current;
6629
+ try {
6630
+ current = await this.config.authorize({
6631
+ db,
6632
+ scope: this.scope,
6633
+ itemId: String(item.id),
6634
+ capturedCeiling: ceiling,
6635
+ operation,
6636
+ handlerId: handler.id
6637
+ });
6638
+ } catch (error) {
6639
+ onHostError?.(error);
6640
+ throw error;
6641
+ }
6600
6642
  if (!current.allowed || current.mutationBoundary !== "serialized" || current.principalId !== ceiling.principalId) throw new Error("Intake unavailable");
6601
6643
  const policy = resolveIntakePolicy(current.policy);
6602
6644
  const operationKey = "model" in handler.operation ? `${handler.operation.model}:${handler.operation.action}@${handler.operation.version}` : handler.operation.playbookKey;
6603
6645
  if (!policy.enabled || !policy.handlers.includes(handler.id) || !ceiling.handlers.includes(handler.id) || !policy.operations.includes(operationKey) || !ceiling.operations.includes(operationKey) || !policy.access.includes(this.scope.confidentialScopeId)) throw new Error("Intake unavailable");
6604
6646
  if (operation === "review" && (!current.reviewer || !policy.reviewers.includes(this.scope.actorId))) throw new Error("Intake unavailable");
6605
6647
  const deadline = Math.min(time(item.expires_at), time(item.created_at) + policy.retentionMs);
6648
+ return {
6649
+ current,
6650
+ ceiling,
6651
+ policy,
6652
+ deadline
6653
+ };
6654
+ }
6655
+ async access(db, item, handler, operation) {
6656
+ const { current, ceiling, policy, deadline } = await this.authority(db, item, handler, operation);
6606
6657
  const enforce = async (executor) => {
6607
6658
  const intents = this.retentionIntents.getStore();
6608
6659
  const itemId = String(item.id);
@@ -6739,6 +6790,38 @@ var IntakeExecutionService = class {
6739
6790
  handler
6740
6791
  };
6741
6792
  }
6793
+ /**
6794
+ * Read authority for one handler binding of a listed item, read-only. It
6795
+ * applies the handler checks `listReviews` applies before projecting an
6796
+ * action: the bound handler must resolve to a single operation whose
6797
+ * operation and capability still match the saved binding (no version
6798
+ * drift), and the execution read gate (host authority, policy and ceiling
6799
+ * handler/operation allowlists, `policy.access`, principal) must pass, but
6800
+ * without the retention write; an item past the deadline `access` would
6801
+ * narrow to is not listable, and neither is a cancelled item, which
6802
+ * `listReviews` refuses once it binds an action. Per-action target,
6803
+ * evidence and plan gates are not evaluated here; `load` still enforces
6804
+ * them. A refusal or any other failed check answers false and the list
6805
+ * discloses nothing about why; a host `authorize` that throws propagates,
6806
+ * as it does from `load`, so the page is rejected. Package-internal:
6807
+ * reachable only through a symbol the service holds,
6808
+ * so callers cannot hand it an unscoped row.
6809
+ */
6810
+ async [listReadGate](item, binding) {
6811
+ let hostFailure;
6812
+ try {
6813
+ if (item.cancelled) return false;
6814
+ const handler = this.operation(this.handler(binding.handlerId, binding.handlerVersion));
6815
+ if (canonical(handler.operation) !== canonical(binding.operation) || canonical(handler.capability) !== canonical(binding.capability)) return false;
6816
+ const { deadline } = await this.authority(this.db, item, handler, "read", (error) => {
6817
+ hostFailure = { error };
6818
+ });
6819
+ return deadline > this.now().getTime();
6820
+ } catch {
6821
+ if (hostFailure) throw hostFailure.error;
6822
+ return false;
6823
+ }
6824
+ }
6742
6825
  review(bound) {
6743
6826
  return {
6744
6827
  actionId: String(bound.action.id),
@@ -6848,7 +6931,7 @@ var IntakeExecutionService = class {
6848
6931
  if (!Array.isArray(references)) throw new Error("Feedback lineage unavailable");
6849
6932
  if (references.length === 0) return;
6850
6933
  if (!this.options.feedback) throw new Error("Feedback configuration unavailable");
6851
- const { IntakeFeedbackService } = await import("./feedback-CJB900iG.js").then((n) => n.r);
6934
+ const { IntakeFeedbackService } = await import("./feedback-CuUzWKzP.js").then((n) => n.r);
6852
6935
  await new IntakeFeedbackService(this.options, this).assertActionLineage(String(bound.action.id), db, String(bound.proposal.id));
6853
6936
  }
6854
6937
  async getAction(actionId) {
@@ -7043,7 +7126,12 @@ var IntakeExecutionService = class {
7043
7126
  };
7044
7127
  });
7045
7128
  }
7046
- async buildBinding(db, item, input) {
7129
+ /**
7130
+ * `reviewed` marks arguments a reviewer is previewing or correcting: only
7131
+ * then is a refusal the typed `HandlerArgumentsInvalidError`. Apply-time
7132
+ * verification and plan step expansion keep the plain error.
7133
+ */
7134
+ async buildBinding(db, item, input, reviewed = false) {
7047
7135
  const handler = this.operation(this.handler(input.handlerId, input.handlerVersion));
7048
7136
  const { policy, context } = await this.access(db, item, handler, "preview");
7049
7137
  const dependencies = input.dependencies ?? {};
@@ -7073,8 +7161,8 @@ var IntakeExecutionService = class {
7073
7161
  }
7074
7162
  concrete[field] = `00000000-0000-4000-8000-000000000000`;
7075
7163
  }
7076
- this.validate(handler.argsSchema, concrete, policy.maxBytes);
7077
- if (!(await handler.validate(input.args, context)).ok) throw new Error("Invalid handler arguments");
7164
+ this.validate(handler.argsSchema, concrete, policy.maxBytes, reviewed);
7165
+ if (!(await handler.validate(input.args, context)).ok) throw reviewed ? new HandlerArgumentsInvalidError("Invalid handler arguments") : /* @__PURE__ */ new Error("Invalid handler arguments");
7078
7166
  const preview = await handler.preview(input.args, context);
7079
7167
  if (canonical(preview.normalizedArgs) !== canonical(input.args)) throw new Error("Preview arguments must be normalized before publication");
7080
7168
  for (const target of preview.targetPreconditions) await context.assertTarget(target.model, target.id, target.revision);
@@ -7187,7 +7275,7 @@ var IntakeExecutionService = class {
7187
7275
  const frozen = JSON.parse(canonical(input));
7188
7276
  return this.tx(async (db) => {
7189
7277
  const item = await this.item(db, frozen.itemId, true);
7190
- const binding = await this.buildBinding(db, item, frozen);
7278
+ const binding = await this.buildBinding(db, item, frozen, true);
7191
7279
  return this.publish(db, item, frozen, binding);
7192
7280
  });
7193
7281
  }
@@ -7304,7 +7392,7 @@ var IntakeExecutionService = class {
7304
7392
  args: frozen.correctedArgs,
7305
7393
  dependencies: bound.binding.dependencies
7306
7394
  };
7307
- const binding = await this.buildBinding(db, bound.item, corrected);
7395
+ const binding = await this.buildBinding(db, bound.item, corrected, true);
7308
7396
  await this.feedbackLineage(db, bound);
7309
7397
  return this.publish(db, bound.item, corrected, binding);
7310
7398
  }
@@ -7803,8 +7891,8 @@ var IntakeExecutionService = class {
7803
7891
  const handler = this.handler(frozen.handlerId, frozen.handlerVersion);
7804
7892
  if (!("expand" in handler) || !("playbookKey" in handler.operation)) throw new Error("Playbook handler required");
7805
7893
  const { policy, context } = await this.access(db, item, handler, "preview");
7806
- this.validate(handler.argsSchema, frozen.args, policy.maxBytes);
7807
- if (!(await handler.validate(frozen.args, context)).ok) throw new Error("Invalid plan arguments");
7894
+ this.validate(handler.argsSchema, frozen.args, policy.maxBytes, true);
7895
+ if (!(await handler.validate(frozen.args, context)).ok) throw new HandlerArgumentsInvalidError("Invalid plan arguments");
7808
7896
  const preview = await handler.preview(frozen.args, context);
7809
7897
  if (canonical(preview.normalizedArgs) !== canonical(frozen.args) || Buffer.byteLength(canonical(preview)) > policy.maxBytes) throw new Error("Invalid plan preview");
7810
7898
  for (const target of preview.targetPreconditions) await context.assertTarget(target.model, target.id, target.revision);
@@ -8024,6 +8112,6 @@ async function continueIntakeReview(service, actionId, task) {
8024
8112
  return service.applyAction(actionId);
8025
8113
  }
8026
8114
  //#endregion
8027
- export { feedbackActionTransaction as a, __exportAll as c, resolveIntakePolicy as i, __toESM as l, continueIntakeReview as n, feedbackDiscoveryContext as o, intakeBindingDigest as r, require_ajv as s, IntakeExecutionService as t };
8115
+ export { feedbackActionTransaction as a, GenerationSnapshotStaleError as c, discoveryTransaction as d, generationSnapshotRead as f, __toESM as h, resolveIntakePolicy as i, GenerationSourceStaleError as l, __exportAll as m, continueIntakeReview as n, feedbackDiscoveryContext as o, listReadGate as p, intakeBindingDigest as r, require_ajv as s, IntakeExecutionService as t, HandlerArgumentsInvalidError as u };
8028
8116
 
8029
- //# sourceMappingURL=execution-NoDh3pjs.js.map
8117
+ //# sourceMappingURL=execution-9CfjxX8I.js.map