@cirvix_ai/agent-control 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 (45) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +42 -0
  3. package/README.md +341 -0
  4. package/action/README.md +100 -0
  5. package/action/action.yml +134 -0
  6. package/action/report.mjs +144 -0
  7. package/bin/cirvix.mjs +1073 -0
  8. package/package.json +60 -0
  9. package/src/commands/demo.mjs +315 -0
  10. package/src/commands/init.mjs +558 -0
  11. package/src/commands/policy.mjs +345 -0
  12. package/src/commands/sarif.mjs +176 -0
  13. package/src/commands/scan.mjs +210 -0
  14. package/src/commands/status.mjs +208 -0
  15. package/src/commands/upgrade.mjs +162 -0
  16. package/src/core/approvals.mjs +388 -0
  17. package/src/core/audit.mjs +181 -0
  18. package/src/core/canonical.mjs +316 -0
  19. package/src/core/daemon.mjs +352 -0
  20. package/src/core/decisions.mjs +253 -0
  21. package/src/core/delegation.mjs +658 -0
  22. package/src/core/detect.mjs +337 -0
  23. package/src/core/entitlement-gate.mjs +100 -0
  24. package/src/core/entitlements.mjs +285 -0
  25. package/src/core/format.mjs +33 -0
  26. package/src/core/gateway.mjs +959 -0
  27. package/src/core/guard.mjs +568 -0
  28. package/src/core/http-transport.mjs +505 -0
  29. package/src/core/journal.mjs +419 -0
  30. package/src/core/jsonrpc.mjs +152 -0
  31. package/src/core/meter.mjs +225 -0
  32. package/src/core/normalize.mjs +516 -0
  33. package/src/core/notices.mjs +80 -0
  34. package/src/core/pipeline.mjs +629 -0
  35. package/src/core/policy-dsl.mjs +611 -0
  36. package/src/core/policy.mjs +710 -0
  37. package/src/core/prompts.mjs +146 -0
  38. package/src/core/risk.mjs +509 -0
  39. package/src/core/sanitize.mjs +279 -0
  40. package/src/core/secret-detect.mjs +533 -0
  41. package/src/core/secrets.mjs +312 -0
  42. package/src/core/uds.mjs +383 -0
  43. package/src/core/vault.mjs +530 -0
  44. package/src/index.mjs +143 -0
  45. package/src/testing.mjs +145 -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/NOTICE ADDED
@@ -0,0 +1,42 @@
1
+ Cirvix AgentControl — enforcement engine
2
+ Copyright 2026 Umang Kumar, trading as Cirvix
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this file except in compliance with the License. You may obtain a copy of the
6
+ License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed
11
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ specific language governing permissions and limitations under the License.
14
+
15
+ ---
16
+
17
+ WHAT THIS LICENCE COVERS
18
+
19
+ This package is the enforcement engine: the policy evaluator, the risk
20
+ classifier, the secret detector and handle substitution, the local control
21
+ socket, the MCP gateway, the audit chain, the scanner, and the `cirvix` CLI.
22
+
23
+ It is licensed under Apache 2.0 deliberately. A security control that cannot be
24
+ read is a security control you are asked to take on faith, and this is the part
25
+ that decides whether a tool call runs. Read it, fork it, audit it, run it in
26
+ production without paying anything, and do not ask us for permission.
27
+
28
+ WHAT IT DOES NOT COVER
29
+
30
+ The Cirvix control plane — multi-tenant policy distribution, the team vault,
31
+ SSO and SCIM, approvals workflow, hosted audit retention and export, compliance
32
+ evidence reporting, fleet telemetry and billing — is a separate package under a
33
+ separate, proprietary licence. See packages/control-plane/LICENSE.
34
+
35
+ THIRD-PARTY CODE
36
+
37
+ There is none. This package has zero runtime dependencies, deliberately and
38
+ permanently — a security tool that drags in a transitive dependency tree is
39
+ asking to become the supply-chain incident it exists to prevent.
40
+
41
+ The self-hosted fonts shipped with the Cirvix website (Geist and Geist Mono) are
42
+ licensed SIL OFL-1.1 and are not part of this package.
package/README.md ADDED
@@ -0,0 +1,341 @@
1
+ # @cirvix_ai/agent-control
2
+
3
+ Runtime governance for AI agents. Scan what is ungoverned, evaluate tool calls
4
+ against policy, and keep a tamper-evident record of every decision.
5
+
6
+ **Zero runtime dependencies.** A security tool that drags in a transitive
7
+ dependency tree is asking to become the supply-chain incident it exists to
8
+ prevent.
9
+
10
+ ## Install in 30 seconds
11
+
12
+ No account, no signup, no config file, no daemon to leave running.
13
+
14
+ ```bash
15
+ npx @cirvix_ai/agent-control scan
16
+ ```
17
+
18
+ That reads your machine and tells you which agent runtimes are ungoverned. It
19
+ writes nothing and sends nothing anywhere. Then decide one call:
20
+
21
+ ```bash
22
+ npx @cirvix_ai/agent-control check --action fs.read --resource .env.production
23
+ ```
24
+
25
+ ```
26
+ DENY fs.read .env.production
27
+ rule deny-dotenv-read
28
+ reason Reading .env files is denied outside an approved secrets flow. This is
29
+ the single most common path from a prompt injection to a live credential.
30
+ fix Request the value as a handle: secrets.get("STRIPE_KEY")
31
+ ```
32
+
33
+ To govern an agent rather than a single call, wrap its tools — the call cannot
34
+ leave without being decided, so there is no verdict to forget to check:
35
+
36
+ ```bash
37
+ npm install @cirvix_ai/agent-control
38
+ ```
39
+
40
+ ```js
41
+ import { guard, CirvixDenied, STARTER_RULES } from "@cirvix_ai/agent-control";
42
+
43
+ const tools = guard.wrap(myTools, { agent: "pr-triage", rules: STARTER_RULES });
44
+
45
+ try {
46
+ await agent.invoke(input);
47
+ } catch (err) {
48
+ if (err instanceof CirvixDenied) {
49
+ console.log(err.policy, err.remediation, err.decisionId);
50
+ }
51
+ throw err;
52
+ }
53
+ ```
54
+
55
+ Requires Node 20 or later. There is a second implementation of the same engine
56
+ for Python — `pip install cirvix` — and the two are held to a shared
57
+ conformance fixture that both must pass.
58
+
59
+ **Full documentation:** [`docs/`](https://www.cirvix.com/docs.html) — [CLI reference](https://www.cirvix.com/docs.html), [Node SDK](https://www.cirvix.com/sdks.html), [policy reference](https://www.cirvix.com/policy-engine.html).
60
+
61
+ ## Licence
62
+
63
+ Apache-2.0. The local enforcement engine is open source and ships with the
64
+ Apache-2.0 licence and attribution notice in this package. The hosted Cirvix
65
+ control plane is a separate product and is not included here.
66
+
67
+ ## `cirvix scan`
68
+
69
+ Read-only inventory of this machine. No account, no network, nothing written.
70
+
71
+ Finds the agent runtimes you have installed (Claude Code, Cursor, Windsurf,
72
+ Cline, VS Code MCP), the frameworks declared in the current project, every MCP
73
+ server configured across all of them, and the credential files an agent with
74
+ filesystem access could read.
75
+
76
+ ```
77
+ runtimes 2 found
78
+ Claude Code ~/.claude/settings.json
79
+ ungoverned · 6 MCP servers
80
+ Cursor ~/.cursor/mcp.json
81
+ ungoverned · 4 MCP servers
82
+
83
+ mcp servers 7 configured
84
+ filesystem-mcp stdio broad scope
85
+ github-mcp stdio inline secrets · ×2 runtimes
86
+
87
+ credentials 3 paths reachable from agent context
88
+ AWS credentials On disk and readable by any agent with filesystem access
89
+ .env.production 4 secret-shaped keys: STRIPE_KEY, DATABASE_URL…
90
+
91
+ findings 4 high · 3 medium · 1 low
92
+ ```
93
+
94
+ **It never prints a secret value.** Key *names* only — reporting a leak by
95
+ leaking it would be absurd.
96
+
97
+ | Flag | Effect |
98
+ |---|---|
99
+ | `--json` | Machine-readable output |
100
+ | `--deep` | Include MCP command lines |
101
+ | `--fail-on <high\|medium\|low>` | Exit non-zero at that severity — for CI |
102
+ | `--cwd <dir>` | Workspace root |
103
+
104
+ ## `cirvix check`
105
+
106
+ Evaluate a single tool call against the policy set. Every decision names the
107
+ rule that produced it.
108
+
109
+ ```bash
110
+ $ cirvix check --action fs.read --resource .env.production
111
+
112
+ DENY fs.read /repo/.env.production
113
+ rule deny-dotenv-read
114
+ reason Reading .env files is denied outside an approved secrets flow.
115
+ fix Request the value as a handle: secrets.get("STRIPE_KEY")
116
+ ```
117
+
118
+ Exit code is `1` on deny, `0` otherwise — so it works as a gate in CI.
119
+
120
+ ## The policy engine
121
+
122
+ An ordered rule set with three effects: `permit`, `forbid`, `hold`. Three
123
+ properties are guaranteed and covered by tests:
124
+
125
+ 1. **`forbid` always wins.** No `permit` can override it, at any position.
126
+ This is what makes a rule set safe to extend — adding a permissive rule can
127
+ never silently punch a hole through an existing prohibition.
128
+ 2. **Default deny.** A request matching nothing is denied. Fail-open is how a
129
+ control plane becomes decorative the first time a rule file fails to parse.
130
+ 3. **Resources are canonicalized before matching.** `./x/../.env`, `.env`, and
131
+ the absolute path are one resource. Rules matching raw strings are bypassed
132
+ by the first traversal attempt.
133
+
134
+ Conditions are **plain data, never expressions** — no `eval`, no
135
+ `new Function`. A policy file is exactly the kind of thing that gets templated
136
+ by a script, and making it an execution surface would turn the security
137
+ product into the vulnerability.
138
+
139
+ ```json
140
+ {
141
+ "name": "require-approval-prod-deploy",
142
+ "effect": "hold",
143
+ "actions": ["k8s.apply", "db.migrate"],
144
+ "resources": ["*"],
145
+ "when": [{ "path": "environment", "op": "in", "value": ["production"] }],
146
+ "approvers": ["platform-oncall"]
147
+ }
148
+ ```
149
+
150
+ Operators: `eq` `ne` `in` `nin` `gt` `gte` `lt` `lte` `matches` `exists`
151
+ `contains` `supersetOf`. An unknown operator fails closed.
152
+
153
+ ## `guard.wrap()` — governing an agent that does not speak MCP
154
+
155
+ The gateway governs everything, including tools added after you deployed it,
156
+ because it sits on the wire. It also requires the agent to speak MCP. `wrap` is
157
+ for when it does not — a LangChain executor, a crew, a hand-rolled loop over
158
+ some functions:
159
+
160
+ ```js
161
+ import { guard, CirvixDenied, CirvixHeld } from "@cirvix_ai/agent-control";
162
+
163
+ const tools = guard.wrap(myTools, {
164
+ agent: "pr-triage",
165
+ environment: process.env.CIRVIX_ENV ?? "local",
166
+ rules, // or load them with loadPolicy({ policyDir })
167
+ });
168
+
169
+ try {
170
+ await agent.invoke(input);
171
+ } catch (err) {
172
+ if (err instanceof CirvixDenied) {
173
+ console.log(err.policy); // "deny-dotenv-read"
174
+ console.log(err.remediation); // 'secrets.get("STRIPE_KEY")'
175
+ console.log(err.decisionId); // pass to `cirvix why`
176
+ }
177
+ throw err;
178
+ }
179
+ ```
180
+
181
+ **The trade, stated plainly.** You give up the property that makes the gateway
182
+ worth deploying — it governs tools nobody told it about — because you are
183
+ wrapping a list. You keep everything else: the same engine, the same rules, the
184
+ same decision record, the same secret brokering, the same audit chain. That is
185
+ not a slogan; `wrap` and the gateway call one `Guard`, so a rule cannot mean
186
+ one thing here and another there.
187
+
188
+ | It accepts | Example |
189
+ |---|---|
190
+ | An object of `name → function` | `{ read_file, run_query }` |
191
+ | An array of tool objects carrying a callable | LangChain, CrewAI, AutoGen |
192
+ | A single function | `guard.wrap(fn, { name: "read_file" })` |
193
+
194
+ Tool objects come back with their descriptions, schemas, and framework
195
+ metadata intact — and the array you passed in is left alone, so a framework
196
+ holding the originals does not find them governed by surprise.
197
+
198
+ **`CirvixDenied` vs `CirvixHeld`.** A denial means re-plan. A hold means this
199
+ exact call may still happen once a person says yes, and carries `approvers`.
200
+ They are separate types because collapsing them teaches an agent to treat both
201
+ as failure.
202
+
203
+ ### Testing a policy like code
204
+
205
+ ```js
206
+ import { evaluate, expectNoLoosening } from "@cirvix_ai/agent-control/testing";
207
+
208
+ test("production writes are held for a human", async () => {
209
+ const decision = await evaluate({
210
+ policyDir: "./policies",
211
+ agent: "deploy-bot",
212
+ action: "k8s.apply",
213
+ resource: "production/checkout",
214
+ context: { environment: "production" },
215
+ });
216
+
217
+ expect(decision.verdict).toBe("hold");
218
+ expect(decision.approvers).toContain("platform-oncall");
219
+ });
220
+ ```
221
+
222
+ `expectNoLoosening({ before, after, calls })` is the pull-request counterpart:
223
+ it reports any call the change would newly permit. Tightening passes — a
224
+ security policy is allowed to move that way without surprising a reviewer.
225
+
226
+ ### Claude Code, Cursor, and other MCP clients
227
+
228
+ Use the gateway, not `wrap`. They already speak MCP, and pointing them at
229
+ `cirvix gateway` governs every server they load — including ones added later:
230
+
231
+ ```json
232
+ { "mcpServers": { "cirvix": { "command": "cirvix", "args": ["gateway", "--servers", "~/.cursor/mcp.json"] } } }
233
+ ```
234
+
235
+ ### Python
236
+
237
+ ```bash
238
+ pip install cirvix
239
+ ```
240
+
241
+ ```python
242
+ from cirvix import guard, CirvixDenied
243
+ tools = guard.wrap(my_tools, agent="pr-triage", rules=rules)
244
+ ```
245
+
246
+ Same API, native evaluator — not an HTTP client, because a round trip in the
247
+ enforcement path would break the offline-first guarantee the daemon exists for.
248
+
249
+ Which raises the obvious risk: two engines that can silently disagree are worse
250
+ than one engine and an honest gap. What makes it safe is
251
+ `packages/conformance/policy-conformance.json` — 44 cases both engines must
252
+ answer identically, down to the canonical resource and the rule trace. Neither
253
+ language gets a private copy. See `packages/cirvix-python`.
254
+
255
+ ## Secret handles
256
+
257
+ An agent never receives secret material. It receives an opaque handle, and the
258
+ real value is substituted into the outbound request at the gateway — after
259
+ policy has authorized that specific destination.
260
+
261
+ ```js
262
+ import { SecretsClient } from "@cirvix_ai/agent-control/secrets";
263
+
264
+ const secrets = new SecretsClient({ apiUrl, apiKey, agent: "pr-triage" });
265
+
266
+ const key = await secrets.get("STRIPE_RESTRICTED_KEY");
267
+ // "sec_handle_a89f…" — this is everything the model ever sees.
268
+ ```
269
+
270
+ Attach it to the gateway and the rest is automatic:
271
+
272
+ ```js
273
+ const gw = new Gateway({ servers, rules, secrets });
274
+ ```
275
+
276
+ | | |
277
+ |---|---|
278
+ | On the way out | Handles in a permitted call's arguments are resolved and substituted |
279
+ | Off-path | A handle presented for an unsanctioned destination denies the call, rule `secret-broker` |
280
+ | No destination | A call carrying a handle but naming no http(s) endpoint is refused |
281
+ | Partially resolvable | If any handle fails, **nothing** is substituted — never a real credential beside a literal handle |
282
+ | On the way back | Results are scanned for material this session resolved, and it is swapped back to its handle |
283
+
284
+ **Substitution does not taint the session.** The `touchedSecret` flag that
285
+ blocks egress after a raw credential read is deliberately not set here: an
286
+ agent holding a handle never held the material, which is the entire point. The
287
+ alternative would deny the second call to the very API the handle was for.
288
+
289
+ **Leak detection covers material this session resolved, and nothing else.** A
290
+ credential Cirvix was never told about cannot be recognised on the return
291
+ path. This is a backstop, not a substitute for scoping what a handle reaches.
292
+
293
+ ## The audit chain
294
+
295
+ Append-only JSONL where each record commits to the hash of its predecessor.
296
+
297
+ ```bash
298
+ $ cirvix audit verify --file .cirvix/audit.jsonl
299
+
300
+ chain intact 43,675 records verified
301
+ ```
302
+
303
+ Alter or delete any record and verification reports **where** it broke:
304
+
305
+ ```
306
+ chain broken at record 2 of 3
307
+ Record 2 has been modified — its contents no longer match its hash.
308
+ ```
309
+
310
+ **What this proves:** no record was altered or removed after it was written.
311
+ **What it does not prove:** that a record was written truthfully in the first
312
+ place — that comes from the enforcement path, not the log. It also does not
313
+ prevent destruction; someone with disk access can delete the file. The chain
314
+ guarantees doing so is *visible*.
315
+
316
+ Hashes are SHA-256 over a canonical JSON serialization with sorted keys, so
317
+ two semantically identical records hash identically.
318
+
319
+ ## Tests
320
+
321
+ ```bash
322
+ npm test
323
+ ```
324
+
325
+ 93 tests covering the three policy invariants, traversal bypass attempts, glob
326
+ safety under hostile patterns, condition safety, chain tamper detection,
327
+ gateway interception against a real child-process MCP server, handle
328
+ substitution on both the outbound and return paths, and the `guard.wrap`
329
+ surface.
330
+
331
+ ## Status
332
+
333
+ Pre-release. `scan`, `check`, `policy`, `why`, `replay`, `audit verify`,
334
+ `gateway`, and `daemon` work today, as does secret brokering and `guard.wrap`
335
+ when a control plane is configured. Not yet built: a Python SDK, and the
336
+ hosted control plane — the one in `packages/control-plane` is self-hosted. See
337
+ [cirvix.com](https://www.cirvix.com).
338
+
339
+ ## License
340
+
341
+ See LICENSE. Cirvix is a product of Umang Kumar, trading as Cirvix.
@@ -0,0 +1,100 @@
1
+ # `cirvix/scan`
2
+
3
+ Find the AI agent runtimes, MCP servers, and reachable credentials in a
4
+ repository that nothing is governing — on every pull request.
5
+
6
+ ```yaml
7
+ - uses: cirvix/scan@v1
8
+ ```
9
+
10
+ That is the whole minimum. It scans the checkout, writes a job summary,
11
+ annotates blocking findings on the diff, uploads SARIF to code scanning, and
12
+ fails the job on anything high.
13
+
14
+ ## First run on an existing repository
15
+
16
+ Do not gate a merge on the first scan. Look at the baseline:
17
+
18
+ ```yaml
19
+ - uses: cirvix/scan@v1
20
+ with:
21
+ fail-on: never
22
+ ```
23
+
24
+ Then tighten once you know what is there.
25
+
26
+ ## A realistic workflow
27
+
28
+ ```yaml
29
+ name: Agent governance
30
+
31
+ on:
32
+ pull_request:
33
+ push:
34
+ branches: [main]
35
+
36
+ jobs:
37
+ scan:
38
+ runs-on: ubuntu-latest
39
+ permissions:
40
+ contents: read
41
+ # Required to put findings in the Security tab and on the diff.
42
+ security-events: write
43
+ # Only needed for comment-on-pr.
44
+ pull-requests: write
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: cirvix/scan@v1
48
+ with:
49
+ fail-on: high
50
+ comment-on-pr: true
51
+ ```
52
+
53
+ Without `security-events: write` the upload step is skipped rather than
54
+ failing the job — the scan is still useful, the findings just stay in the
55
+ summary.
56
+
57
+ ## Inputs
58
+
59
+ | Input | Default | |
60
+ |---|---|---|
61
+ | `fail-on` | `high` | `high`, `medium`, `low`, or `never` |
62
+ | `working-directory` | `.` | Directory to scan |
63
+ | `sarif-file` | `cirvix-scan.sarif` | Empty string to skip SARIF |
64
+ | `upload-sarif` | `true` | Send findings to code scanning |
65
+ | `comment-on-pr` | `false` | One comment, edited in place on each push |
66
+ | `version` | `latest` | Version of `@cirvix_ai/agent-control` to run |
67
+
68
+ ## Outputs
69
+
70
+ `high`, `medium`, `low`, `passed`, and `findings` (the full JSON), so a
71
+ workflow can branch without re-running the scan:
72
+
73
+ ```yaml
74
+ - uses: cirvix/scan@v1
75
+ id: cirvix
76
+ with:
77
+ fail-on: never
78
+ - if: steps.cirvix.outputs.high != '0'
79
+ run: echo "::notice::${{ steps.cirvix.outputs.high }} high findings"
80
+ ```
81
+
82
+ ## What it does not do
83
+
84
+ - **It does not send your code anywhere.** The scan reads local configuration
85
+ files and reports what it finds. Nothing is uploaded except the SARIF you
86
+ asked GitHub to store.
87
+ - **It does not execute anything.** No agent runs, no tool is called.
88
+ - **It reports reachability, not wrongdoing.** "This runtime can read
89
+ `.env.production`" is not a claim that it did. That distinction is in the
90
+ summary text on purpose, because a security report that overstates gets
91
+ discounted entirely the first time somebody checks one.
92
+
93
+ ## Why a composite action
94
+
95
+ There is no committed `dist/` bundle. A JavaScript action ships one, it has to
96
+ be rebuilt on every change, and in practice it is the thing that goes stale.
97
+ The CLI has zero runtime dependencies, so `npx @cirvix_ai/agent-control` is a
98
+ smaller and more honest supply chain than a vendored bundle nobody re-reads.
99
+
100
+ Pin `version` if you would rather not track `latest`.