feat: initial APL Rust implementation.#60
Open
terylt wants to merge 17 commits into
Open
Conversation
…on, cedarling PDP. Signed-off-by: Teryl Taylor <terylt@ibm.com>
…ate() function, and identity sections.
Signed-off-by: Teryl Taylor <terylt@ibm.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat/apl_rust — APL policy engine, identity stack, and pluggable IAM for CPEX Rust
This branch turns the Phase-1a CPEX Rust core into a full policy-driven, identity-aware plugin runtime — a Rust port of the Python
apl-pluginsdesign, with the conditional-effects work (when/do/parallel/taint) and the typed-hook plumbing the original lacked.Scope: 24 commits, 240+ files, ~70k LOC. Tests: 746 across the workspace, 0 fail.
What's new — at a glance
apl-coremask,redact,omit,hash), conditional effects (when:/do:),sequential:/parallel:, content effects, PDP calls, taints, delegation.apl-cmfcpex-core::Extensions→ APL's flatAttributeBag(role.*,perm.*,delegation.*,args.*,result.*,session.*) so predicates can read typed identity without knowing the shape of the underlying extension.apl-cpexPluginInvoker/DelegationInvokertrait implementations that bridge APL's evaluator into typed CPEX hook dispatch (invoke_named::<CmfHook>,::<TokenDelegateHook>). Owns the request-scopedCmfPluginInvoker, the route dispatch plan cache, the session store, and the syntheticAplRouteHandlerplugin that wraps APL eval into a normal cpex-core plugin.cpex-orchestrationrun_brancheshelper —JoinSet + abort_on_deny + per-branch timeout. Used by bothcpex-core::executor::run_concurrent_phaseandapl-core::dispatch_parallel.Identity & delegation
A first-class identity story, distinct from "auth happens upstream":
SubjectExtension/WorkloadIdentityincpex-core::extensions::securitymodel end-user, calling agent, and our gateway as separate typed identities — the basis for predicates likerequire(role.hr),perm.view_ssn, and the new identity-derived session id.DelegationExtension+ theTokenDelegateHookhook type carry an arbitrary chain of acting subjects with attenuated grants. Surfaces in APL asdelegation.depth,delegation.chain[*],delegation.granted_permissions.apl-identity-jwt— JWT identity resolver with configurable claim mapping. Readssub/act.sub/aud/ roles / permissions into the structured extensions; raw claims preserved insubject.claimsfor tier-1 session resolution.apl-delegator-oauth— RFC 8693 token exchange. The mint-on-demand path: APL writesdelegate(workday-oauth, audience: workday-api, permissions: [...]), the delegator hits the IdP, and the outbound request carries a freshly-minted audience-scoped token — never the user's original IdP JWT.apl-delegator-biscuit— Biscuit-based delegation as an alternative to OAuth token-exchange. Reference implementation for IETF draft-prakash-aip-00 (Agent Identity Protocol) "Chained Mode."SessionResolver(apl-cpex/src/session_resolver.rs) —agent.session_id→ JWTsession_idclaim →X-CPEX-Session-Idheader →sha256(sub:caller:gateway)[:16]→ none. Ported from Python apl-plugins, with the agent-tier added so plugins can inject pre-resolved session ids without inventing a new API.PDP integration
APL can defer decisions to an external policy engine via a
pdp(...)step. Two backends ship:apl-pdp-cedar-direct— In-process Cedar evaluation against an embedded policy store. Fast (no network) for tightly-coupled use cases.apl-cedarling— Cedarling-mediated (Janssen) Cedar evaluation. Adds signed policy stores, multi-issuer JWT validation, and (with Lock Server) centralized policy management. Pluggable via thePdpDialectenum so both can coexist on the same route.Plugin ecosystem (proof the framework actually composes)
apl-pii-scanner—cmf.tool_pre_invokeplugin that catches SSN/credit-card/etc. patterns in args. ReturnsPluginViolationwith codepii.detected.apl-audit-logger—cmf.tool_pre_invokeaudit plugin that logs every dispatch including denied ones. Demonstrates the audit/non-blocking plugin pattern.PluginError+PluginViolationtypes, follow thePluginConfig-only constructor convention, and live as their own crates with their ownPluginFactoryimpls.CPEX core changes
The runtime needed several enhancements to support the APL stack. These landed as standalone, generally-useful improvements:
Stepenum collapsed intoEffect.policy:is nowVec<Effect>directly. One IR vocabulary, one dispatch path (dispatch_effect), one static validator walk.Effect::Sequential/Effect::Parallelorchestration (E3): Side-effect lists run in-order-with-halt or concurrently-with-abort-on-deny. Built on the newcpex-orchestration::run_branches. Static parallel-purity validator rejects mutation effects inside parallel blocks at config-load.parallel:blocks are registered with safe modes (Audit / Concurrent / FireAndForget). Sequential / Transform plugins are rejected — their writes would silently vanish in a discarded branch.cpex-core::executor::run_concurrent_phasemigrated from its custom JoinSet machinery to the sharedrun_branches. Fixed a latent panic-index attribution bug in the process.Effect::Taint { scopes: [Session] }now actually labels the session. NewCmfPluginInvoker::apply_session_taintsdrainsRouteDecision.taintsintosecurity.labels; the existingpersist_sessiondiff catches them and writes to theSessionStore. Closes the "policy with side-effects" pitch — writingtaint(audit, session)in YAML actually causes the session to be permanently labelled and observable in subsequent requests.Testing
apl-coreunit + IR + parser + evaluatorapl-cmfend-to-end + bridgeapl-cpexinvokers + visitor + plan + resolvercpex-coreruntime + executor + hookscpex-orchestrationapl-pdp-cedar-direct,apl-cedarling,apl-pii-scanner,apl-audit-logger,apl-delegator-*,apl-identity-jwtMigration notes / breaking changes
apl-corepublic API switched fromevaluate_steps(&[Step], ...)toevaluate_effects(&[Effect], ...).Stepis now a parser-internalpub(crate)type. Callers buildingVec<Step>should switch toVec<Effect>(Effect::When { condition, body, source }replacesStep::Rule(Rule)).&dyn PluginInvokerto&Arc<dyn PluginInvoker>(same forDelegationInvokerandPdpResolver) soEffect::Parallelcan spawn branches across OS threads. Consumers holding concrete types (e.g.Arc::new(CmfPluginInvoker::for_request(...))) need a one-line upcast:let invoker_dyn: Arc<dyn PluginInvoker> = invoker.clone();.CmfPluginInvokerno longer pulls only fromextensions.agent.session_id. The 5-tier resolver kicks in. Existing callers that only setagent.session_idstill work — it's tier 0, highest priority.