Repository navigation
feat(authz): TOTP-armed operator delegation, product half (#7420) - #7486
MScottAdams wants to merge 11 commits into
Conversation
One core arming verb (packages/core/src/authz/delegation) checks a TOTP code from the prompt text, burns its step in lastAcceptedStep inside one locked store step, and writes a time-boxed record (default 12h, max 72h). While the record is live, #7279 harness-attended requests for scope:record-approved-scope and the four release templates complete with provenance delegated-totp in one compare-and-set. Results carry the delegated origin; only the scope-provenance fence (caller-injected delegation) and evaluateClosedVerb (own release verb) accept them, and both stop admitting when the delegation ends. Adds deft delegate enroll|off|status|claude-hook|session-end, the Claude adapter library, release:run acceptance of delegated release grants, the hook-allow helper for the advisory-capable scope-cover condition, docs and the changelog fragment. Installer-area wiring (deposit registration, dispatcher allow, stub) is not in this commit. deft-story: 7420 Refs #7420 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion path (#7420) Deposit one managed UserPromptSubmit group for Claude (deposit and setup wiring, stripped on uninstall and repair). hook-dispatch gets a prompt.submit path that calls the delegation adapter and always exits 0; session.end ends the delegation for the arming session. The generated stub allows a prompt quietly when the pin is missing (outer sha8 aee61ba9 to 869d8615). Refs #7420 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Declare the 11 new numeric constants in the delegation types and the one rethrow in the delegation store. Refs #7420 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…7420) verify:scope-provenance resolves the live TOTP delegation and hands it to the scope-provenance fence, the one reader that admits a delegated approved-scope stamp. kill-switch:on ends any live delegation at once with the kill-switch reason (best effort; the kill record already stops it admitting). Refs #7420 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #7420 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #7420 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…gation # Conflicts: # packages/core/src/authz/delegation/store.test.ts # packages/core/src/authz/delegation/store.ts
|
ended_at: 2026-11-27T21:46:00.753Z |
| if (arg === "--confirm") confirm = true; | ||
| else if (arg === "--replace") replace = true; | ||
| else if (arg === "--json") json = true; | ||
| else if (arg === "--project-root" || arg === "--account") { |
There was a problem hiding this comment.
P2 (0% confidence) — packages/runtime/src/delegate.ts:115 — Enrollment prints the TOTP secret to stdout. Operators’ terminal transcripts or captured command output can retain a credential that the documented phone-only workflow intends to keep out of agent-visible output.
Suggestion
Print only the enrollment URI and avoid writing the raw secret to stdout.
Pipeline annotations (2)
[demoted: missing CWE anchor]
[corroborated: deterministic proximity]
|
| Severity | File | Line | Category | Confidence |
|---|---|---|---|---|
| P2 | packages/runtime/src/human-presence-mint.ts |
500 | Correctness | 50% |
| P2 | packages/core/src/release/run.ts |
634 | Ignored Test Seam | 0% |
Machine-readable findings
{
"schemaVersion": 2,
"findings": [
{
"severity": "P2",
"confidence": 0.5,
"filePath": "packages/runtime/src/human-presence-mint.ts",
"line": 500,
"endLine": 500,
"category": "Correctness",
"reviewKey": "31aaf623528a303c",
"message": "The dedupe marker is created exclusively before the work it guards, and nothing removes it if that work fails. If this call throws (disk full, permission, bad input), the marker stays and every later attempt with the same key returns \"duplicate\", so the work is never done. Write the marker after the work succeeds, or unlink it in the failure path. [corroborated: deterministic proximity] [corroborated: cross-source collapse, llm Non-Atomic Completion]",
"hasSuggestion": false,
"source": "deterministic",
"onDiff": true,
"contested": {
"verdict": "false-positive",
"counterclaim": "The marker is a frozen confirmation-request record, not a dedupe marker guarding the mint work; it is created at request-open (lines 505–520) and later confirmation checks and marks it completed (lines 571–634)."
}
},
{
"severity": "P2",
"confidence": 0,
"filePath": "packages/core/src/release/run.ts",
"line": 634,
"endLine": 634,
"category": "Ignored Test Seam",
"reviewKey": "320630bdd64965e7",
"message": "packages/core/src/release/run.ts:634 — Delegated promote runs bypass injected `runPromote` seams. Operators and test harnesses can unexpectedly invoke real promote logic or fail in dry runs. [reanchored: symbol `runPromote` not found at cited line 634] [corroborated: deterministic proximity]",
"hasSuggestion": true,
"suggestion": "Route delegated promotion through the configured seam.",
"source": "llm",
"onDiff": true,
"contested": {
"verdict": "false-positive",
"counterclaim": "The cited line 634 prints the CHANGELOG heading; promote is wired through `ctx.seams.promote` at line 799, with `defaultRunPromote` only as its fallback."
}
}
],
"omittedCount": 0
}
SLizard: Wide-PR detector summary2 detector finding(s) collapsed into 1 check(s). P0/P1 and security findings that already qualify for inline stay pinned.
Machine-readable collapsed sites{
"schemaVersion": 1,
"kind": "wide-collapse",
"clusters": [
{
"check": "authz-grant-docs-missing-confirm",
"count": 2,
"fileCount": 2,
"maxSeverity": "P2",
"sites": [
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/commands.md",
"line": 428,
"endLine": 428,
"category": "incorrect-documentation",
"reviewKey": "9c37e65cb2e2c67f",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"fingerprint": "eff3b0ec0598fd39",
"tool": "authz-grant-docs-missing-confirm"
},
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/docs/operator-delegation.md",
"line": 56,
"endLine": 56,
"category": "incorrect-documentation",
"reviewKey": "b716d8956da8fce5",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"fingerprint": "61453f9cd2d44c59",
"tool": "authz-grant-docs-missing-confirm"
}
]
}
],
"omittedSiteCount": 0
} |
[High impact] The PR lets an agent use one local TOTP delegation across scope approval and selected release actions. Fix the normal publication commands before merging so they can use valid delegated grants. Findings
Fix with agent prompt### Issue 1
packages/runtime/src/authz.ts:980-981
This branch mints delegated `release-publish` and `release-promote-latest` grants, but `deft release:publish` and its `--promote-latest` form still load only `listActiveHumanGrants`, which excludes delegated origins. Both commands therefore reject a valid grant even while its delegation is live. Only `release:run` supplies delegated candidates.
Include delegated candidates in the normal release gates too, while keeping the live-delegation check in `evaluateClosedVerb`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
This comment has been minimized.
This comment has been minimized.
SLizard: Wide-PR detector summary2 detector finding(s) collapsed into 1 check(s). P0/P1 and security findings that already qualify for inline stay pinned.
Machine-readable collapsed sites{
"schemaVersion": 1,
"kind": "wide-collapse",
"clusters": [
{
"check": "authz-grant-docs-missing-confirm",
"count": 2,
"fileCount": 2,
"maxSeverity": "P2",
"sites": [
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/commands.md",
"line": 428,
"endLine": 428,
"category": "incorrect-documentation",
"reviewKey": "9c37e65cb2e2c67f",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"fingerprint": "eff3b0ec0598fd39",
"tool": "authz-grant-docs-missing-confirm"
},
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/docs/operator-delegation.md",
"line": 56,
"endLine": 56,
"category": "incorrect-documentation",
"reviewKey": "b716d8956da8fce5",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"fingerprint": "61453f9cd2d44c59",
"tool": "authz-grant-docs-missing-confirm"
}
]
}
],
"omittedSiteCount": 0
} |
…gation # Conflicts: # changelog.d/7420-totp-delegation.md
|
| Severity | File | Line | Category | Confidence |
|---|---|---|---|---|
| P2 | packages/runtime/src/human-presence-mint.ts |
500 | Correctness | 50% |
Machine-readable findings
{
"schemaVersion": 2,
"findings": [
{
"severity": "P2",
"confidence": 0.5,
"filePath": "packages/runtime/src/human-presence-mint.ts",
"line": 500,
"endLine": 500,
"category": "Correctness",
"reviewKey": "523eecb1b127ee15",
"message": "The dedupe marker is created exclusively before the work it guards, and nothing removes it if that work fails. If this call throws (disk full, permission, bad input), the marker stays and every later attempt with the same key returns \"duplicate\", so the work is never done. Write the marker after the work succeeds, or unlink it in the failure path. [clustered: deterministic-line-proximity] [corroborated: deterministic proximity]",
"hasSuggestion": false,
"source": "deterministic",
"onDiff": true,
"contested": {
"verdict": "false-positive",
"counterclaim": "This finding describes a dedupe marker, but the code at the cited line handles a missing harness-attended request by printing an error and returning; requests are persisted in `openHarnessAttendedMintRequest` at lines 374–385, and failures return `{ ok: false }` without leaving a marker."
}
}
],
"omittedCount": 0
}
SLizard: Wide-PR detector summary2 detector finding(s) collapsed into 1 check(s). P0/P1 and security findings that already qualify for inline stay pinned.
Machine-readable collapsed sites{
"schemaVersion": 1,
"kind": "wide-collapse",
"clusters": [
{
"check": "authz-grant-docs-missing-confirm",
"count": 2,
"fileCount": 2,
"maxSeverity": "P2",
"sites": [
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/commands.md",
"line": 428,
"endLine": 428,
"category": "incorrect-documentation",
"reviewKey": "9c37e65cb2e2c67f",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"contested": {
"verdict": "false-positive",
"counterclaim": "The cited line is about host-hook spawn gating, not an approval command; the documented approved-scope command at line 165 already includes `--confirm` and says it asks for the typed `mint`."
},
"fingerprint": "eff3b0ec0598fd39",
"tool": "authz-grant-docs-missing-confirm"
},
{
"severity": "P2",
"confidence": 0.95,
"filePath": "content/docs/operator-delegation.md",
"line": 56,
"endLine": 56,
"category": "incorrect-documentation",
"reviewKey": "b716d8956da8fce5",
"message": "[Incorrect Documentation] Approval command is incomplete: the skill grant for authz:grant uses --template / --target but omits --confirm. authz:grant refuses to mint without that flag even in an interactive terminal, so an operator following this instruction cannot create the promotion approval. Add --confirm and mention the typed mint prompt.",
"hasSuggestion": false,
"source": "deterministic",
"fingerprint": "61453f9cd2d44c59",
"tool": "authz-grant-docs-missing-confirm"
}
]
}
],
"omittedSiteCount": 0
} |
There was a problem hiding this comment.
Machine-readable verdict
{
"slizard_verdict": {
"schema_version": 1,
"decision": "comment",
"severity": {
"P0": 0,
"P1": 0,
"P2": 3,
"P3": 3
},
"confidence": 0.6451,
"decision_confidence": 0.4771,
"finding_count": 6,
"findings_by_source": {
"llm": 3,
"deterministic": 8,
"unknown": 0
},
"merge_impact": "non-blocking",
"version": "slizard v0.3.8991",
"skip_llm": false,
"head_sha": "5041d95010a6ec14a291490bbe2c0ef3843a2c66"
}
}🔌 Adapter module PR — wrapper/bridge code detected.
P3 · packages/core/src/scope-provenance/evaluate.ts:205 · confidence 0.09 · fp:887582efe9d331e0
packages/core/src/scope-provenance/evaluate.ts:205 — The fence’s delegation view has no expiry or ended-state to check. A stale view can admit a delegated stamp after its delegation expires or ends.
P3 · packages/runtime/src/delegate-adapter-claude.ts:50-57 · confidence 0.07 · fp:05fda535ae5e4ed1
packages/runtime/src/delegate-adapter-claude.ts:50-57 — The adapter accepts payloads with no event identity. Callers or malformed input can arm a delegation using prompt and session fields from an event the adapter claims not to handle.
P3 · packages/runtime/src/scope-record-approved-scope.ts:783 · confidence 0.00 · fp:f827d55d3046f9a9
packages/runtime/src/scope-record-approved-scope.ts:783 — Delegated widening loses provenance. Operators using delegated authority may get a widened record without the delegation ID and expiry, breaking delegated audit and expiry enforcement.
P2 · packages/runtime/src/human-presence-mint.ts:500 · confidence 0.50 · fp:417a7b4293d4e195
The dedupe marker is created exclusively before the work it guards, and nothing removes it if that work fails. If this call throws (disk full, permission, bad input), the marker stays and every later attempt with the same key returns "duplicate", so the work is never…[truncated]
1 contested by a second-opinion check (listed last); see the Contested block on each inline comment before fixing.
Advisory notes
Observation · packages/runtime/src/delegate.ts:48 · fp:d9db4af87cff6da5
DELEGATE_VERB is defined but never called anywhere in this PR, so the behavior it adds never runs from the code this PR changes (nothing in the diff invokes it). If this is intentional (e.g. exported for external consumers), disregard.
Observation · packages/runtime/src/delegate.ts:48 · fp:9b0dcd933b387eef
DELEGATE_VERB is exported but never imported or referenced in any other file changed by this PR. If this is a new feature, the wiring step (import + call site) may be missing. If it is an intentional library export consumed outside this PR, disregard.
Observation · packages/runtime/src/authz.ts:1032 · fp:3e44202246e9bce9
template was just added to an interface/type in packages/runtime/src/human-presence-mint.ts (DelegatedConfirmQuery) but is hardcoded to null here instead of being accepted as a parameter or derived from existing data, so any value a caller supplies for…[truncated]
Observation · content/docs/scope-provenance.md:36 · fp:077bc0b535a7c32b
Reference to evaluate.ts but this file does not exist in the repository. Verify the path is correct or remove the dangling reference.
Observation · packages/core/src/release/run.ts:647 · fp:506ea7169fbd3606
Function runPromoteOf calls delegatedRunGrant directly and also through runFlipOf (which calls delegatedRunGrant internally), causing redundant invocations of delegatedRunGrant.
P2 · authz-grant-docs-missing-confirm · 2 hits in 2 files
Collapsed 2 detector hit(s) of this check. Sample sites:
content/commands.md:428fp:eff3b0ec0598fd39content/docs/operator-delegation.md:56fp:61453f9cd2d44c59
Note: Additional findings were omitted from this summary due to GitHub's 64KB review body limit — see inline comments on this PR.
Agent verification brief
- PR/CR:
deftai/directive#7486 - Head SHA:
5041d95010a6ec14a291490bbe2c0ef3843a2c66 - Decision: comment
- Highest-risk claims: P2
content/commands.md:428incorrect-documentation (0.95); P2content/docs/operator-delegation.md:56incorrect-documentation (0.95); P2packages/runtime/src/human-presence-mint.ts:500Correctness (0.50) - Reviewed files:
changelog.d/7420-totp-delegation.md,content/commands.md,content/contracts/human-origin-authz.md,content/docs/operator-delegation.md,content/docs/scope-provenance.md,docs/RULE-MAP.md,packages/core/src/authz/delegation/delegation-e2e.test.ts,packages/core/src/content-contracts/standards/approvers_6945.test.ts, +24 more - Skipped files: none
- Evidence sources: static analysis, call graph/blast radius, vector context, deterministic checks
- Known blind spots: Wide PR light mode: 32 changed file(s); priority review limited to 32 file(s) (0 deprioritized). Detectors (inline + extended static) run on the full changed set until static budget expires. Graph, blast-radius, and LLM/index use priority files.; Review resume cache: reused L0 slices for 32/32 unchanged files (#1273).; Background indexing finished after this review started. Vector context may have been stale during analysis — a re-review or the next PR should benefit from the updated index.
- Fingerprints: each finding has
fp:…(16 hex). Collect from bot review bodies or inline slizard-meta.fingerprint. - Label (write+ required):
@slizard label <fp> <fp|tp|risk> [reason]— top-level OK; multi-line batch after@slizard label. fp/risk quiet this PR (posted findings + actionable brief/check summary); tp corpus only. Seedocs/finding-fingerprints.md.
Decision: comment
Merge impact: non-blocking
Review confidence: 0.48
Decision confidence: 0.48
Finding confidence: 0.43
Reason: Findings are advisory under the current severity/confidence policy.
Severity counts: P0: 0, P1: 0, P2: 3, P3: 3
Important files: packages/runtime/src/human-presence-mint.ts (P2, 1 finding(s), confidence 0.50); content/commands.md (P2, 1 finding(s), confidence 0.95); content/docs/operator-delegation.md (P2, 1 finding(s), confidence 0.95)
Review scope: 32 files, 2491 additions, 46 deletions
Estimated LLM cost for this review: ~$0.008 (estimate from list prices, not a charge).
slizard v0.3.8991
| if (delegated.completion !== null) { | ||
| return mintDelegatedTemplateGrant(args, delegated.completion); |
There was a problem hiding this comment.
Publication ignores delegated grants
This branch mints delegated release-publish and release-promote-latest grants, but deft release:publish and its --promote-latest form still load only listActiveHumanGrants, which excludes delegated origins. Both commands therefore reject a valid grant even while its delegation is live. Only release:run supplies delegated candidates.
Include delegated candidates in the normal release gates too, while keeping the live-delegation check in evaluateClosedVerb.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/runtime/src/authz.ts
Line: 980-981
Comment:
**Publication ignores delegated grants**
This branch mints delegated `release-publish` and `release-promote-latest` grants, but `deft release:publish` and its `--promote-latest` form still load only `listActiveHumanGrants`, which excludes delegated origins. Both commands therefore reject a valid grant even while its delegation is live. Only `release:run` supplies delegated candidates.
Include delegated candidates in the normal release gates too, while keeping the live-delegation check in `evaluateClosedVerb`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
TOTP-armed operator delegation (#7420). The operator enrolls a TOTP secret once in a terminal (
deft delegate enroll), then arms a time-boxed delegation from chat (deft delegate on [<ttl>] <code>; default 12h, max 72h). While it is live, harness-attendedscope:record-approved-scopeand the four release grants complete with provenancedelegated-totp. Each result is accepted only by the scope-provenance fence orevaluateClosedVerb, and stops admitting when the delegation ends (delegate off, TTL, session end, UAT start, kill switch, terminalauthz:revoke).Limit: delegated approved-scope stamps admit locally only, not on CI, because the delegation store is local to the operator machine. CI cannot see it, so a delegated stamp does not satisfy the CI fence.
Strength: parity of forging effort with the terminal mint, with a wider blast radius. The intent-constraint record for this story landed first (#7477) on the merge base, and the protected authz half landed in #7482 (class 4, #4980). This PR is the product half: the
delegatecommand, hooks, scope-provenance fence, release wiring, docs and the end-to-end test.Installer-area parts (agent-hooks, setup-wiring, host-hook-outer) were approved by Scott for this story.
Related Issues
deft-story: 7420
Refs #7420
Documentation impact
change_class: add
surfaces: command:delegate
rationale: "New delegate command documented in content/commands.md and content/docs/operator-delegation.md; contract and scope-provenance docs updated."
Checklist
changelog.d/7420-totp-delegation.mdfragment landed with feat(authz): delegation store, arm, TOTP and delegated origin (#7420) #7482.🤖 Generated with Claude Code