@atps/ztip
v0.1.0-alpha.0
Published
Official TypeScript library for ZTIP (Zero-Trust Intent Protocol): root intents, delegation chains, scope monotonicity, and drift classification.
Maintainers
Readme
@atps/ztip
Official TypeScript library for ZTIP (Zero-Trust Intent Protocol), tracking draft-miller-ztip-00.
Pre-1.0 alpha. APIs may change before the stable release. Pin an exact version if you depend on this in non-experimental code.
Part of the Agent Trust Protocol Stack. Depends on @atps/core.
What this package provides
- Root intent + delegated intent construction —
createRootIntent,createDelegatedIntent. Intent hashing useshashIntentfrom@atps/core(canonical SHA-256). - Envelope construction —
createZtipEnvelope(root, chain[])produces a plain-JSON envelope. JOSE/JWS wrapping is a follow-up. - Delegation chain validation —
validateDelegationChainchecks intent hash and per-layer scope monotonicity. - Scope monotonicity —
checkScopeMonotonicityenforces "preserve or narrow only" across patients, visits, actions, tools, data_classes (and any caller-defined axis). - Drift classification —
classifyDriftSignal(root, observed)flags semantic drift between an observed action and the authorized scope. - Policy —
evaluateZtipPolicy({ envelope, observed, mode })returns the canonical decision:allow/observe/deny/human_review, with one of theZTIP_*reason codes.
Reason codes
ZTIP_OK, ZTIP_MISSING_ROOT_INTENT, ZTIP_INTENT_HASH_MISMATCH, ZTIP_DELEGATION_CHAIN_INVALID, ZTIP_SCOPE_EXPANDED, ZTIP_TOOL_OUT_OF_SCOPE, ZTIP_ACTION_OUT_OF_SCOPE, ZTIP_DATA_SCOPE_MISMATCH, ZTIP_INTENT_DRIFT_DETECTED, ZTIP_HUMAN_REVIEW_REQUIRED.
Minimal usage
import {
createRootIntent,
createZtipEnvelope,
evaluateZtipPolicy,
} from "@atps/ztip";
const root = createRootIntent({
originator: "user:alice",
intent_object: {
action: "summarize_visit_note",
target: "patient:patient-123",
scope: {
patients: ["patient-123"],
visits: ["visit-abc"],
actions: ["read", "summarize"],
tools: ["clinicalNotes.read"],
data_classes: ["clinical_note"],
},
},
});
const envelope = createZtipEnvelope(root, []);
const decision = evaluateZtipPolicy({
envelope,
observed: {
action: "infer_causality",
visit_scope: "multiple_visits",
data_scope: ["clinical_note", "prior_visit_history"],
tool: "clinicalNotes.read",
},
mode: "enforce",
});
// decision.result: "deny" | "human_review"
// decision.reason: "ZTIP_SCOPE_EXPANDED" | "ZTIP_INTENT_DRIFT_DETECTED" | ...Test vectors
Conformance vectors live at ../../test-vectors/ztip/. They are currently template JSON pending deterministic signing; the validators here exercise the structural logic.
