-
Notifications
You must be signed in to change notification settings - Fork 0
[Draft] feat: Delegation depth tracking — max_delegation_depth (Phase 2) #108
Description
Status: Draft
This is a design draft for Phase 2 of delegation-aware effects.
Phase 1 (delegation=explicit + grants) is tracked in #107.
Feedback and design discussion welcome — nothing is frozen here.
Motivation
Phase 1 introduces a static friction mechanism: callers must explicitly declare grants to invoke delegation=explicit effects. This stops silent propagation at one hop.
But in long delegation chains (A→B→C→D), an explicit grant at each hop still allows the permission to travel arbitrarily far. For highly sensitive or irreversible effects, you may want to limit how many hops a permission can travel, regardless of explicit grants.
This is the dynamic complement to Phase 1's static mechanism.
Proposed Addition
Add optional max_delegation_depth to EffectQualifier:
{
"op": "NET:http_post",
"reversible": false,
"delegation": "explicit",
"max_delegation_depth": 1
}Semantics:
depth=0: only the declaring module may invoke this effect directlydepth=1: the declaring module + one level of delegation- No field (default): unlimited depth (current behavior)
Open Design Questions
1. Static or dynamic?
The core challenge: delegation depth is often determined at runtime (which agent calls which), not at compile time.
- Static approach: define "depth" as the number of module boundaries crossed in the static call graph. Checkable by L2 at compile time, but may be too conservative — a module that conditionally delegates would always be counted.
- Dynamic approach: thread a
delegation_contextthrough runtime execution. More precise, but requires runtime support (executor, or mcp-fw enforcement layer). - Hybrid: static checker warns, runtime enforces.
2. Who enforces it?
- NAIL checker (static): can detect obvious violations at compile time
- mcp-fw (runtime): can track actual delegation chain length per call
This is the primary reason Phase 2 is deferred — the enforcement boundary between NAIL (language) and mcp-fw (runtime) needs to be decided first.
3. Interaction with grants
Does max_delegation_depth=1 mean:
- (a)
grantscan only be declared at depth ≤ 1, or - (b) the effect can only be executed within depth ≤ 1 of its origin?
These have different implications for the checker and the runtime.
Relationship to mcp-fw
mcp-fw already sits in the delegation chain between Claude and MCP servers. Phase 2 would likely be primarily enforced there — tracking delegation_chain per request and blocking calls that exceed max_delegation_depth.
See: https://github.com/zyom45/mcp-fw
References
- arXiv:2602.11865 — Section 2.3 "Zone of Indifference", "Authority Gradient"
- Phase 1: feat: Effect Qualifiers — delegation-aware type system (Phase 1) #107