@kontourai/survey 0.5.2 → 0.7.0

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.
package/README.md CHANGED
@@ -89,16 +89,29 @@ One observation, one chain: the page it came from, what the extractor read, who
89
89
 
90
90
  ## The producer validation path
91
91
 
92
- 1. Build Survey observations with source, extraction, candidate, review, and claim records.
92
+ 1. Build Survey observations covering each link in the evidence chain.
93
93
  2. Call `buildSurveyTrustBundle` to project the Survey records into a Surface Trust Bundle.
94
94
  3. Call Surface `validateTrustBundle` on the Trust Bundle.
95
95
  4. Optionally call public Surface report APIs such as `buildTrustReport` to inspect claims, evidence, status, gaps, and metadata.
96
96
 
97
- Keep producer operational state outside Survey. Queue status, reviewer form state, retries, source caches, and product policy decisions belong in the producer's own data model. Survey carries only the portable source, extraction, candidate, review, and claim projection records needed by Surface.
97
+ Keep producer operational state outside Survey. Queue status, reviewer form state, retries, source caches, and product policy decisions belong in the producer's own data model. Survey carries only the portable evidence chain records needed by Surface.
98
98
 
99
99
  ## Review Workbench embed
100
100
 
101
- For downstream products that already produce `ReviewItem` queues:
101
+ **Web component** (shadow DOM, no framework required):
102
+
103
+ ```html
104
+ <link rel="stylesheet" href="@kontourai/survey/review-workbench/standalone.css">
105
+ <survey-review-workbench theme="survey" color-scheme="dark"></survey-review-workbench>
106
+ <script type="module">
107
+ import "@kontourai/survey/review-workbench/element";
108
+ const el = document.querySelector("survey-review-workbench");
109
+ el.session = reviewQueueSession;
110
+ el.presentationAdapter = myAdapter;
111
+ </script>
112
+ ```
113
+
114
+ **Direct mount** into an existing element:
102
115
 
103
116
  ```ts
104
117
  import {
@@ -117,15 +130,29 @@ const presentationAdapter = {
117
130
  mountReviewWorkbench(element, reviewQueueSession, { presentationAdapter });
118
131
  ```
119
132
 
120
- The stylesheet is scoped to `.survey-workbench-embed` and bundles the Console Kit tokens it needs, so it will not rewrite the host application's `body` or `:root` styles. Mount into:
133
+ The embedded stylesheet is scoped to `.survey-workbench-embed` and bundles Console Kit tokens, so it will not rewrite the host application's `body` or `:root` styles. Mount into:
121
134
 
122
135
  ```html
123
136
  <div class="survey-workbench-embed theme-survey"></div>
124
137
  ```
125
138
 
126
- `@kontourai/survey/review-workbench/standalone.css` exists for pages Survey owns entirely. Server code persisting browser-submitted review events should use `persistReviewSessionEvents`, then `deriveReviewSessionApplyResultForSnapshot` (or the composed `deriveServerReviewSessionApplyResult` with the freshness and event assertions from `@kontourai/survey/review-workbench/server-review-session`) before applying product policy — write results derive from pre-decision snapshots plus persisted events, never from browser-computed decisions.
139
+ `@kontourai/survey/review-workbench/standalone.css` exists for pages Survey owns entirely.
140
+
141
+ ## Review MCP
142
+
143
+ Drive review-queue decisions from an MCP agent (Claude Desktop, Cursor, or any MCP host):
144
+
145
+ ```sh
146
+ npx survey-review-mcp --session path/to/session.json
147
+ ```
148
+
149
+ Three tools: `survey_review_queue` (queue state), `survey_review_item` (item detail), and `survey_review_decide` (record a decision). Each queue and item call includes an embedded, fully self-contained review card with Accept / Hold / Reject buttons. See [docs/review-mcp.md](docs/review-mcp.md).
150
+
151
+ At viewports ≤ 980 px, the queue panel becomes a slide-in drawer with a compact progress bar. At narrow container widths, `cqi`-based type scaling keeps candidate values from overflowing at 360 px. CSS custom properties (`--k-*`) inherit through the shadow boundary so the host can theme either mode without forking styles.
152
+
153
+ Server code persisting browser-submitted review events should use `persistReviewSessionEvents`, then `deriveReviewSessionApplyResultForSnapshot` (or the composed `deriveServerReviewSessionApplyResult` from `@kontourai/survey/review-workbench/server-review-session`) before applying product policy — write results derive from pre-decision snapshots plus persisted events, never from browser-computed decisions.
127
154
 
128
- The [Consumer Integration Guide](docs/consumer-integration-guide.md) covers the full path from `ReviewItem` construction through persisted review events, exported results, and optional Surface projection, with test-covered examples under [`examples/review-workbench/`](examples/review-workbench/).
155
+ The [Consumer Integration Guide](docs/consumer-integration-guide.md) covers the full path from `ReviewItem` construction through persisted review events, exported results, Surface projection, and the full `--k-*` theming token list. Test-covered examples are under [`examples/review-workbench/`](examples/review-workbench/). To run the standalone demo locally, see [Review Workbench Prototype](docs/review-workbench-prototype.md).
129
156
 
130
157
  ## Where Survey fits
131
158
 
@@ -155,7 +182,7 @@ Survey feeds Surface; Surface-shaped evidence feeds Flow gates; Flow's adversari
155
182
 
156
183
  ## Product boundary
157
184
 
158
- Survey does not crawl pages, parse PDFs, rank candidates, decide review policy, or claim a value is true. Producers own acquisition, extraction, ranking, review UX, materiality, and domain policy. Survey gives those producers a consistent source → extraction → candidate → review → claim contract before the records enter Surface.
185
+ Survey does not crawl pages, parse PDFs, rank candidates, decide review policy, or claim a value is true. Producers own acquisition, extraction, ranking, review UX, materiality, and domain policy. Survey gives those producers a consistent evidence chain contract before the records enter Surface.
159
186
 
160
187
  ## Contributor checks
161
188
 
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { runReviewMcp } from "../dist/src/mcp/review-mcp.js";
3
+
4
+ runReviewMcp(process.argv.slice(2)).catch((error) => {
5
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
6
+ process.exitCode = 1;
7
+ });
@@ -33,3 +33,5 @@ export { mappingReviewToSurface, referenceSchemaExtractor, surveySchemaMapping,
33
33
  export type { MappingProposalRecord, ReviewedMapping, SchemaMappingExtractor, SchemaMappingOptions, SystemFieldRef, } from "./schema-mapping.js";
34
34
  export { buildAuthorizedActionAuthorizing, isValidAuthorizing, validateAuthorizing } from "./review-authorizing.js";
35
35
  export type { BuildAuthorizedActionAuthorizingInput, ReviewAuthorizingIssue, ReviewAuthorizingIssueCode, } from "./review-authorizing.js";
36
+ export { deriveOversightMetrics, mergeTrustBundleWithOversightMetrics, oversightMetricsToClaims, } from "./oversight-metrics.js";
37
+ export type { AggregateOversightMetrics, DeriveOversightMetricsOptions, OversightMetrics, OversightMetricsClaimsSubject, OversightQualityClaim, ReviewerOversightMetrics, } from "./oversight-metrics.js";
package/dist/src/index.js CHANGED
@@ -15,3 +15,4 @@ export { applyAutoAcceptPolicy, applyMappingReview, buildMappingReviewItems, loo
15
15
  export { referenceUtteranceExtractor, surveyAgentUtterance, utteranceToSurveyInput, } from "./agent-utterance.js";
16
16
  export { mappingReviewToSurface, referenceSchemaExtractor, surveySchemaMapping, } from "./schema-mapping.js";
17
17
  export { buildAuthorizedActionAuthorizing, isValidAuthorizing, validateAuthorizing } from "./review-authorizing.js";
18
+ export { deriveOversightMetrics, mergeTrustBundleWithOversightMetrics, oversightMetricsToClaims, } from "./oversight-metrics.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { runReviewMcp } from "./review-mcp.js";
2
+ await runReviewMcp(process.argv.slice(2));
@@ -0,0 +1 @@
1
+ export declare function runReviewMcp(args: string[]): Promise<void>;