{"_id":"policystrata","_rev":"6-fbf9922d85cc22f83b8f15713a217c48","name":"policystrata","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"policystrata","version":"0.1.0","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"license":"MIT","_id":"policystrata@0.1.0","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"dist":{"shasum":"bad966784c60eede0b36e1436b3d83c93ad3359c","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.0.tgz","fileCount":13,"integrity":"sha512-KBvy/zbonvyqKkW7i6Etg60+h/NKtkS8X/RvsVW9C3m0k8eUvaVqYTvv7InS1nbUiiDeyr6EUYnX5dVLemahkA==","signatures":[{"sig":"MEYCIQCilaNMardXXvjRpHnzAEzCdCOUHNsdvqPLtYy7vJpVugIhAP5MUZsJlwYF5H47oqFDdJQ65Nm+DHs4uMMCeCullIXd","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":133395},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"gitHead":"e7669807a40464acab60022342f9a3ecb7bb4eac","scripts":{"test":"npm run build && node --test dist/test/*.test.js","build":"tsc -p tsconfig.json","prepack":"npm run build"},"_npmUser":{"name":"raintree-technology","email":"admin@raintree.technology"},"repository":{"url":"git+https://github.com/raintree-technology/policystrata.git","type":"git","directory":"packages/node"},"_npmVersion":"10.9.8","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/policystrata_0.1.0_1783011725101_0.4354140928310293","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"policystrata","version":"0.1.1","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"license":"MIT","_id":"policystrata@0.1.1","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"dist":{"shasum":"a6a57edb180eb6f8b142c5f46ad60be613f6d6d5","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.1.tgz","fileCount":13,"integrity":"sha512-NqhDiXOhwoCjc04IAeXho++6YYx54EM0Ul/dj3HO4v6h8fnojR7ImgtvN6F4DeFUFjlwOoRtkpjpiYkCZBwhnA==","signatures":[{"sig":"MEQCIBKC6uFjIRvvavmCtJaiIdEoJMxQAgoU3PR7I1BHjJpJAiBmAF6MVMYCCnGQjAhClQWw4ryi4mh58NBgfqwvPFTppw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/policystrata@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":137620},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"gitHead":"d16a0885001ee8267fe2fca6b1c7e724cc913dde","scripts":{"test":"npm run build && node --test dist/test/*.test.js","build":"tsc -p tsconfig.json","prepack":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ca5ae254-38b5-49d1-baf5-ead5d0bb58c0"}},"repository":{"url":"git+https://github.com/raintree-technology/policystrata.git","type":"git","directory":"packages/node"},"_npmVersion":"11.16.0","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.20.0","typescript":"^5.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/policystrata_0.1.1_1783020957014_0.5850935145507832","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"policystrata","version":"0.1.2","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"license":"MIT","_id":"policystrata@0.1.2","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"dist":{"shasum":"777b178b61a934c842200ba917cf90bd074ca40d","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.2.tgz","fileCount":13,"integrity":"sha512-VEBMfg53poXWFcWmE8zpfqgaPX3ZluXx6fvjarKqRtDxKy/3enVPYOp4oJBIysTeJDCHNbsGizdMJN0kXKC6kg==","signatures":[{"sig":"MEQCIHANegZXbj68+uAED86/yXpsHXpFhK0v/L5fR+eWmcFWAiBamEDz4vuuS15Im17wnSAGSloOnDWjJXNHSTvn3jlxGA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/policystrata@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":174374},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":"24.x"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"gitHead":"0db6729edf8879ea001898fcb3d7ea55e664fe11","scripts":{"test":"bun run build && node --test dist/test/*.test.js","build":"tsc -p tsconfig.json","prepack":"bun run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ca5ae254-38b5-49d1-baf5-ead5d0bb58c0"}},"repository":{"url":"git+https://github.com/raintree-technology/policystrata.git","type":"git","directory":"packages/node"},"_npmVersion":"11.16.0","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.20.0","typescript":"^5.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/policystrata_0.1.2_1783460590026_0.6910737445752566","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"policystrata","version":"0.1.3","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"license":"MIT","_id":"policystrata@0.1.3","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"dist":{"shasum":"fad1e3eb6726f5b035b323a8d71a42749d6dc81b","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.3.tgz","fileCount":13,"integrity":"sha512-ypu8PaSysbrztx5CCxeir9mo6DfU0KmEkaeT+D8XoUpGlwBZv/nP0u8BloxoKaIXum/l1MeplYFoa3UWvC+fjQ==","signatures":[{"sig":"MEUCIQDzeuqfIGEru9T2E8IYjTqs17lzEde3WQZN236jTVCllwIgXZG0f1YWcq5uI1NXom4nnAQRNB5DMtZzWw3ZmdWzayg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/policystrata@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":193700},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":"24.x"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"gitHead":"70d08c19906b1c09d3e34f6ce75461dd211adf28","scripts":{"test":"bun run build && node --test dist/test/*.test.js","build":"tsc -p tsconfig.json","prepack":"bun run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ca5ae254-38b5-49d1-baf5-ead5d0bb58c0"}},"repository":{"url":"git+https://github.com/raintree-technology/policystrata.git","type":"git","directory":"packages/node"},"_npmVersion":"11.16.0","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.20.0","typescript":"^5.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/policystrata_0.1.3_1783537327521_0.5725881632262657","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"policystrata","version":"0.1.4","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"license":"MIT","_id":"policystrata@0.1.4","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"dist":{"shasum":"d282d681c752939c22aff867b63474ab38e034f3","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.4.tgz","fileCount":13,"integrity":"sha512-CQEItDBs7NNTADtTx5dV+xoF06YRV+/6Icpk4VnjK8QZOTn2qxhvz7//5beB/8A4aP9jKP4sFwInZoEEghkG/g==","signatures":[{"sig":"MEYCIQDgidQwBFnvebarQgVvv4eq+d+301Vtc1ivsGIDvkJUKQIhALpwiWjjFnvKu6lh+KyJWNHaTDlrv/IZEYGiJYBGCdDi","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/policystrata@0.1.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":196262},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":"24.x"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"gitHead":"0f0e8ab78539781b263074f51b9e655a15cefe6b","scripts":{"test":"bun run build && node --test dist/test/*.test.js","build":"tsc -p tsconfig.json","prepack":"bun run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ca5ae254-38b5-49d1-baf5-ead5d0bb58c0"}},"repository":{"url":"git+https://github.com/raintree-technology/policystrata.git","type":"git","directory":"packages/node"},"_npmVersion":"11.16.0","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.20.0","typescript":"^5.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/policystrata_0.1.4_1784768357184_0.44555185215473525","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"policystrata","version":"0.1.5","description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","type":"module","main":"./dist/src/index.js","types":"./dist/src/index.d.ts","license":"MIT","sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/raintree-technology/policystrata.git","directory":"packages/node"},"homepage":"https://github.com/raintree-technology/policystrata#readme","bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"keywords":["llm","data-agents","authorization","policy-testing","runtime"],"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"},"./node":{"types":"./dist/src/node.d.ts","default":"./dist/src/node.js"},"./runtime":{"types":"./dist/src/runtime.d.ts","default":"./dist/src/runtime.js"},"./runtime-manifest.schema.json":{"default":"./schema/runtime-manifest.schema.json"}},"scripts":{"build":"tsc -p tsconfig.json","test":"bun run build && node --test dist/test/*.test.js","prepack":"bun run build"},"engines":{"node":"24.x"},"devDependencies":{"@types/node":"^22.0.0","ajv":"^8.20.0","typescript":"^5.0.0"},"gitHead":"7d1de02c95de08d7a7e7309b5071bdb8657f89d2","_id":"policystrata@0.1.5","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-134Ue2lQ077JN5+l4chB54rm4PVl2rsUZV2v9pHUI9TWsFZPDsLWiuchvaL1G2h1z24OXc0xccKWhi7INdqu4Q==","shasum":"d19be3f47ce4b2440023586c8da59002e9edc554","tarball":"https://registry.npmjs.org/policystrata/-/policystrata-0.1.5.tgz","fileCount":16,"unpackedSize":252868,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/policystrata@0.1.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAxduJke2ui2Uwprvunrnq+Fo4ceLXqxVfkg1FPZLOlPAiBaI3An6V/MS8eaLQaiPerLU9peHNOi7+1ymg59yqhrDg=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ca5ae254-38b5-49d1-baf5-ead5d0bb58c0"}},"directories":{},"maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/policystrata_0.1.5_1785359968810_0.6684082178979203"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-02T17:02:05.038Z","modified":"2026-07-29T21:19:29.324Z","0.1.0":"2026-07-02T17:02:05.277Z","0.1.1":"2026-07-02T19:35:57.201Z","0.1.2":"2026-07-07T21:43:10.159Z","0.1.3":"2026-07-08T19:02:07.664Z","0.1.4":"2026-07-23T00:59:17.314Z","0.1.5":"2026-07-29T21:19:28.955Z"},"bugs":{"url":"https://github.com/raintree-technology/policystrata/issues"},"license":"MIT","homepage":"https://github.com/raintree-technology/policystrata#readme","keywords":["llm","data-agents","authorization","policy-testing","runtime"],"repository":{"type":"git","url":"git+https://github.com/raintree-technology/policystrata.git","directory":"packages/node"},"description":"TypeScript/Node trace recorder and runtime authorizer for PolicyStrata","maintainers":[{"name":"raintree-technology","email":"admin@raintree.technology"}],"readme":"# PolicyStrata Node SDK\n\nThis package records sanitized agent, tool, SQL, and mutation traces from TypeScript/Node\napplications. Read-tool SQL records are compatible with `policystrata scan` JSONL imports.\nThe scanner/CLI distribution remains the PolicyStrata PyPI package; this directory is the\nTypeScript SDK source and packaging surface.\n\nIt also exposes a deterministic runtime authorizer at `policystrata/runtime`. The scanner remains\na release gate, not a live service dependency; the runtime authorizer is the small in-process helper\napplications can put on their own request path.\n\nInstall the Node runtime from npm:\n\n```bash\nnpm install policystrata\n```\n\n`pip install policystrata` installs the Python CLI and scanner. It does not make\n`policystrata/runtime` importable to Node applications.\n\n```ts\nimport { createPolicyStrataRecorder } from \"policystrata/node\";\n\nconst recorder = createPolicyStrataRecorder({\n  service: \"demo-data-agent\",\n  environment: process.env.NODE_ENV,\n  out: \".policystrata/traces.jsonl\",\n  tenancy: {\n    tenantColumns: [\"transactions.household_id\", \"accounts.household_id\"],\n  },\n});\n\nconst searchTransactions = recorder.wrapTool(\"searchTransactions\", {\n  kind: \"read\",\n  scope: \"household\",\n  handler: async (args, ctx) => {\n    const query = db\n      .select()\n      .from(transactions)\n      .where(eq(transactions.householdId, ctx.householdId));\n\n    recorder.captureQuery(query);\n    return await query;\n  },\n});\n```\n\nBy default the recorder hashes ID fields with a per-recorder HMAC key, drops prompt text,\nredacts raw error messages and SQL literal values, records sanitized argument shape instead of\nargument values, and summarizes result rows as sanitized field names plus row count. Pass a deployment-specific\n`redaction.hashSalt` when traces need stable pseudonymous IDs across recorder instances. With\ndefault ID hashing, scanner-contract `tenant_ids` are omitted rather than HMACed; use\n`redaction.hashIds: false` only for trusted fixture traces that need explicit tenant IDs for real\ndatabase comparison. Structured payloads such as `semantic_ir`, `expected_policy`, mutation, and\naudit metadata are recursively redacted; `semantic_ir.filters.tenant_id` is HMACed under default ID\nhashing and preserved raw only when trusted fixtures set `redaction.hashIds: false`.\n\n## Drizzle\n\nUse `captureQuery(query)` on Drizzle query builders that expose `.toSQL()`, or wrap a client:\n\n```ts\nconst tracedDb = recorder.wrapDrizzleClient(db);\n```\n\nThe proxy captures common execution methods (`execute`, `all`, `get`, `values`, `run`) and query\nbuilders with `.toSQL()` before they execute. For explicit control, prefer `captureQuery()` at the\ntool boundary where request context and release decisions are available.\n\n## Record Types\n\n- `sql_trace`: read-tool SQL records with top-level `sql` and `principal`; trusted fixture traces\n  may also include raw `tenant_ids` for `policystrata scan`.\n- `agent_session`: session metadata such as model, prompt class, available tools, approval policy,\n  and write-tool enablement. Prompt text is omitted unless explicitly enabled.\n- `mutation`: write-tool metadata such as touched table, ownership predicates, written columns, and\n  audit event state. These records intentionally omit top-level read SQL.\n- `tool_execution`: a tool call that did not execute SQL.\n\nThe Python scanner ignores non-SQL SDK records when they appear in the same JSONL file.\n\n## Runtime Authorizer\n\n```ts\nimport { createPolicyStrataAuthorizer } from \"policystrata/runtime\";\n\nconst authorizer = createPolicyStrataAuthorizer(runtimeManifest);\nconst decision = authorizer.authorize({\n  subject: { id: \"user-1\", role: \"owner\" },\n  action: \"read\",\n  resource: \"searchTransactions\",\n  context: {\n    semanticIr: { metric: \"transaction_spend\", dimensions: [\"merchant_name\"] },\n  },\n  mode: \"shadow\",\n});\n```\n\n`authorizeTool()` remains as a compatibility wrapper over the generic API:\n\n```ts\nconst toolDecision = authorizer.authorizeTool({\n  toolName: \"searchTransactions\",\n  userId: \"user-1\",\n  householdId: \"household-1\",\n  role: \"owner\",\n  toolKind: \"read\",\n  allowWriteTools: false,\n  writeState: \"disabled\",\n  approvalRequiredSatisfied: true,\n  approvalState: \"satisfied\",\n  decisionPoint: \"execution\",\n  semanticIr: { metric: \"transaction_spend\", dimensions: [\"merchant_name\"] },\n  mode: \"shadow\",\n});\n```\n\n`authorizeTool()` decisions include operational metadata for application logs and metrics:\n`toolKind`, `decisionPoint`, `writeState`, `approvalState`, `userId`, and `householdId`.\nApproval-required tools may be visible at `decisionPoint: \"pre_model\"` with\n`approvalState: \"pending\"`; the same pending approval is denied at `decisionPoint: \"execution\"`.\n\n`authorizeRelease()` wraps the same API for the paper's release-conformance boundary: a result and\nits lineage may leave only approved boundaries.\n\n```ts\nconst releaseDecision = authorizer.authorizeRelease({\n  subject: { id: \"user-1\", role: \"owner\" },\n  resource: \"searchTransactions\",\n  boundary: \"user\",\n  result: { kind: \"aggregate\", rowCount: 12, containsSensitiveValues: false },\n  lineage: { sources: [\"transactions\"], containsRawRows: false },\n  mode: \"enforce\",\n});\n```\n\nRuntime manifests must default to deny. Unknown tools/resources/actions, unknown roles, missing\napproval, write tools without an application write-tool grant, undeclared semantic metrics or\ndimensions, and release attempts that violate result/lineage/boundary constraints are denied.\n`allowed` is always the deterministic policy decision. `mode` is reported as rollout metadata:\napplications usually log or sample denied shadow decisions, then block the same denied decision only\nafter switching that call site to `mode: \"enforce\"`.\n\n```ts\nif (!decision.allowed && decision.enforcementMode === \"enforce\") {\n  throw new Error(decision.reasons.join(\"; \"));\n}\n```\n\nThe same runtime module evaluates v0.2 gateway events across auth context, retrieval, memory,\ntool, browser/code, SQL, schema binding, output, egress, and trace layers:\n\n```ts\nimport { evaluateRuntimeEvent, sqlRuntimeEvent } from \"policystrata/runtime\";\n\nconst runtimeDecision = evaluateRuntimeEvent(runtimeManifest, sqlRuntimeEvent({\n  eventId: \"evt_1\",\n  project: \"support-bi\",\n  agent: { key: \"support-bi-copilot\" },\n  summary: \"Tenant-scoped support ticket query\",\n  actor: { userId: \"user-1\", tenantId: \"tenant-a\", role: \"support\", purpose: \"support\" },\n  resource: { kind: \"table\", name: \"support_tickets\" },\n  sql: \"select count(*) from support_tickets where tenant_id = $1\",\n}));\n```\n\nRuntime event builders are available for common layers:\n\n- `buildRuntimeEvent()` for explicit low-level events.\n- `sqlRuntimeEvent()` for SQL statement metadata.\n- `toolRuntimeEvent()` for MCP/tool calls and schema refs.\n- `retrievalRuntimeEvent()` for vector/search retrieval evidence.\n- `egressRuntimeEvent()` for outbound webhook/API destinations.\n- `clearanceEvidencePackRuntimeEvent()` for referencing a local `.clearance/evidence-pack.json`\n  artifact in runtime evidence without calling hosted Clearance APIs.\n\n## Next.js Route Handler\n\nUse the runtime helpers in the application request path, not as a hosted dependency:\n\n```ts\nimport { NextResponse } from \"next/server\";\nimport { evaluateRuntimeEvent, sqlRuntimeEvent } from \"policystrata/runtime\";\nimport runtimeManifest from \"@/policystrata.runtime.json\";\n\nexport async function POST(request: Request) {\n  const body = await request.json();\n  const sql = compileTenantScopedSql(body);\n  const decision = evaluateRuntimeEvent(runtimeManifest, sqlRuntimeEvent({\n    eventId: crypto.randomUUID(),\n    project: \"support-bi\",\n    agent: { key: \"support-bi-copilot\" },\n    summary: \"Support ticket query\",\n    actor: {\n      userId: body.userId,\n      tenantId: body.tenantId,\n      role: body.role,\n      purpose: \"support\",\n    },\n    resource: { kind: \"table\", name: \"support_tickets\", tenantId: body.tenantId },\n    sql,\n  }));\n\n  if (!decision.allowed) {\n    return NextResponse.json({ error: decision.reason }, { status: 403 });\n  }\n\n  return NextResponse.json(await runQuery(sql));\n}\n```\n\nFor a customer-hosted sidecar, install `@policystrata/agent-trust-gateway`; it wraps this evaluator\nin an HTTP gateway and strips runtime-event `payload` and fixture-only `expectedDecision` metadata\nbefore control-plane upload by default. The gateway is an application-side enforcement and telemetry\nhelper; it does not replace\n`policystrata scan`, `policystrata doctor`, application authorization, or database controls.\n\nThe runtime manifest schema is available at `policystrata/runtime-manifest.schema.json` and in this\nsource tree at `schema/runtime-manifest.schema.json`. The runtime authorizer is for in-process app\nchecks on tool and release boundaries in the request path. `policystrata scan` remains the\nCI/release evidence gate over exported traces and should not be treated as a live authorization\nservice.\n","readmeFilename":"README.md"}