@shieldaai/agent-map 0.0.0-stage → 0.1.0-alpha.2

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/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 2026 ShieldaAI contributors
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 CHANGED
@@ -1,3 +1,308 @@
1
- # Temporary Holding Version
1
+ # Agent Guard reference map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Optional read-only reference service for the immutable Agent Guard projections
4
+ published by the [Cartography collector](../../integrations/cartography/README.md).
5
+ It supplies the same evidence to HTTP, MCP clients and the
6
+ [React/Cytoscape viewer](../../apps/agent-map/README.md). It never prepares or
7
+ executes an action. Declared grants and cloud associations are not effective
8
+ permission decisions.
9
+
10
+ Install the service with `npm install @shieldaai/agent-map@alpha`. It includes the
11
+ `agent-guard-map` and `agent-guard-map-identity` commands. Viewer assets and the
12
+ Python collector are separate repository components and are not bundled in this
13
+ npm package. The commands require host-owned configuration and credentials.
14
+
15
+ ## Run the loopback bearer service
16
+
17
+ ```sh
18
+ npm ci --ignore-scripts
19
+ npm run build
20
+ node packages/agent-map/dist/cli.js --config deployment/cartography/reference.example.json
21
+ ```
22
+
23
+ Review the example's company, tenant and team identifiers, Neo4j address and
24
+ username before use. Provide `AGENT_MAP_NEO4J_PASSWORD` and
25
+ `AGENT_MAP_READER_TOKEN` through your host's secret environment. Generate the
26
+ reader token with `createMapToken()` and provision it through your trusted host;
27
+ do not commit it or include it in a URL. The launcher prints only its loopback URL
28
+ and mode. Open that URL and enter the reference token. The viewer keeps it in
29
+ memory until disconnect/reload and never sends it to a different origin. The
30
+ clearly labeled synthetic demo uses only browser-local fixture data.
31
+
32
+ The launcher requires nonblocking file-open support, as provided by the pilot's
33
+ POSIX hosts. Its configuration must resolve to a regular file of at most 128 KiB;
34
+ symlinks to regular files remain supported. It checks the opened descriptor and
35
+ limits bytes read even if the file grows. Named pipes and other nonregular inputs
36
+ fail startup with the same safe diagnostic. Native Windows is outside the
37
+ [pilot's supported host profile](../../deployment/cartography/RUNBOOK.md#prerequisites-and-layout).
38
+
39
+ Viewer asset hosting on both HTTP and HTTPS also requires nonblocking and
40
+ no-follow file-open support, as provided by the POSIX pilot hosts. The fixed
41
+ `index.html`, `app.js` and `app.css` entries must each be regular files of at most
42
+ 4 MiB. The loader checks each opened descriptor, rejects a symlink replacing an
43
+ asset, and bounds reads even if the file grows. It captures the bytes at startup;
44
+ later path replacements do not change the served assets. Starting an API without
45
+ `viewerDirectory` does not require these file-open capabilities.
46
+
47
+ `agm_v1` reference credentials are independent of executor/task and observer
48
+ credentials. Each credential is mapped to an immutable `ReadScope` by the host:
49
+ `subject`, `companyId`, `tenantIds`, `teamIds`, `allTeams`. Neither HTTP nor MCP
50
+ arguments can override this scope. A team reader can see only agents explicitly
51
+ assigned to an allowed team and their attached evidence. `allTeams: true` is a
52
+ separate explicit grant, including unassigned/core inventory. It must not be
53
+ inferred from an empty team list. Restart with a revised credential registry to
54
+ rotate or revoke these bearer credentials.
55
+
56
+ The server binds `127.0.0.1` only and requires an exact Host header. Browser
57
+ requests must use its same origin. It provides no CORS, arbitrary Cypher,
58
+ database credentials, execution tools or administration routes. For company
59
+ browser access, use the separate HTTPS identity endpoint below. Do not expose
60
+ the loopback listener directly through an unchecked proxy.
61
+
62
+ Use a dedicated Neo4j reader account where database privileges are available.
63
+ The driver's READ session mode is not a privilege boundary. Neo4j Community
64
+ does not establish database-level team isolation; the service's fixed queries
65
+ and scope checks enforce its reference interface. The database remains a
66
+ trusted service accessible only to collector and query hosts. Remote database
67
+ connections require verified TLS (`neo4j+s` or `bolt+s`). Unencrypted connections
68
+ are accepted only with direct `bolt://` and a literal loopback address. Plaintext
69
+ `neo4j://` routing is rejected because advertised peers can leave loopback.
70
+
71
+ ## Run the company HTTPS viewer
72
+
73
+ The separate `agent-guard-map-identity` launcher serves the viewer and scoped
74
+ queries over HTTPS with confidential OIDC sign-in. Follow the
75
+ [identity deployment guide](../../deployment/cartography/IDENTITY.md) to register
76
+ the provider, provision private configuration/TLS files and environment secrets,
77
+ and adapt [identity.example.json](../../deployment/cartography/identity.example.json).
78
+ After building and provisioning the private config:
79
+
80
+ ```sh
81
+ node packages/agent-map/dist/identity-cli.js --config /absolute/private/identity.json
82
+ ```
83
+
84
+ The installed package exposes the equivalent `agent-guard-map-identity` command.
85
+ The provider must support authorization code flow with S256 PKCE and RS256 ID
86
+ tokens. Each exact issuer `sub` has an explicit host-owned scope; provider groups
87
+ and browser arguments cannot grant access. The endpoint owns TLS, requires exact
88
+ Host/Origin, rejects forwarded identity/authorization headers and provides no
89
+ CORS. It does not wrap or reconfigure the loopback service.
90
+
91
+ The browser uses opaque Secure/HttpOnly cookies and CSRF-protected same-origin
92
+ POSTs. It receives no provider tokens or scope claims. Sessions last at most 15
93
+ minutes, capped by ID token expiry, and are not refreshed. Sign out ends the
94
+ local session only; the IdP SSO session may remain active. Bindings, secrets and
95
+ TLS files reload on restart, which invalidates all sessions. There is no
96
+ distributed session store or HA mode. A registered live company IdP and a
97
+ trusted-browser end-to-end check remain rollout gates; see the guide for their
98
+ status and the complete configuration/operational limits.
99
+
100
+ ## Shared operations
101
+
102
+ On the loopback service, POST `/v1/query` with `Authorization: Bearer <reference-token>`, content type
103
+ `application/json` and `{ "operation": "list_agents", "args": {} }`.
104
+ Results contain `operation`, `observedAt`, `data` and an optional focused `graph`.
105
+ Source IDs are the graph source IDs returned by the service, not native source
106
+ names. Native agent/task IDs and returned stable entity IDs are accepted where
107
+ documented by the schemas. No pagination cursor exposes a broader scope.
108
+
109
+ | Operation | Arguments | Evidence |
110
+ | --- | --- | --- |
111
+ | `list_agents` | optional `sourceId`, `search`, `ownerId`, `environment`, `limit` | Scoped inventory for choosing an agent. |
112
+ | `get_agent_access` | `sourceId`, `agentId` | Focused deployments, tasks, grants, tools, bindings, MCP and cloud observations. |
113
+ | `explain_access` | `sourceId`, `taskId`, `tool`, `resourceId` | Visible delegation, declared matches, known blockers and explicit unknown checks. |
114
+ | `find_agents_with_access` | `resourceRef`, `action`; optional `sourceId`, `limit` | Potential candidates from exact host resource/action bindings; no wildcard or prefix expansion. |
115
+ | `get_changes` | `sourceId`; optional `since` | Net current/previous changes to currently authorized agents; explicit gaps. |
116
+ | `get_inventory_health` | optional `sourceId` | Visible capture times and independently stale or unavailable components. |
117
+
118
+ Snapshot generation time and component observation times are separate. Tasks and
119
+ tools retain their original capture times after host/MCP recomposition. MCP age
120
+ uses the oldest capture or observation among visible connections; recomposing a
121
+ cached observation does not refresh it. Missing observation times remain unknown
122
+ and stale for observed connections. Unavailable connections use the time their
123
+ failure was captured. Historical projections retain their own capture times.
124
+
125
+ On the loopback service, POST `/mcp` uses the official MCP SDK's stateless HTTP transport. The six tools
126
+ have the same arguments and use the same service as HTTP. Supply the reference
127
+ bearer in the client's HTTP headers. The host-only `createMapMcpServer(service,
128
+ scope)` factory also supports embedding; only trusted host code chooses scope.
129
+ There are no subscriptions, arbitrary resources or mutation methods. MCP tool
130
+ results contain the common JSON envelope as text; clients should treat all
131
+ imported names and identifiers as data, never instructions.
132
+
133
+ The company endpoint exposes the same `/v1/query` envelope with session cookies
134
+ and `X-CSRF-Token`, and deliberately has no `/mcp` route. Bearer/MCP credentials
135
+ and company browser sessions are separate authentication boundaries.
136
+
137
+ ## Host API
138
+
139
+ ### Current IAM policy evidence
140
+
141
+ The existing HTTP/MCP operations also expose the collector's optional IAM policy
142
+ candidate layer. `get_agent_access.data.policyEvidence` lists evidence for the
143
+ selected agent. `explain_access.data.externalEvidence.policyEvidence` selects the
144
+ exact task/tool/resource bindings; potential-access lookup further selects the
145
+ requested action. Each result identifies its task, deployment, execution binding,
146
+ resource binding and external endpoints by stable entity ID, with an independent
147
+ policy observation time, status, reason and `assessment: unknown`.
148
+
149
+ Only the three collected S3 mappings are supported. A complete record contains
150
+ zero or one candidate with mapping name, condition flag/key names and
151
+ `resourceScope: bucket_summary`. Empty candidates never prove denial. The original
152
+ host resource ARN, kind and scope remain on the binding graph; a bucket summary
153
+ does not authorize an exact object or prefix. Boundaries, unsupported policies,
154
+ missing collection, opt-out and stale/changed evidence remain explicit gaps.
155
+
156
+ The Neo4j reader derives pairs through a visible task's own deployment, declared
157
+ grant, resource binding and execution tool. It validates the exact provider
158
+ links, account ownership, scoped collection, membership and candidate provenance.
159
+ It rechecks the bounded raw evidence and source pointers before returning;
160
+ concurrent changes fail with a stable error instead of mixing observations.
161
+ The reader returns no raw policies, condition values, collection-wide hashes,
162
+ counts or unrelated provider neighbors. Generic Cartography `CAN_*` edges do not
163
+ fill missing owned evidence.
164
+
165
+ Policy age uses the tighter of the snapshot's enrolled cloud `maxAgeSeconds` and
166
+ the host's `Neo4jMapStoreOptions.policyMaxAgeSeconds` (default 7,200; maximum
167
+ 86,400). A newer AWS capture makes old Guard provider joins unavailable until the
168
+ next successful Guard collection. `get_inventory_health` reports policy coverage
169
+ separately. `get_changes` returns `policyHistory: not_collected`: live candidates
170
+ are not attached to historical inventory snapshots or used to invent policy diffs.
171
+
172
+ The reader caps each request at 512 task/binding/action pairs and fails overflow
173
+ without returning partial evidence. Fixed read queries, row/byte limits, the
174
+ five-second transaction deadline and the existing response limits still apply.
175
+ Custom `MapStore` implementations may omit `MapProjection.policyEvidence`; supplied
176
+ records receive closed-shape and binding-path validation at the service boundary.
177
+ Complete evidence requires one owning agent and unambiguous tool/identity/binding
178
+ links, including unique task/grant and grant/selector pairs. Distinct valid grants
179
+ and resource selectors remain supported; ambiguous evidence may be reported as
180
+ unavailable with no candidates.
181
+ This metadata never changes executor admission.
182
+
183
+ Sources superseded through the host's [lifecycle command](../../deployment/cartography/SOURCE-LIFECYCLE.md)
184
+ are excluded from normal reads, including explicit source requests and history.
185
+ A read spanning supersession fails rather than returning its old view. The new
186
+ enrollment generation has its own source identity; supersession does not rewrite
187
+ the executor ledger or change agent permissions.
188
+
189
+ This self-contained example demonstrates the public contract without requiring
190
+ a database. For real inventory, replace the store with `createNeo4jMapStore` and
191
+ close it when the host shuts down.
192
+
193
+ ```ts
194
+ import { MapService, validateReadScope, type MapStore } from '@shieldaai/agent-map';
195
+
196
+ const store: MapStore = { async read() { return { sources: [] }; } };
197
+ const service = new MapService(store);
198
+ const scope = validateReadScope({ subject: 'reader', companyId: 'example',
199
+ tenantIds: ['engineering'], teamIds: ['platform'], allTeams: false });
200
+ const response = await service.query(scope, 'list_agents', {});
201
+ console.log(response.data);
202
+ ```
203
+
204
+ To embed the company endpoint, load TLS material and secrets in trusted host
205
+ code. This self-contained function uses an empty store and is not invoked by the
206
+ example. Replace its paths, registered issuer/client and subject binding before
207
+ calling it; the host API requires an absolute viewer directory and loaded PEM
208
+ strings. The CLI adds the private-file checks described in the deployment guide.
209
+
210
+ ```ts
211
+ import { readFile } from 'node:fs/promises';
212
+ import { MapService, startMapIdentityServer,
213
+ type MapIdentityServer, type MapStore } from '@shieldaai/agent-map';
214
+
215
+ export async function startCompanyReference(clientSecret: string): Promise<MapIdentityServer> {
216
+ const store: MapStore = { async read() { return { sources: [] }; } };
217
+ return startMapIdentityServer({
218
+ service: new MapService(store),
219
+ publicOrigin: 'https://localhost:8788', listenHost: '127.0.0.1', port: 8788,
220
+ tls: {
221
+ key: await readFile('/absolute/private/tls/server-key.pem', 'utf8'),
222
+ cert: await readFile('/absolute/private/tls/server-chain.pem', 'utf8'),
223
+ },
224
+ oidc: {
225
+ issuer: 'https://login.example.invalid',
226
+ clientId: 'replace-with-registered-client-id', clientSecret,
227
+ },
228
+ companyId: 'example-company',
229
+ bindings: [{
230
+ subject: 'replace-with-exact-idp-sub',
231
+ scope: { subject: 'platform-reader', companyId: 'example-company',
232
+ tenantIds: ['engineering'], teamIds: ['platform'], allTeams: false },
233
+ }],
234
+ viewerDirectory: '/absolute/path/to/agent-guard/apps/agent-map/dist',
235
+ });
236
+ }
237
+ ```
238
+
239
+ `bindings[].subject` is the exact IdP `sub`; `scope.subject` is a local alias and
240
+ can differ. The returned server exposes `replaceBindings`, `revokeSubject` and
241
+ `invalidateSessions` only to host code. Each invalidates all current sessions
242
+ and login transactions; revocation also removes that binding. Persist policy
243
+ changes in the host before restarting. Call `close()` during shutdown and close
244
+ any real Neo4j store. No HTTP administration endpoints are exposed.
245
+
246
+ Custom `MapStore` implementations are trusted adapters and must implement the
247
+ same visibility boundary as `Neo4jMapStore`; the service does not turn an
248
+ unscoped store into a scoped one. The included store filters all node/edge
249
+ queries before limits or materialization. Shared tools, principals, resources
250
+ and MCP connections do not reveal other teams' attached entities. Historical
251
+ membership is intersected with current authorized agent ownership, including
252
+ task ownership, so moving an agent/task between teams cannot expose its old
253
+ team's evidence. Hidden and nonexistent IDs return the same `MAP_NOT_FOUND`.
254
+ Team responses omit source-wide revision counters and hidden ancestor/family
255
+ identifiers. Explanations always retain a generic ancestor-scope uncertainty.
256
+
257
+ ## Limits and semantics
258
+
259
+ Loopback defaults: 32 KiB HTTP request, 1 MiB service result (2 MiB transport ceiling),
260
+ 500 focused nodes/1,000 edges, 64 sources and 2,000 nodes/5,000 edges per store
261
+ read, 5-second graph/service deadline, 10-second HTTP deadline, four concurrent
262
+ HTTP requests and 120 requests/minute per credential plus a global quota.
263
+ Streaming graph reads cap materialized nodes/edges at 4 MiB. Synchronous service
264
+ processing shares the query deadline and has a 200,000-unit work budget; potential
265
+ access evidence is limited to 1,000 entries and the cumulative response-byte
266
+ budget. Configuration has hard upper bounds. Oversized authorized inventories fail
267
+ closed instead of returning a misleading partial map. List operations return
268
+ up to 100 rows and explicitly indicate truncation.
269
+
270
+ The company endpoint has separate browser/provider limits, including a default
271
+ 600 requests/minute per session and globally. Its complete defaults and hard
272
+ ceilings are in the [identity guide](../../deployment/cartography/IDENTITY.md).
273
+ The MapService/store limits and evidence semantics below apply to both endpoints.
274
+
275
+ The store uses fixed parameterized read-only templates in one transaction,
276
+ allowlisted properties and relationships, bounded graph paths, and a publication
277
+ pointer recheck. It never traverses into arbitrary provider policy data. A
278
+ pointer change fails the query for retry rather than mixing generations.
279
+ Current/previous comparisons are net differences, not an audit history; missing
280
+ or retired previous evidence is explicit. Collection times and global revision
281
+ changes alone are not entity changes. Health describes published inventory,
282
+ not collector process health. Source-wide publication timing is visible to
283
+ authorized readers of that source.
284
+
285
+ Blockers describe exported gates at capture/evaluation time. A result without
286
+ blockers remains `unknown`: live budgets, arguments, custom policy, approvals,
287
+ delegation outside scope and backend authorization still require evaluation.
288
+ Potential-access matches retain exact/prefix, static/dynamic, cloud freshness
289
+ and MCP lifecycle limitations. The graph is never used in executor admission.
290
+
291
+ ## Validation
292
+
293
+ ```sh
294
+ npm test
295
+ npm run test:pack
296
+ cd integrations/cartography
297
+ .venv/bin/python scripts/test-disposable-neo4j.py -- -q
298
+ ```
299
+
300
+ JavaScript checks cover schemas, immutable scope, query bounds, safe HTTP,
301
+ official SDK HTTP/MCP equivalence, disposable HTTPS/OIDC exchange, cookie/CSRF
302
+ and revocation boundaries, private launcher files and viewer lifecycle behavior.
303
+ The packed-package check compiles both Host API examples and exercises the
304
+ installed identity boundary. Disposable Neo4j checks
305
+ exercise actual published graphs, cross-company/tenant/team isolation, shared
306
+ MCP metadata, moved ownership, hidden IDs, current/previous visibility and
307
+ absence of database mutations. Never run the integration suite against a
308
+ shared or production database.
@@ -0,0 +1,5 @@
1
+ /** Load the fixed public assets once; never follow a replaced leaf or read beyond the cap. */
2
+ export declare function loadMapAssets(directory: unknown): Promise<Map<string, {
3
+ body: Buffer;
4
+ mime: string;
5
+ }>>;
package/dist/assets.js ADDED
@@ -0,0 +1,43 @@
1
+ import { constants } from 'node:fs';
2
+ import { open } from 'node:fs/promises';
3
+ import { isAbsolute, join } from 'node:path';
4
+ import { fail } from './boundary.js';
5
+ /** Load the fixed public assets once; never follow a replaced leaf or read beyond the cap. */
6
+ export async function loadMapAssets(directory) {
7
+ const assets = new Map();
8
+ if (directory === undefined)
9
+ return assets;
10
+ if (typeof directory !== 'string' || !isAbsolute(directory) ||
11
+ typeof constants.O_NONBLOCK !== 'number' || typeof constants.O_NOFOLLOW !== 'number')
12
+ fail('MAP_CONFIG_INVALID');
13
+ const maximum = 4 * 1024 * 1024;
14
+ for (const [name, mime] of [['index.html', 'text/html; charset=utf-8'], ['app.js', 'text/javascript; charset=utf-8'], ['app.css', 'text/css; charset=utf-8']]) {
15
+ try {
16
+ const file = await open(join(directory, name), constants.O_RDONLY | constants.O_NONBLOCK | constants.O_NOFOLLOW);
17
+ try {
18
+ const info = await file.stat();
19
+ if (!info.isFile() || info.size > maximum)
20
+ fail('MAP_CONFIG_INVALID');
21
+ const data = Buffer.alloc(maximum + 1);
22
+ let bytes = 0;
23
+ while (bytes < data.length) {
24
+ const read = await file.read(data, bytes, data.length - bytes, null);
25
+ if (!read.bytesRead)
26
+ break;
27
+ bytes += read.bytesRead;
28
+ }
29
+ if (bytes > maximum)
30
+ fail('MAP_CONFIG_INVALID');
31
+ // Do not retain the full maximum-sized allocation for a small asset.
32
+ assets.set(`/${name}`, { body: Buffer.from(data.subarray(0, bytes)), mime });
33
+ }
34
+ finally {
35
+ await file.close();
36
+ }
37
+ }
38
+ catch {
39
+ fail('MAP_CONFIG_INVALID');
40
+ }
41
+ }
42
+ return assets;
43
+ }
@@ -0,0 +1,5 @@
1
+ export declare function fail(code: string): never;
2
+ export declare function fields(value: unknown, allowed: readonly string[], required?: readonly string[]): Record<string, unknown>;
3
+ export declare function integer(value: unknown, fallback: number, min: number, max: number): number;
4
+ /** Bounded strict JSON, including duplicate decoded keys that JSON.parse would discard. */
5
+ export declare function parseRequest(bytes: Uint8Array, maximum?: number): unknown;