@schift-io/knowledge-scope 0.1.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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +387 -0
  3. package/dist/context-pack.js +4771 -0
  4. package/dist/index.js +8044 -0
  5. package/dist/main.js +7550 -0
  6. package/dist/types/adapters/evidence-policy.d.ts +3 -0
  7. package/dist/types/adapters/gates.d.ts +13 -0
  8. package/dist/types/adapters/http-policy.d.ts +10 -0
  9. package/dist/types/adapters/open-connector.d.ts +20 -0
  10. package/dist/types/adapters/provider-port.d.ts +27 -0
  11. package/dist/types/adapters/response.d.ts +12 -0
  12. package/dist/types/adapters/schift-search-headers.d.ts +2 -0
  13. package/dist/types/adapters/schift-search-identity.d.ts +14 -0
  14. package/dist/types/adapters/schift-search.d.ts +17 -0
  15. package/dist/types/adapters/types.d.ts +136 -0
  16. package/dist/types/api-contract.d.ts +164 -0
  17. package/dist/types/api.d.ts +30 -0
  18. package/dist/types/application-batch.d.ts +4 -0
  19. package/dist/types/application-execution.d.ts +30 -0
  20. package/dist/types/application.d.ts +47 -0
  21. package/dist/types/authorization.d.ts +228 -0
  22. package/dist/types/cli-options.d.ts +6 -0
  23. package/dist/types/cli.d.ts +24 -0
  24. package/dist/types/client-error.d.ts +5 -0
  25. package/dist/types/client-validation.d.ts +8 -0
  26. package/dist/types/client.d.ts +18 -0
  27. package/dist/types/context-pack/bounded-json.d.ts +3 -0
  28. package/dist/types/context-pack/canonical.d.ts +12 -0
  29. package/dist/types/context-pack/index.d.ts +73 -0
  30. package/dist/types/context-pack/knowledge-scope-admission.d.ts +23 -0
  31. package/dist/types/context-pack/knowledge-scope-batch.d.ts +85 -0
  32. package/dist/types/context-pack/knowledge-scope-execution.d.ts +297 -0
  33. package/dist/types/context-pack/knowledge-scope-lock.d.ts +71 -0
  34. package/dist/types/context-pack/knowledge-scope-mount.d.ts +1094 -0
  35. package/dist/types/context-pack/knowledge-scope.d.ts +1843 -0
  36. package/dist/types/context-pack/scalars.d.ts +13 -0
  37. package/dist/types/doctor-config.d.ts +6 -0
  38. package/dist/types/doctor.d.ts +7 -0
  39. package/dist/types/errors.d.ts +8 -0
  40. package/dist/types/evaluation/contracts.d.ts +718 -0
  41. package/dist/types/evaluation.d.ts +20 -0
  42. package/dist/types/index.d.ts +26 -0
  43. package/dist/types/json.d.ts +17 -0
  44. package/dist/types/limits.d.ts +10 -0
  45. package/dist/types/main.d.ts +10 -0
  46. package/dist/types/onboarding-config.d.ts +9 -0
  47. package/dist/types/portable.d.ts +14 -0
  48. package/dist/types/quickstart.d.ts +10 -0
  49. package/dist/types/schema-subset.d.ts +9 -0
  50. package/dist/types/state-contract.d.ts +2867 -0
  51. package/dist/types/state-store.d.ts +29 -0
  52. package/docs/PILOT.md +184 -0
  53. package/examples/batch-consumer.mjs +19 -0
  54. package/examples/consumer.mjs +17 -0
  55. package/examples/evaluation/README.md +34 -0
  56. package/examples/evaluation/run.mjs +21 -0
  57. package/examples/evaluation/synthetic.json +59 -0
  58. package/examples/mount-bindings.json +31 -0
  59. package/examples/support-scope/schemas/query-input.json +6 -0
  60. package/examples/support-scope/schemas/result-row.json +6 -0
  61. package/examples/support-scope/scope.json +48 -0
  62. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # Schift Knowledge Scope CE
2
+
3
+ Connect an existing Schift Search index to your AI application and return cited evidence within
4
+ one project's declared access boundary. Your application chooses the model and generates the answer.
5
+
6
+ Start with the [first retrieval](#quickstart), then use the SDK in your application. For a customer
7
+ trial, follow the [pilot guide](docs/PILOT.md), which separates local verification from live-customer
8
+ acceptance.
9
+
10
+ ```text
11
+ scope.json + schema files
12
+ │ validate + lock
13
+
14
+ portable KnowledgeScopeDefinition
15
+ │ mount
16
+
17
+ server-owned KnowledgeScopeMount
18
+ │ declared operation only
19
+
20
+ Open Connector / Schift Search / injected records port
21
+ │ normalize + authorize + admit
22
+
23
+ CandidateEnvelope[] + admission receipt
24
+ ```
25
+
26
+ ## What is implemented
27
+
28
+ - [x] Portable Definition and server-owned Mount are separate contracts.
29
+ - [x] The lock covers canonical `scope.json` plus every referenced input/result schema.
30
+ - [x] Local mount state uses owner-only, atomic file persistence and optimistic revisions.
31
+ - [x] Authorization decisions HMAC-bind the complete immutable Candidate evidence projection and
32
+ survive process restarts.
33
+ - [x] Open Connector executes declared actions through its public runtime API.
34
+ - [x] Schift Search uses the authenticated v2 status + retrieve APIs.
35
+ - [x] Direct named-record execution is available through an injected application port.
36
+ - [x] Candidate admission checks source, operation, provider, permission mode, Scope, citation,
37
+ freshness, connector audit correlation, and required provider scopes.
38
+ - [x] Aggregate admission enforces every declared `minEvidence` coverage assertion.
39
+ - [x] `run-batch` combines up to eight declared operations under one mount and admits their evidence together.
40
+ - [x] CLI and loopback HTTP API use the same application and persistent state.
41
+ - [ ] npm publication, Schift Cloud multi-tenant persistence, production deployment, and live
42
+ provider-account certification. Those are separate operational actions.
43
+
44
+ OBS, Context Runtime/A2A, APM, Agent execution, Workflow execution, and final LLM generation are
45
+ deliberately outside this package.
46
+
47
+ ## Quickstart
48
+
49
+ You need Node.js 20 or later, a package tarball, and an **already indexed** Schift Search corpus.
50
+ Obtain the Search endpoint, authorized token, organization ID, and index name from its owner.
51
+ This package does not upload, parse, or index your documents. A new empty index will not produce
52
+ usable evidence.
53
+
54
+ Until npm publication is completed, install the supplied artifact in your application directory.
55
+ Replace the path with the actual tarball; do not assume the registry package is available:
56
+
57
+ ```bash
58
+ npm install /absolute/path/to/schift-io-knowledge-scope-0.1.0.tgz
59
+ npx --no-install schift-ks --help
60
+ ```
61
+
62
+ Keep credentials in your local runtime environment. The values below are placeholders, not demo
63
+ credentials:
64
+
65
+ ```bash
66
+ export SCHIFT_KS_SEARCH_URL=https://api.schift.io
67
+ export SCHIFT_KS_SEARCH_TOKEN='<authorized Search token>'
68
+ export SCHIFT_KS_SEARCH_ORGANIZATION_ID='<your organization ID>'
69
+ export SCHIFT_KS_SEARCH_SCOPES=search:read
70
+ ```
71
+
72
+ Create a new workspace and retrieve evidence. Replace `support-handbook` and `tenant.acme` with
73
+ the authorized index and project tenant. The destination must not already exist:
74
+
75
+ ```bash
76
+ npx --no-install schift-ks quickstart ./support-project \
77
+ --index support-handbook --tenant tenant.acme \
78
+ --query 'How do I reset a subscription?'
79
+ ```
80
+
81
+ The command creates portable files in `support-project/pack/`, with local `bindings.json`,
82
+ `input.json`, and `installation.json` beside that directory. It locks, mounts, and runs the `search`
83
+ operation. Save the returned `installationId`. `result.status: "ready"` means admitted evidence is
84
+ available; `"insufficient_evidence"` means the application must not answer from these results.
85
+ The outer `status: "completed"` reports completion of the command, not evidence sufficiency.
86
+
87
+ Check the installation without a provider request, or explicitly probe it with another question:
88
+
89
+ ```bash
90
+ npx --no-install schift-ks doctor '<installation-id>'
91
+ npx --no-install schift-ks doctor '<installation-id>' --probe --query 'How do I reset a subscription?'
92
+ ```
93
+
94
+ The default doctor report has `evidenceVerified: false`; `configured` does not certify live
95
+ retrieval. A probe executes the normal read path and may consume provider usage. On a run failure,
96
+ quickstart preserves the workspace and reports a recovery command rather than overwriting it.
97
+ If filesystem setup failed, `artifactsComplete: false` means the workspace needs inspection and
98
+ validation before mounting; the recovery command does not claim that incomplete files are ready.
99
+
100
+ ## Use the evidence in your application
101
+
102
+ The installed package includes a consumer that uses the same local state and provider environment:
103
+
104
+ ```bash
105
+ node node_modules/@schift-io/knowledge-scope/examples/consumer.mjs \
106
+ '<installation-id>' tenant.acme 'How do I reset a subscription?' search
107
+ ```
108
+
109
+ It prints the typed result, exits with code 3 for insufficient evidence, and never calls a model.
110
+ In your application, `createKnowledgeScopeClient({ application })` exposes `inspect(installationId)`,
111
+ `run(request)`, `runBatch(request)`, and `admit(request)`. Inject `createCliDependencies().embedded` for the local
112
+ application or a `createRemoteKnowledgeScopeApplication` instance for the authenticated HTTP API.
113
+ The client validates response contracts and identity; the application remains responsible for
114
+ authorization and HMAC verification.
115
+
116
+ Only pass `result.candidates` to downstream processing when `result.status === "ready"`. Preserve
117
+ each candidate's citation when assembling context. Your model, prompt, and answer UI remain yours.
118
+
119
+ For offline retrieval measurements, see the [evaluation example](examples/evaluation/README.md)
120
+ and the [pilot metric definitions](docs/PILOT.md#measure-a-useful-outcome). The included dataset is
121
+ synthetic and makes no accuracy claim about a live provider.
122
+
123
+ ## Manual authoring
124
+
125
+ For a complete editable definition, copy the shipped support example into a new directory from
126
+ your application root. This example declares `search-handbook`, `fetch-support`, and `list-orders`;
127
+ the matching bindings name those exact operations:
128
+
129
+ ```bash
130
+ mkdir ./manual-support
131
+ cp -R node_modules/@schift-io/knowledge-scope/examples/support-scope ./manual-support/pack
132
+ cp node_modules/@schift-io/knowledge-scope/examples/mount-bindings.json ./manual-support/bindings.json
133
+ ```
134
+
135
+ In `manual-support/bindings.json`, replace `replace-with-organization` with the same organization
136
+ as `SCHIFT_KS_SEARCH_ORGANIZATION_ID`, and replace `replace-with-tenant` with your tenant. The sample
137
+ Search index is `support-handbook`; if yours differs, change both the capability's `indexRef` in
138
+ `pack/scope.json` and its Search binding's `providerRef` in `bindings.json` to your index name.
139
+ These files contain references, never credentials.
140
+
141
+ ```bash
142
+ npx --no-install schift-ks validate ./manual-support/pack
143
+ npx --no-install schift-ks lock ./manual-support/pack
144
+ npx --no-install schift-ks mount ./manual-support/pack --bindings ./manual-support/bindings.json
145
+ npx --no-install schift-ks inspect '<installation-id>'
146
+ ```
147
+
148
+ Use the returned installation ID in subsequent commands. Mounting records and connector bindings
149
+ does not configure their executors; running those two operations requires the separate provider
150
+ configuration described below. The Search operation can run independently.
151
+
152
+ When a definition declares capabilities, every supplied binding must name at least one coherent
153
+ operation and at least one declared capability must be bound. Other provider-specific capabilities
154
+ may remain unbound and fail with `operation_not_bound` if called. A zero-capability, document-only
155
+ definition may still mount with an empty operation list.
156
+
157
+ Save this strict JSON document as `manual-support/run.json`. Replace `replace-with-tenant` with
158
+ the **same value** used in `bindings.json`; this is not an additional access boundary:
159
+
160
+ ```json
161
+ {
162
+ "effectiveScope": {"tenant": "replace-with-tenant"},
163
+ "input": {"query": "How do I reset a subscription?"},
164
+ "filters": {},
165
+ "expectedRevision": 1
166
+ }
167
+ ```
168
+
169
+ ```bash
170
+ npx --no-install schift-ks run '<installation-id>' search-handbook --input ./manual-support/run.json
171
+ ```
172
+
173
+ To stop using the mount, inspect its current revision and pass that revision to
174
+ `schift-ks unmount '<installation-id>' --expected-revision <revision>`.
175
+
176
+ `schift-ks init <new-directory>` is a separate authoring tool: it creates an empty skeleton with
177
+ no capabilities. Before attaching an operation binding, declare that operation and its referenced
178
+ schemas yourself. Do not attach the shipped example's operation bindings to the empty skeleton.
179
+
180
+ `admit` accepts either one Candidate object or a nonempty JSON array. Use an array to evaluate
181
+ already available Candidates as one aggregate coverage set:
182
+
183
+ ```bash
184
+ npx --no-install schift-ks admit '<installation-id>' --candidate ./candidates.json
185
+ ```
186
+
187
+ Each `run` executes one operation against the full Scope policy and withholds all Candidates when
188
+ coverage is insufficient. To retrieve documents and records together, declare separate required
189
+ coverage rules for `document` and `records`, then call `run-batch` with both operations:
190
+
191
+ ```json
192
+ {
193
+ "effectiveScope": {"tenant": "replace-with-tenant"},
194
+ "expectedRevision": 1,
195
+ "operations": [
196
+ {"operationId": "search-handbook", "input": {"query": "What is the shipping policy?"}},
197
+ {"operationId": "fetch-support", "input": {"query": "Order 123 status"}}
198
+ ]
199
+ }
200
+ ```
201
+
202
+ Save this as `batch.json`, with inputs matching your declared schemas and a current mount revision:
203
+
204
+ ```bash
205
+ npx --no-install schift-ks run-batch '<installation-id>' --input ./batch.json
206
+ node node_modules/@schift-io/knowledge-scope/examples/batch-consumer.mjs '<installation-id>' ./batch.json
207
+ ```
208
+
209
+ The shipped support Pack is a schema example; it does not already require both classes. For a
210
+ combined policy, add two `mustConsider` rules and list both IDs in `evidence.coverageAssertions`.
211
+ Bind the actual record operation as `sourceClass: "records"`; the sample helpdesk binding is
212
+ `activity_stream` and must not be relabeled unless its source really supplies records.
213
+
214
+ Batch requests contain 1–8 unique operation IDs. All inputs and bindings are validated before
215
+ provider dispatch; execution is sequential, with a combined ceiling of 100 Candidates and 8 MiB.
216
+ Admission rechecks the current mount before releasing the combined evidence. A failed operation or
217
+ unsatisfied policy releases no partial Candidate payload. Separate insufficient runs cannot be
218
+ accumulated through `admit`, because those runs withhold their Candidates.
219
+ Every requested operation must contribute evidence. Even if the remaining operations satisfy
220
+ coverage, an empty operation fails with `batch_incomplete`; rejected Candidates fail with
221
+ `candidate_invalid`. Neither error includes partial evidence.
222
+
223
+ This is atomic admission and output, not a shared transaction or synchronized snapshot across
224
+ external providers. Each source retains its own revision and freshness. Python provides matching
225
+ request contracts and pure admission checks; this package's execution runtime and CLI are Node.js.
226
+ See the [combined pilot path](docs/PILOT.md#extend-to-documents-plus-live-records).
227
+
228
+ All successful output is JSON on stdout. Errors are redacted JSON on stderr with a stable `code`
229
+ and a non-zero exit status.
230
+
231
+ ## Provider configuration
232
+
233
+ Provider URLs and credentials are runtime configuration. They are never written to `scope.json`,
234
+ the lock, mount state, Candidate output, or errors.
235
+
236
+ Open Connector is the product in `core-dependencies/schift-connector`; it owns account connections,
237
+ credentials, and its public action runtime. Configure its endpoint:
238
+
239
+ ```bash
240
+ export SCHIFT_KS_OPEN_CONNECTOR_URL=http://127.0.0.1:3000
241
+ export SCHIFT_KS_OPEN_CONNECTOR_TOKEN=...
242
+ export SCHIFT_KS_OPEN_CONNECTOR_SCOPES=tickets:read
243
+ export SCHIFT_KS_OPEN_CONNECTOR_ALIAS=work
244
+ export SCHIFT_KS_OPEN_CONNECTOR_READ_ACTIONS='[{"connectorRef":"zendesk","connectorAlias":"work","actionId":"zendesk.search_tickets"}]'
245
+ ```
246
+
247
+ `SCHIFT_KS_OPEN_CONNECTOR_READ_ACTIONS` is a strict server-owned JSON allowlist of connector,
248
+ account alias, and action triples. A Pack cannot authorize its own action or select a different
249
+ account with the same action ID; any triple not explicitly attested as retrieval-only is rejected
250
+ before HTTP.
251
+ The generic Open Connector adapter never drops an allowed filter or narrower Scope silently.
252
+ Nonempty filters and `namespace` / `subject` / `session` Scope require an injected trusted input
253
+ mapper in the SDK; without one, execution fails before HTTP. The mapper receives trusted Scope and
254
+ must bind it into the provider-native, schema-validated action input. Tenant-only calls may use the
255
+ mounted connector/account boundary directly.
256
+
257
+ Schift Search:
258
+
259
+ ```bash
260
+ export SCHIFT_KS_SEARCH_URL=https://api.schift.io
261
+ export SCHIFT_KS_SEARCH_TOKEN=...
262
+ export SCHIFT_KS_SEARCH_ORGANIZATION_ID=org.acme
263
+ export SCHIFT_KS_SEARCH_SCOPES=search:read
264
+ ```
265
+
266
+ The Schift Search adapter first reads `/v2/buckets/{index}/search/status`, then retrieves passages
267
+ from `/v2/buckets/{index}/retrieve`. Missing source identity, revision, citation, or freshness fails
268
+ closed. The credential-bound organization ID must match the mounted organization and is sent as
269
+ `X-Org-Id`, so the Search API's normal organization/bucket ACL remains authoritative. The local
270
+ tenant/effective Scope is an additional Schift KS constraint; it is not presented as a provider
271
+ tenant attestation. The adapter never falls back to another index or to Web search.
272
+ The current v2 Search API does not enforce `namespace`, `subject`, or `session` narrowing, so this
273
+ adapter rejects those requests before HTTP. Use an appropriately scoped bucket and installation
274
+ for separate access boundaries; adding an arbitrary Scope field does not filter provider data.
275
+
276
+ For `records_operation`, library consumers inject the named-operation executor through the public
277
+ provider port. The default CLI does not invent SQL, accept raw predicates, or hold database
278
+ credentials; an unconfigured records operation returns `invalid_configuration`. Open Connector may
279
+ also be used as the managed database gateway.
280
+
281
+ `web_search` remains a portable provider declaration for compatible runtimes, but the local CE
282
+ control plane does not silently choose or bill a Web provider in v0.1. It fails closed with
283
+ `invalid_configuration`; applications can use Schift Search, Open Connector, or an injected records
284
+ port until a separately governed Web-search adapter is installed.
285
+
286
+ ## Local HTTP API
287
+
288
+ Start the same application as a loopback service:
289
+
290
+ ```bash
291
+ export SCHIFT_KS_ORGANIZATION_ID=org.acme
292
+ export SCHIFT_KS_TENANT=tenant.acme
293
+ export SCHIFT_KS_API_TOKEN='<random owner-only token>'
294
+ node dist/main.js serve --host 127.0.0.1 --port 8787
295
+ ```
296
+
297
+ Routes:
298
+
299
+ - `POST /v1/knowledge-scopes/mounts`
300
+ - `GET /v1/knowledge-scopes/mounts/{installationId}`
301
+ - `POST /v1/knowledge-scopes/mounts/{installationId}/unmount`
302
+ - `POST /v1/knowledge-scopes/mounts/{installationId}/capabilities/{operationId}:run`
303
+ - `POST /v1/knowledge-scopes/mounts/{installationId}:run-batch`
304
+ - `POST /v1/knowledge-scopes/mounts/{installationId}:admit`
305
+
306
+ The HTTP mount body cannot choose organization or tenant; the server injects them from trusted
307
+ configuration. Mutating requests require `application/json`, and cross-origin browser requests are
308
+ rejected.
309
+
310
+ The local HTTP server always requires `SCHIFT_KS_API_TOKEN`, including on loopback, and validates
311
+ the literal loopback Host to prevent DNS rebinding. Direct non-loopback binding is not supported in
312
+ v0.1 because the built-in server is plain HTTP. The same token is sent by
313
+ `schift-ks ... --api-url <url>`; non-loopback remote URLs must use HTTPS. The token is never
314
+ persisted or printed. Production exposure should terminate TLS and apply network policy at an
315
+ authenticated reverse proxy that forwards only to the loopback listener, or use a Schift Cloud
316
+ adapter.
317
+
318
+ ## Portable files and schema subset
319
+
320
+ The portable directory contains exactly:
321
+
322
+ - `scope.json`
323
+ - every relative `inputSchemaRef` and `resultSchemaRef`
324
+ - generated `scope.lock.json`
325
+
326
+ Symlinks, absolute paths, backslashes, `..`, duplicate JSON keys, missing files, and every undeclared
327
+ regular file are rejected. `.schift/` is local state and is never locked or packed; README, license,
328
+ credential, PDF, and raw-data files belong outside the portable Scope directory.
329
+
330
+ The dependency-free schema validator supports:
331
+
332
+ `type`, `properties`, `required`, `additionalProperties` (boolean), `items`, `enum`, `const`,
333
+ `minLength`, `maxLength`, `minimum`, `maximum`, `minItems`, and `maxItems`.
334
+
335
+ `$ref`, composition keywords, conditionals, formats, unknown keywords, and schema/value nesting
336
+ beyond 16 levels fail with `unsupported_schema_keyword` or `schema_depth_exceeded`.
337
+ Portable schema numbers are restricted to the cross-runtime safe-integer range. Integral spellings
338
+ such as `1`, `1.0`, and `1e0` normalize to one lock value; fractional and unsafe integers are
339
+ rejected instead of producing different TypeScript/Python digests.
340
+
341
+ ## State and trust guarantees
342
+
343
+ - `SCHIFT_KS_HOME` defaults to `~/.schift/knowledge-scope`.
344
+ - Directories are mode `0700`; state and the separate 32-byte authorization key are mode `0600`.
345
+ - State uses same-directory temp files, fsync, atomic rename, and an exclusive process lock.
346
+ - State is capped at 16 MiB and is parsed with the same byte/depth/node ceilings before and after
347
+ every atomic write, so a successful mount cannot make the next read invalid.
348
+ - Lock recovery is intentionally fail-closed. If a process crashes while holding `state.lock`, the
349
+ owner must verify the recorded PID is gone before manually removing that lock file; the product
350
+ never auto-deletes a possibly live writer's lock.
351
+ - Unmount preserves a tombstone, removes active bindings, and increments mount revision.
352
+ - Replacing the authorization key intentionally invalidates outstanding Candidates.
353
+ - Provider output cannot set installation, authority, Scope, Pack digest, permission mode, or the
354
+ authorization decision. The HMAC covers SRN, revision, freshness, payload, citation, provider
355
+ scopes/evidence, mounted permission, and every Scope/binding identity used by admission.
356
+ - A denied or incomplete run returns no Candidate payloads.
357
+
358
+ ## Verification
359
+
360
+ From a clean repository checkout, use the canonical verification command. It installs dependencies
361
+ inside a temporary copy before building and testing:
362
+
363
+ ```bash
364
+ cd packages/knowledge-scope-cli
365
+ bun run release:verify
366
+ ```
367
+
368
+ For an already provisioned development workspace, these individual checks are also available.
369
+ They require its dependencies, including TypeScript, to have been installed:
370
+
371
+ ```bash
372
+ bun run build
373
+ bun run typecheck
374
+ bun test
375
+ node dist/main.js --help
376
+ ```
377
+
378
+ The repository E2E suite executes Open Connector and Schift Search against local fake HTTP
379
+ providers. Release verification additionally dry-packs the artifact, audits its file inventory,
380
+ installs it in an empty temporary project, and repeats the portable lifecycle from that installed
381
+ artifact. `release:verify` performs these checks in an isolated temporary copy with its own
382
+ dependencies and writes a tarball, SHA-256 checksum, and `release-report.json` to the reported
383
+ temporary directory. It does not publish a package or deploy a service.
384
+
385
+ Local fake-provider tests verify software contracts. They do not certify a customer's Search
386
+ index, connector account, access policy, or retrieval quality. Use the [pilot gates](docs/PILOT.md#external-pilot-gates)
387
+ for those checks.