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

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