@happyvertical/smrt-ingestion 0.57.33 → 0.57.34

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 (50) hide show
  1. package/EXTRACTION.md +61 -1
  2. package/PROPOSALS.md +55 -2
  3. package/dist/chunks/{execution-BxkUOtLf.js → execution-DKWz2cz0.js} +14 -3
  4. package/dist/chunks/{execution-BxkUOtLf.js.map → execution-DKWz2cz0.js.map} +1 -1
  5. package/dist/chunks/{extraction-providers-C66ADDVe.js → extraction-providers-GOoo2Vfj.js} +141 -15
  6. package/dist/chunks/extraction-providers-GOoo2Vfj.js.map +1 -0
  7. package/dist/chunks/{feedback-D69e1hX5.js → feedback-DHcSKgVU.js} +3 -3
  8. package/dist/chunks/{feedback-D69e1hX5.js.map → feedback-DHcSKgVU.js.map} +1 -1
  9. package/dist/chunks/{proposal-contracts-CqVVPvqq.js → proposal-contracts-ClAXdqDF.js} +34 -4
  10. package/dist/chunks/proposal-contracts-ClAXdqDF.js.map +1 -0
  11. package/dist/chunks/{reviewer-instruction-Ip4W4f0j.js → reviewer-instruction-Deoe4NPv.js} +2 -2
  12. package/dist/chunks/{reviewer-instruction-Ip4W4f0j.js.map → reviewer-instruction-Deoe4NPv.js.map} +1 -1
  13. package/dist/execution-contracts.d.ts +4 -0
  14. package/dist/execution-contracts.d.ts.map +1 -1
  15. package/dist/execution.d.ts.map +1 -1
  16. package/dist/execution.js +1 -1
  17. package/dist/extraction-providers.d.ts +9 -1
  18. package/dist/extraction-providers.d.ts.map +1 -1
  19. package/dist/extraction-types.d.ts +23 -0
  20. package/dist/extraction-types.d.ts.map +1 -1
  21. package/dist/extraction-worker.js +6 -2
  22. package/dist/extraction-worker.js.map +1 -1
  23. package/dist/extraction.d.ts +5 -1
  24. package/dist/extraction.d.ts.map +1 -1
  25. package/dist/json-storage.d.ts +9 -0
  26. package/dist/json-storage.d.ts.map +1 -0
  27. package/dist/manifest.json +1 -1
  28. package/dist/models.js +1 -1
  29. package/dist/models.js.map +1 -1
  30. package/dist/observed-regions.d.ts +13 -0
  31. package/dist/observed-regions.d.ts.map +1 -0
  32. package/dist/proposal-contracts.d.ts +1 -0
  33. package/dist/proposal-contracts.d.ts.map +1 -1
  34. package/dist/proposal-dto.d.ts +3 -0
  35. package/dist/proposal-dto.d.ts.map +1 -1
  36. package/dist/proposal-sdk.d.ts.map +1 -1
  37. package/dist/proposal-validation.d.ts +3 -0
  38. package/dist/proposal-validation.d.ts.map +1 -1
  39. package/dist/proposals.d.ts +1 -1
  40. package/dist/proposals.d.ts.map +1 -1
  41. package/dist/proposals.js +61 -14
  42. package/dist/proposals.js.map +1 -1
  43. package/dist/server.d.ts +2 -0
  44. package/dist/server.d.ts.map +1 -1
  45. package/dist/server.js +28 -38
  46. package/dist/server.js.map +1 -1
  47. package/dist/smrt-knowledge.json +12 -12
  48. package/package.json +13 -13
  49. package/dist/chunks/extraction-providers-C66ADDVe.js.map +0 -1
  50. package/dist/chunks/proposal-contracts-CqVVPvqq.js.map +0 -1
package/EXTRACTION.md CHANGED
@@ -48,7 +48,46 @@ time, falling back to actual rendered-page OCR for empty pages. Embedded text
48
48
  is not evidence that every visual element was understood. TIFF is actually
49
49
  decoded page-by-page with sharp to PNG; each result cites its original TIFF page.
50
50
  Animated non-TIFF images are unsupported. Ordinary image OCR and scene vision
51
- are separately configured. Speech uses source-level text unless actual segment
51
+ are separately configured. Vision alone prepares an EXIF-oriented, full-frame
52
+ image inside a 2048-pixel edge without cropping or upscaling. Opaque inputs use
53
+ JPEG quality 85 (80 only when needed); alpha inputs retain transparency in PNG.
54
+ A 512 KiB encoded-image cap bounds base64 transport to about 700 KiB per image.
55
+ If neither high-quality JPEG encoding fits, or transparent PNG exceeds the cap,
56
+ extraction returns `limit` before a vision provider call. It never shrinks further,
57
+ drops a page, or silently flattens transparency. Original decode pixel limits,
58
+ native-memory isolation, deadlines and authorization apply before downsizing.
59
+ OCR, including PDF fallback, keeps its existing full-resolution PNG coordinates.
60
+
61
+ Trusted `visionImageLimits?: {maxEdge?, maxEncodedBytes?}` may tighten defaults
62
+ (edge 256–2048; encoded bytes 1024–524288). Adapter construction rejects expanded
63
+ or invalid limits. Use a new extraction configuration revision when adopting this
64
+ policy or changing its bounds. `imagePreparations` records `vision-image-v1`, the
65
+ bounds, source dimensions/orientation, derivative dimensions/format/quality/bytes
66
+ and source/page location. Evidence still identifies the unchanged retained bytes.
67
+ This is lossy provider preparation, not a claim that all text detail survives.
68
+ Small handwriting can become unreadable; the vision instruction requires honest
69
+ unreadable observations. Vision also separates printed questions/solved examples
70
+ from learner handwriting, preserves observed responses even when incorrect, and
71
+ reports matching lines only with visibly traceable endpoints. Unreadable or
72
+ uncertain responses/endpoints remain unknown; arithmetic solutions and expected
73
+ matches must not be reported as observations. The generic scene/text instruction,
74
+ untrusted-image instruction boundary and prohibition on actions still apply.
75
+ Observation text preserves visible sections/headings, columns/rows, task parts,
76
+ reading order, and their text/response associations. Unclear structure or reading
77
+ order is explicitly unknown; the prompt forbids invented layout, boxes,
78
+ coordinates, or verified geometry. A physical source page is identified only
79
+ when known, otherwise unknown; a visible printed page number is separate and
80
+ does not establish the physical source page. These are textual observations,
81
+ not a new structured generic layout contract. Assessment-specific consumers may
82
+ derive bounded advisory layout metadata from them under their own contracts.
83
+ Hosts adopting this observation prompt must use a new extraction configuration
84
+ revision; `vision-image-v1` versions image preparation, not prompt behavior.
85
+ Synthetic request tests verify these instructions reach the provider, not remote
86
+ recognition quality. Hosts must verify their intended model on representative
87
+ work and retain manual access to originals. No point weights or assessment
88
+ content may be invented to compensate for lost detail.
89
+
90
+ Speech uses source-level text unless actual segment
52
91
  timestamps are returned; absent speech confidence calibration is unknown.
53
92
 
54
93
  Confidence and boxes are explicitly null unless an OCR provider advertises and
@@ -133,3 +172,24 @@ truncation only. The adapter never bypasses the SDK to recover hidden fields.
133
172
  The missing SDK metadata is tracked in [happyvertical/ocr#144](https://github.com/happyvertical/ocr/issues/144).
134
173
  AI vision retains reported truncation when supplied by its SDK. Missing provider
135
174
  cost is unknown, not zero; no cost estimate is invented.
175
+
176
+ ### Optional observed image regions
177
+
178
+ Trusted SDK configuration `observeAnswerRegions: true` asks the SAME existing
179
+ vision request for JSON observations plus an optional bounded region catalog.
180
+ Default off preserves ordinary text observations. This prompt/protocol adoption
181
+ requires a new host configurationRevision (Hearth uses
182
+ `hearth-paper-v5-answer-regions`); no model change or extra automatic request.
183
+
184
+ Catalog rectangles are approximate direct visual observations, not verified boxes:
185
+ version1, coordinateSpace display-oriented, at most64 regions with short id/text
186
+ and finite normalized positive `[x,y,width,height]` inside the entire upright
187
+ EXIF-oriented uncropped image. Fit-inside resize preserves full-frame mapping;
188
+ never infer locations from columns/task numbers. Initial source images only,
189
+ not PDF raster fallback. Missing, uncertain or malformed catalog data is omitted
190
+ while valid observation text survives. A catalog that alone would exceed the
191
+ retained output byte budget is omitted. Existing total token/native/input limits
192
+ still apply; usage includes numeric vision_* counters when the provider reports
193
+ them. Tests prove exactly one SDK call and synthetic oriented alignment, not remote
194
+ model quality. imagePreparations records original orientation/dimensions and sent
195
+ format/dimensions/bytes; immutable source hashes/bytes remain unchanged.
package/PROPOSALS.md CHANGED
@@ -133,11 +133,16 @@ absent or no offered candidate matches. On required-only schema refusals, the
133
133
  validator computes the absent required set and corrects a mismatched model
134
134
  declaration; the instruction guides the model without making its declaration
135
135
  authoritative. Absent optional fields stay out
136
- of both `args` and `missingFields`. The model prefers `no_action` when no
136
+ of both `args` and `missingFields`, rather than being sent as null (unless the field explicitly permits null). Suggestion objects contain exactly the required envelope keys, with handler arguments nested only inside `args`. Alternatives mean genuinely competing OTHER choices, not a list of offered choices: use `[]` when none exist and never list the selected handler itself. The SDK response schema excludes that handler key from each suggestion variant while retaining other handler and candidate keys (#4395). Existing malformed or ambiguous outputs remain refused/pending; no self-alternative is stripped after generation. The model prefers `no_action` when no
137
137
  offered handler's description fits the document's role, and `unknown` when the
138
138
  evidence cannot be interpreted (#4290). Domain routing, such as which received
139
139
  documents an application ignores, belongs in host handler descriptions or
140
- reviewer guidance, not in this text. The text is not persisted. It is not part
140
+ reviewer guidance, not in this text. Keep these shared instructions concise: the
141
+ maintained reference host pins the complete SDK request to an 8 KiB wire/input
142
+ budget. That budget includes schema and transport overhead; adding repeated prose
143
+ can prevent a valid small request from reaching its provider. The frozen
144
+ evaluation checks the real envelope without raising its budget (#4395).
145
+ The text is not persisted. It is not part
141
146
  of the frozen interpretation configuration, the input, catalog or output
142
147
  digests, or the stored generation output, so a package release that changes it
143
148
  leaves stored attempts readable and previewable unchanged. New attempts send the
@@ -686,3 +691,51 @@ Interpretation output uses the exported `GenerationAnalysisOutput` wrapper at
686
691
  An explicit feedback `retrieve` denial omits optional examples and feedback
687
692
  provenance and continues generation. Item/execution denials, unexpected failures,
688
693
  and revocation after examples were selected still fail closed before disclosure.
694
+
695
+ ## Storage-safe provider text (#4393)
696
+
697
+ After the normal output-byte ceiling, generation validates decoded JSON object
698
+ keys and nested string values for PostgreSQL's unsupported NUL and unpaired
699
+ UTF-16 surrogate characters. A refusal is `malformed_output` with a fixed,
700
+ value-free reason, before either accepted or refused suggestion arguments can be
701
+ retained. Provider content is never stripped, repaired or treated as authority.
702
+ Literal backslash-u text and valid supplementary Unicode remain unchanged.
703
+
704
+ The generic `completeAnalysis` publication boundary independently checks the
705
+ whole result, including provider metadata and diagnostics. An invalid result
706
+ records the exact current fenced attempt as `needs_attention/malformed_output`
707
+ on the same authorized executor and completes its dispatch; it produces no
708
+ completed analysis, proposal or execution. Originals remain readable, and a
709
+ fresh authorized analysis revision can retry without rewriting the failed one.
710
+ Existing byte limits and current authority/fence checks still apply.
711
+
712
+ Optional failed-attempt capture uses the existing private, reviewer-authorized
713
+ host redaction policy. Unsupported generated JSON can be retained there as its
714
+ JSON-escaped diagnostic representation; it is never copied into a successful
715
+ proposal or returned in ordinary snapshot payloads. Without an enabled redactor,
716
+ no raw diagnostic text is retained. Shared foundation/proposal tests exercise
717
+ SQLite and actual PostgreSQL JSONB writes, invalid keys and values, lone high/low
718
+ surrogates, valid emoji/literal escapes, source retention, retry and capture policy.
719
+
720
+
721
+ ## Descriptive candidate context
722
+
723
+ A discovery candidate may include optional `context`, a plain JSON object of
724
+ untrusted descriptive data. It is never instructions or new authority. Keep the
725
+ label concise: context does not create extra entity choices. Validation rejects
726
+ non-JSON values, lossy coercions, unsafe Unicode, cycles, depth over32 and context
727
+ exceeding the existing `maxInputBytes`. The complete offered input still uses the
728
+ same total byte budget. Invalid authorized context fails closed; denied candidates
729
+ and their context never reach generation. Absent context preserves the old wire.
730
+
731
+ Context is snapshotted and included in the candidate key/digest and generator
732
+ contract. Hosts must bind any context changes to their current target revision;
733
+ current target checks retain their existing live executor/authorization boundary.
734
+ Education binds canonical same-capture prompt context to its target revision digest.
735
+
736
+ The engine exposes read-only `HandlerContext.analysisRevision` and forwards the
737
+ same current item revision to target authorization on its shared executor. This
738
+ pin comes from the owned intake row, not handler arguments, browser input or model
739
+ output. An owner may use it to avoid treating that generation's own materialized
740
+ result as an independent change to its input context; ordinary unrelated changes
741
+ and current authority/revision checks still invalidate stale snapshots.
@@ -6875,12 +6875,14 @@ var IntakeExecutionService = class IntakeExecutionService {
6875
6875
  db,
6876
6876
  scope: this.scope,
6877
6877
  itemId: String(item.id),
6878
+ analysisRevision: Number(item.analysis_revision),
6878
6879
  policy,
6879
6880
  assertTarget: async (model, targetId, revision) => {
6880
6881
  await this.config.assertTarget({
6881
6882
  db,
6882
6883
  scope: this.scope,
6883
6884
  itemId: String(item.id),
6885
+ analysisRevision: Number(item.analysis_revision),
6884
6886
  model,
6885
6887
  id: targetId,
6886
6888
  ...revision === void 0 ? {} : { revision }
@@ -6930,6 +6932,7 @@ var IntakeExecutionService = class IntakeExecutionService {
6930
6932
  db,
6931
6933
  scope: this.scope,
6932
6934
  itemId,
6935
+ analysisRevision: context.analysisRevision,
6933
6936
  model,
6934
6937
  id: id2
6935
6938
  })), requireReview);
@@ -7141,7 +7144,7 @@ var IntakeExecutionService = class IntakeExecutionService {
7141
7144
  if (!Array.isArray(references)) throw new Error("Feedback lineage unavailable");
7142
7145
  if (references.length === 0) return;
7143
7146
  if (!this.options.feedback) throw new Error("Feedback configuration unavailable");
7144
- const { IntakeFeedbackService } = await import("./feedback-D69e1hX5.js").then((n) => n.r);
7147
+ const { IntakeFeedbackService } = await import("./feedback-DHcSKgVU.js").then((n) => n.r);
7145
7148
  await new IntakeFeedbackService(this.options, this).assertActionLineage(String(bound.action.id), db, String(bound.proposal.id));
7146
7149
  }
7147
7150
  async getAction(actionId) {
@@ -7230,6 +7233,7 @@ var IntakeExecutionService = class IntakeExecutionService {
7230
7233
  db,
7231
7234
  scope: this.scope,
7232
7235
  itemId,
7236
+ analysisRevision: Number(bound.item.analysis_revision),
7233
7237
  model: target.model,
7234
7238
  id: target.id
7235
7239
  })).revision !== target.revision) {
@@ -7804,6 +7808,7 @@ var IntakeExecutionService = class IntakeExecutionService {
7804
7808
  db,
7805
7809
  scope: this.scope,
7806
7810
  itemId: String(item.id),
7811
+ analysisRevision: Number(item.analysis_revision),
7807
7812
  model,
7808
7813
  id: result[field]
7809
7814
  });
@@ -7834,6 +7839,7 @@ var IntakeExecutionService = class IntakeExecutionService {
7834
7839
  db,
7835
7840
  scope: this.scope,
7836
7841
  itemId: String(bound.item.id),
7842
+ analysisRevision: Number(bound.item.analysis_revision),
7837
7843
  model,
7838
7844
  id: result[field]
7839
7845
  });
@@ -8004,6 +8010,7 @@ var IntakeExecutionService = class IntakeExecutionService {
8004
8010
  db: this.db,
8005
8011
  scope: this.scope,
8006
8012
  itemId: String(send.bound.item.id),
8013
+ analysisRevision: Number(send.bound.item.analysis_revision),
8007
8014
  model,
8008
8015
  id: targetId,
8009
8016
  ...revision === void 0 ? {} : { revision }
@@ -8622,7 +8629,11 @@ var IntakeExecutionService = class IntakeExecutionService {
8622
8629
  ...this.config,
8623
8630
  assertTarget: async (target) => {
8624
8631
  try {
8625
- return await this.config.assertTarget(target);
8632
+ const item = await this.item(target.db, target.itemId);
8633
+ return await this.config.assertTarget({
8634
+ ...target,
8635
+ analysisRevision: Number(item.analysis_revision)
8636
+ });
8626
8637
  } catch {
8627
8638
  throw new IntakeAccessDeniedError();
8628
8639
  }
@@ -8718,4 +8729,4 @@ async function continueIntakeReview(service, actionId, task) {
8718
8729
  //#endregion
8719
8730
  export { __toESM as A, storedFailureCapture as C, generationSnapshotRead as D, discoveryTransaction as E, listReadGate as O, prepareFailureCapture as S, completeWithFailureCapture as T, HandlerArgumentsInvalidError as _, resolveIntakePolicy as a, FAILURE_CAPTURE_MAX_BYTES as b, HANDLER_ARGUMENT_ISSUE_LIMIT as c, schemaOwnedPath as d, require_ajv as f, GenerationSourceStaleError as g, GenerationSnapshotStaleError as h, intakeBindingDigest as i, __exportAll as k, HANDLER_ARGUMENT_PATH_LIMIT as l, redactedCeiling as m, IntakeExecutionService as n, feedbackActionTransaction as o, UNFINISHED_ACTION_STATES as p, continueIntakeReview as r, feedbackDiscoveryContext as s, IntakeAccessDeniedError as t, describeArgumentRefusal as u, ProposalsNotConfiguredError as v, analysisLeaseRemaining as w, assertFailureCapture as x, FAILURE_CAPTURE_DEFAULT_MAX_BYTES as y };
8720
8731
 
8721
- //# sourceMappingURL=execution-BxkUOtLf.js.map
8732
+ //# sourceMappingURL=execution-DKWz2cz0.js.map