Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(vaults): auto-resume the requesting session when a vault request resolves (P4) (#785)
Call Whitec2ba6cc75de9
diff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.pyindex 08490774d..5c2e3bf36 100644--- a/core/scheduled_tasks.py+++ b/core/scheduled_tasks.py@@ -22,7 +22,7 @@ from sqlalchemy.exc import SQLAlchemyErrorfrom config import pathsfrom core.message_context import resolve_context_platformfrom modules.im import MessageContext-from storage.db import create_sqlite_engine+from storage.db import create_sqlite_engine, get_cached_sqlite_enginefrom storage.background import SQLiteBackgroundTaskStorefrom storage.models import agent_sessions, scope_settings, scopesfrom storage.pagination import PageRequest, PageResult, page_sequence@@ -293,6 +293,40 @@ def resolve_session_id_target(session_id: str, *, db_path: Optional[Path] = None)+def enqueue_session_callback(+ request_store: "TaskExecutionStore",+ *,+ session_id: str,+ message: str,+ source_actor: str,+ parent_run_id: Optional[str] = None,+) -> Optional["TaskExecutionRequest"]:+ """Enqueue a callback turn into an existing agent session — the shared entry used by Agent+ Run / watch / scheduled-task callbacks and vault-request auto-resume. Resolves the session's+ agent/backend/model target and enqueues an ``agent_run`` with ``source_kind="callback"`` so+ the running scheduler dispatches it. Returns ``None`` when there is nothing to send;+ ``resolve_session_id_target`` raises for an unresolvable/archived session (caller handles).+ """+ session_id = (session_id or "").strip()+ if not session_id or not (message or "").strip():+ return None+ target = resolve_session_id_target(session_id)+ return request_store.enqueue_agent_run(+ session_id=session_id,+ session_key=target.session_key.to_key(),+ message=message,+ agent_name=target.agent_name,+ agent_id=target.agent_id,+ agent_backend=target.agent_backend,+ model=target.model,+ reasoning_effort=target.reasoning_effort,+ session_policy="existing",+ source_kind="callback",+ source_actor=source_actor,+ parent_run_id=parent_run_id,+ )++def _thread_id_from_session_anchor(anchor: str, *, platform: str, scope_id: str) -> Optional[str]:if not anchor:return None@@ -1565,6 +1599,10 @@ class ScheduledTaskService:except Exception:self._drain_dirty = Trueraise+ # Vault requests resolve via the web/API layer, which emits no run-store change,+ # so sweep for owed auto-resume callbacks every tick — a cheap indexed lookup that+ # no-ops when nothing is pending.+ await self._drain_vault_callbacks()await asyncio.sleep(2)except asyncio.CancelledError:raise@@ -1702,27 +1740,83 @@ class ScheduledTaskService:self.request_store.update_callback_status(run_id, status="sent", callback_run_id=callback_run.id)self._drain_dirty = True+ async def _drain_vault_callbacks(self) -> None:+ """Auto-resume the requesting session when a vault request reaches a terminal state.++ Mirrors :meth:`_drain_callbacks` but for ``vault_requests`` (which resolve outside the run+ store): each row marked ``callback_status='pending'`` is turned into one callback turn via+ the shared :func:`enqueue_session_callback` entry, then marked ``sent``/``skipped``/+ ``failed``. Delivery is at-least-once, matching the run-store callback drain: enqueue and+ the ``sent`` mark are separate writes, so a crash between them re-sends on the next tick.+ Per-row isolation keeps one bad row from aborting the batch or being retried forever.+ """+ if not self._owns_service_instance():+ return+ from storage import vault_service++ # Runs every tick, so use the process-local cached engine (never dispose it) rather than+ # allocating a fresh engine per sweep.+ engine = get_cached_sqlite_engine(paths.get_sqlite_state_path())+ try:+ with engine.begin() as conn:+ # Expiry is lazy (only on request reads), so proactively expire overdue pending+ # requests here — otherwise an unattended timed-out request would never arm its+ # callback until some unrelated read touched it. Both happen in one pass.+ vault_service.expire_overdue_requests(conn)+ pending = vault_service.list_pending_request_callbacks(conn)+ except Exception as exc:+ logger.error("Vault request callback sweep failed to load: %s", exc, exc_info=True)+ return+ for row in pending:+ request_id = str(row.get("id") or "")+ if not request_id:+ continue+ # Resolve + enqueue as one guarded step so a bad row is marked (not left to retry+ # forever) and does not abort the rest of the batch.+ status = "skipped"+ try:+ with engine.begin() as conn:+ ready = vault_service.request_callback_ready(conn, row)+ if not ready:+ # Approved access grant not delivery-ready yet (protected relay in flight);+ # leave callback_status='pending' and retry on a later tick.+ continue+ plan = vault_service.resolve_request_callback(row)+ if plan is not None:+ enqueue_session_callback(+ self.request_store,+ session_id=plan.session_id,+ message=plan.message,+ source_actor=f"vault:{request_id}",+ )+ status = "sent"+ except ValueError:+ status = "skipped" # session archived / not a valid target — nothing to resume+ except Exception as exc:+ logger.error("Vault request callback failed for %s: %s", request_id, exc, exc_info=True)+ status = "failed"+ try:+ with engine.begin() as conn:+ vault_service.mark_request_callback(conn, request_id, status=status)+ except Exception as exc:+ # Leave callback_status='pending' → retried next tick (bounded, transient).+ logger.error("Vault request callback mark failed for %s: %s", request_id, exc, exc_info=True)+ continue+ if status == "sent":+ # A callback run was enqueued into the run store; drain it promptly.+ self._drain_dirty = True+def _enqueue_callback_run(self, run: dict[str, Any]) -> Optional[TaskExecutionRequest]:callback_session_id = str(run.get("callback_session_id") or "").strip()if not callback_session_id:return None- target_info = resolve_session_id_target(callback_session_id)- message = self._build_callback_message(run)- if not message.strip():- return None- return self.request_store.enqueue_agent_run(+ run_id = str(run.get("id") or "")+ return enqueue_session_callback(+ self.request_store,session_id=callback_session_id,- session_key=target_info.session_key.to_key(),- message=message,- agent_name=target_info.agent_name,- agent_id=target_info.agent_id,- agent_backend=target_info.agent_backend,- model=target_info.model,- reasoning_effort=target_info.reasoning_effort,- session_policy="existing",- source_kind="callback",- source_actor=str(run.get("id") or ""),- parent_run_id=str(run.get("id") or "") or None,+ message=self._build_callback_message(run),+ source_actor=run_id,+ parent_run_id=run_id or None,)def _build_callback_message(self, run: dict[str, Any]) -> str:diff --git a/storage/alembic/versions/20260705_0028_vault_request_callback_status.py b/storage/alembic/versions/20260705_0028_vault_request_callback_status.pynew file mode 100644index 000000000..1d02e9a92--- /dev/null+++ b/storage/alembic/versions/20260705_0028_vault_request_callback_status.py@@ -0,0 +1,37 @@+"""vault request auto-resume callback status++Revision ID: 20260705_0028+Revises: 20260704_0027+Create Date: 2026-07-05+"""++from __future__ import annotations++import sqlalchemy as sa+from alembic import op++revision = "20260705_0028"+down_revision = "20260704_0027"+branch_labels = None+depends_on = None+++def _columns(table_name: str) -> set[str]:+ bind = op.get_bind()+ return {row[1] for row in bind.exec_driver_sql(f'pragma table_info("{table_name}")')}+++def _add_column_if_missing(table_name: str, column_name: str, column: sa.Column) -> None:+ if column_name not in _columns(table_name):+ op.add_column(table_name, column)+++def upgrade() -> None:+ _add_column_if_missing("vault_requests", "callback_status", sa.Column("callback_status", sa.String(), nullable=True))+ op.create_index("ix_vault_requests_callback_status", "vault_requests", ["callback_status", "decided_at"], if_not_exists=True)+++def downgrade() -> None:+ op.drop_index("ix_vault_requests_callback_status", table_name="vault_requests", if_exists=True)+ # SQLite cannot drop columns without a table rebuild; keep the additive field on downgrade.+ return Nonediff --git a/storage/models.py b/storage/models.pyindex ba58132b3..671a445c3 100644--- a/storage/models.py+++ b/storage/models.py@@ -510,7 +510,13 @@ vault_requests = Table(Column("created_at", String, nullable=False),Column("decided_at", String, nullable=True),Column("expires_at", String, nullable=True),+ # Auto-resume callback bookkeeping: set to "pending" when a request transitions to a+ # terminal state (approved/denied/fulfilled/failed/expired) so the daemon sweep enqueues+ # exactly one callback turn to the requesting session, then "sent"/"skipped". NULL = no+ # callback owed (e.g. rows created before this feature, or born-fulfilled).+ Column("callback_status", String, nullable=True),Index("ix_vault_requests_status_created", "status", "created_at"),+ Index("ix_vault_requests_callback_status", "callback_status", "decided_at"),)event.listen(vault_requests,diff --git a/storage/vault_service.py b/storage/vault_service.pyindex 270f596e0..86eb9a942 100644--- a/storage/vault_service.py+++ b/storage/vault_service.py@@ -852,7 +852,7 @@ def _expire_pending_request_rows(result = conn.execute(vault_requests.update().where(vault_requests.c.id == row["id"], vault_requests.c.status == "pending")- .values(status="expired", decided_at=now)+ .values(status="expired", decided_at=now, callback_status="pending"))if result.rowcount != 1:continue@@ -918,6 +918,167 @@ def _payload_session_id(payload: Any) -> str | None:return None+# --- Auto-resume callbacks (P4) -------------------------------------------------------------+#+# When a request reaches a terminal state its transition also sets ``callback_status="pending"``.+# The daemon sweep (``core.scheduled_tasks``) drains these: for each it resolves a callback plan+# and enqueues exactly one callback turn to the requesting session — the same entry Agent Run /+# watch / scheduled tasks use — then marks the row ``sent`` / ``skipped``. The atomic+# ``WHERE status='pending'`` claim on every transition makes this exactly-once (a re-resolve+# updates zero rows, so ``callback_status`` is never re-armed).+++@dataclass(frozen=True)+class PendingRequestCallback:+ """A resolved request's auto-resume plan: wake ``session_id`` with ``message``."""++ request_id: str+ session_id: str+ message: str+++def _request_callback_disabled(row: dict[str, Any]) -> bool:+ requester, _ = _request_json_payloads(row)+ return bool(isinstance(requester, dict) and requester.get("callback_disabled"))+++def _build_request_callback_message(row: dict[str, Any]) -> str:+ """Agent-facing text delivered to the requesting session when a request resolves."""+ request_type = str(row.get("request_type") or "")+ status = str(row.get("status") or "")+ request_id = str(row.get("id") or "").strip()+ name = str(row.get("secret_name") or "").strip()+ label = f" '{name}'" if name else ""+ subject = {+ "provision": f"vault request for the secret{label}",+ "access": f"vault access request{label}",+ "sign": f"signature request{label}",+ }.get(request_type, f"vault request{label}")++ if status in {"approved", "fulfilled"}:+ if request_type == "provision":+ usage = f" You can use it, e.g. `vibe vault run --env {name} -- <command>`." if name else ""+ return f"The user provided your {subject}; the secret is now available.{usage} Continue the task."+ if request_type == "access":+ return f"The user approved your {subject}; the grant is ready. Continue the task."+ if request_type == "sign":+ # The public signature is the deliverable — the agent needs it to continue. It's stored+ # in the request; retrieving it by id returns immediately (the request is already done).+ retrieve = f" Retrieve the signature with: vibe vault await {request_id}." if request_id else ""+ return f"The user approved and completed your {subject}.{retrieve} Then continue the task."+ return f"The user approved your {subject}. Continue the task."+ if status == "denied":+ return f"The user declined your {subject}. Do not retry — adjust your approach or ask the user how to proceed."+ if status == "failed":+ # 'failed' is a signing error (transient/crypto/browser), NOT a user decision — retry is fine.+ return f"Your {subject} could not be completed due to a signing error (not a user decision). You may retry if it still makes sense."+ if status == "expired":+ return f"Your {subject} expired without a decision. Re-request it if you still need it, or continue without."+ return ""+++def resolve_request_callback(row: dict[str, Any]) -> PendingRequestCallback | None:+ """Plan the auto-resume callback for a resolved request, or ``None`` to skip.++ Skipped when the requester opted out (``--no-callback``), the request has no originating+ session, or the terminal state maps to no message.+ """+ request_id = str(row.get("id") or "").strip()+ if not request_id or _request_callback_disabled(row):+ return None+ session_id = _request_session_id(row)+ if not session_id:+ return None+ message = _build_request_callback_message(row)+ if not message.strip():+ return None+ return PendingRequestCallback(request_id=request_id, session_id=session_id, message=message)+++def _request_covering_grant_payloads(+ conn: Connection,+ row: dict[str, Any],+ *,+ cache: VaultGrantRuntimeCache = GRANT_RUNTIME_CACHE,+) -> list[dict[str, Any]]:+ request_members = set(_request_member_names(row))+ session_id = _request_session_id(row)+ if not request_members or not session_id:+ return []+ try:+ purpose = _request_grant_option(row).purpose+ except InvalidRequestError:+ return []++ expire_grants(conn, cache=cache)+ rows = conn.execute(+ select(vault_grants)+ .where(+ vault_grants.c.status.in_(ACTIVE_GRANT_STATES),+ vault_grants.c.session_id == session_id,+ vault_grants.c.purpose == purpose,+ )+ .order_by(vault_grants.c.created_at.desc(), vault_grants.c.id.desc())+ ).mappings()+ grants: list[dict[str, Any]] = []+ for grant_row in rows:+ grant = dict(grant_row)+ grant_members = {str(name) for name in (_loads(grant.get("member_snapshot")) or []) if str(name)}+ if request_members.issubset(grant_members):+ grants.append(_grant_payload(conn, grant, cache=cache))+ return grants+++def request_callback_ready(conn: Connection, row: dict[str, Any]) -> bool:+ """Whether a resolved request's callback may be delivered yet (vs. deferred to a later sweep).++ An approved *access* request is only usable once a covering grant is delivery-ready: for a+ protected secret the DEKs are relayed to the resident agent AFTER approval, so resuming the+ agent before then would hand it a grant whose ``delivery_ready`` is still false. Sibling access+ requests approved by the same grant do not own ``vault_grants.request_id``, so readiness follows+ the active grant for the request's session/purpose whose member snapshot covers the request's+ members. Every other terminal state (provision/sign/deny/expire, and standard grants which are+ ready on approval) is deliverable immediately; no active covering grant does not block forever.+ """+ if str(row.get("request_type") or "") == "access" and str(row.get("status") or "") == "approved":+ grants = _request_covering_grant_payloads(conn, row)+ if grants and not any(grant.get("delivery_ready") for grant in grants):+ return False+ return True+++def expire_overdue_requests(conn: Connection) -> None:+ """Flip any overdue pending requests to ``expired`` (arming their callback) proactively.++ Expiry is otherwise lazy (only on request reads), so an unattended timed-out request would+ never auto-resume its session until some unrelated read happened to touch it. The callback+ sweep calls this first so overdue requests are expired and picked up in the same pass.+ """+ _expire_pending_requests(conn)+++def list_pending_request_callbacks(conn: Connection, *, limit: int | None = None) -> list[dict[str, Any]]:+ """Terminal requests owed an auto-resume callback (``callback_status='pending'``)."""+ query = (+ select(vault_requests)+ .where(vault_requests.c.callback_status == "pending")+ .order_by(vault_requests.c.decided_at, vault_requests.c.id)+ )+ if limit is not None:+ query = query.limit(limit)+ rows = conn.execute(query).mappings()+ return [dict(row) for row in rows]+++def mark_request_callback(conn: Connection, request_id: str, *, status: str) -> None:+ """Record the outcome of an auto-resume callback (``sent`` / ``skipped`` / ``failed``)."""+ conn.execute(+ vault_requests.update()+ .where(vault_requests.c.id == request_id)+ .values(callback_status=status)+ )++def _request_card(row: dict[str, Any]) -> dict[str, Any]:_, delivery = _request_json_payloads(row)card = delivery.get("card") if isinstance(delivery, dict) else None@@ -1091,7 +1252,7 @@ def fulfill_pending_provision_requests_for_secret(vault_requests.c.secret_name == name,vault_requests.c.status == "pending",)- .values(status="fulfilled", decided_at=decided_at or _now())+ .values(status="fulfilled", decided_at=decided_at or _now(), callback_status="pending"))return int(result.rowcount or 0)@@ -1187,7 +1348,7 @@ def create_secret(result = conn.execute(vault_requests.update().where(vault_requests.c.id == provision_row["id"], vault_requests.c.status == "pending")- .values(status="fulfilled", decided_at=decided_at)+ .values(status="fulfilled", decided_at=decided_at, callback_status="pending"))if result.rowcount != 1:raise InvalidRequestError("provision request is not pending")@@ -2006,7 +2167,7 @@ def complete_sign_request(claim = conn.execute(vault_requests.update().where(vault_requests.c.id == request_id, vault_requests.c.request_type == "sign", vault_requests.c.status == row_dict["status"])- .values(status="approved", decided_at=_now(), delivery=json.dumps(completed_delivery))+ .values(status="approved", decided_at=_now(), delivery=json.dumps(completed_delivery), callback_status="pending"))if claim.rowcount != 1:raise InvalidRequestError("sign request is not pending")@@ -2079,7 +2240,7 @@ def fail_sign_request(conn: Connection, request_id: str, *, reason: str | None =result = conn.execute(vault_requests.update().where(vault_requests.c.id == request_id, vault_requests.c.status == "signing")- .values(status="failed", decided_at=_now(), delivery=json.dumps(delivery_payload))+ .values(status="failed", decided_at=_now(), delivery=json.dumps(delivery_payload), callback_status="pending"))if result.rowcount != 1:raise InvalidRequestError("sign request is not signing")@@ -2140,7 +2301,7 @@ def deny_request(result = conn.execute(vault_requests.update().where(vault_requests.c.id == request_id, vault_requests.c.status == "pending")- .values(status="denied", decided_at=decided_at)+ .values(status="denied", decided_at=decided_at, callback_status="pending"))if result.rowcount != 1:raise InvalidRequestError("request is not pending")@@ -2496,7 +2657,7 @@ def _approve_sibling_access_requests_for_grant(result = conn.execute(vault_requests.update().where(vault_requests.c.id == row["id"], vault_requests.c.status == "pending")- .values(status="approved", decided_at=decided_at)+ .values(status="approved", decided_at=decided_at, callback_status="pending"))if result.rowcount != 1:continue@@ -2549,7 +2710,7 @@ def restore_access_request_after_failed_grant(result = conn.execute(vault_requests.update().where(vault_requests.c.id == row["id"], vault_requests.c.status == "approved")- .values(status="pending", decided_at=None)+ .values(status="pending", decided_at=None, callback_status=None))if result.rowcount != 1:continue@@ -2613,7 +2774,7 @@ def create_grant(vault_requests.c.request_type == "access",vault_requests.c.status == "pending",)- .values(status="approved", decided_at=decided_at)+ .values(status="approved", decided_at=decided_at, callback_status="pending"))if claim.rowcount != 1:raise InvalidRequestError("grant approval request is not pending")@@ -2668,7 +2829,7 @@ def create_grant(conn.execute(vault_requests.update().where(vault_requests.c.id == request_id)- .values(status="pending", decided_at=None)+ .values(status="pending", decided_at=None, callback_status=None))raiseaudit(diff --git a/tests/test_sqlite_state_migration.py b/tests/test_sqlite_state_migration.pyindex aafdfa6e5..df0c739d6 100644--- a/tests/test_sqlite_state_migration.py+++ b/tests/test_sqlite_state_migration.py@@ -17,7 +17,7 @@ from storage.models import metadatafrom storage.settings_service import SQLiteSettingsService-HEAD_REVISION = "20260704_0027"+HEAD_REVISION = "20260705_0028"def _index_sql(conn: sqlite3.Connection, name: str) -> str:diff --git a/tests/test_vault_cli.py b/tests/test_vault_cli.pyindex 057a98e44..6d1d2b2ba 100644--- a/tests/test_vault_cli.py+++ b/tests/test_vault_cli.py@@ -16,7 +16,7 @@ from unittest.mock import Mockimport pytestfrom storage import vault_service-from storage.models import vault_audit, vault_grants+from storage.models import vault_audit, vault_grants, vault_requestsfrom storage.vault_crypto import Sealedfrom vibe import cli@@ -1818,7 +1818,8 @@ def test_export_is_deprecated_and_does_not_touch_db(capfd):assert vault_service.list_secrets(conn) == []-def test_request_creates_pending(capfd):+def test_request_creates_pending(capfd, monkeypatch):+ monkeypatch.delenv("AVIBE_SESSION_ID", raising=False)code = cli.cmd_vault_request(_ns(name="WANTED_KEY", reason="need it"))captured = capfd.readouterr()assert code == 0@@ -1826,6 +1827,7 @@ def test_request_creates_pending(capfd):assert payload["secret_name"] == "WANTED_KEY"assert payload["status"] == "pending"assert payload["request_id"].startswith("vrq_")+ assert "vibe vault await" in payload["message"]def test_request_accepts_spec_path(tmp_path, capfd):@@ -1842,14 +1844,18 @@ def test_request_accepts_spec_path(tmp_path, capfd):encoding="utf-8",)- code = cli.cmd_vault_request(_ns(name="GITHUB_TOKEN", reason="need PR status", spec=str(spec_path)))+ code = cli.cmd_vault_request(+ _ns(name="GITHUB_TOKEN", reason="need PR status", spec=str(spec_path), session_id="ses_cli")+ )payload = json.loads(capfd.readouterr().out)assert code == 0assert payload["request"]["card"]["spec"]["tags"] == ["github", "skill:github-pr-review"]assert payload["request"]["card"]["spec"]["policy"]["allowed_hosts"] == ["api.github.com"]assert payload["request"]["card"]["spec"]["links"] == {"skills": ["github-pr-review"]}- assert payload["request_id"] in payload["message"]+ # Default (callback) mode: the agent is auto-resumed on resolution rather than told to poll a+ # request id; the id stays in payload["request_id"]. The message still names the affordance.+ assert "resumes automatically" in payload["message"]assert "Provide secret" in payload["message"]assert "Add secret" not in payload["message"]@@ -1881,7 +1887,9 @@ def test_request_for_existing_secret_returns_fulfilled(tmp_path, capfd, monkeypadef test_request_wait_outputs_fulfilled_request(capfd, monkeypatch):def wait_mock(request_id, *, timeout, poll_interval=2.0):- return {"id": request_id, "status": "fulfilled", "request_type": "provision", "secret_name": "WAIT_KEY"}+ with cli._open_vault_engine().begin() as conn:+ vault_service.fulfill_pending_provision_requests_for_secret(conn, "WAIT_KEY")+ return vault_service.get_request(conn, request_id, audience=vault_service.REQUEST_AUDIENCE_AGENT)monkeypatch.setattr(cli, "_wait_for_provision", wait_mock)@@ -1889,6 +1897,9 @@ def test_request_wait_outputs_fulfilled_request(capfd, monkeypatch):payload = json.loads(capfd.readouterr().out)assert payload["status"] == "fulfilled"assert payload["request"]["status"] == "fulfilled"+ with cli._open_vault_engine().connect() as conn:+ status = conn.execute(vault_requests.select().where(vault_requests.c.id == payload["request_id"])).mappings().one()+ assert status["callback_status"] == "skipped"def test_request_wait_returns_denied_without_timeout(capfd, monkeypatch):@@ -1903,6 +1914,46 @@ def test_request_wait_returns_denied_without_timeout(capfd, monkeypatch):assert payload["details"]["request_id"]+ ("terminal_status", "error_code"),+ [+ ("denied", "request_denied"),+ ("expired", "request_expired"),+ ("failed", "request_failed"),+ ],+)+def test_request_wait_suppresses_callback_for_terminal_error_outcomes(+ terminal_status, error_code, capfd, monkeypatch+):+ def wait_mock(request_id, *, timeout, poll_interval=2.0):+ with cli._open_vault_engine().begin() as conn:+ if terminal_status == "denied":+ vault_service.deny_request(conn, request_id)+ else:+ conn.execute(+ vault_requests.update()+ .where(vault_requests.c.id == request_id)+ .values(+ status=terminal_status,+ decided_at="2026-01-01T00:00:00+00:00",+ callback_status="pending",+ )+ )+ return vault_service.get_request(conn, request_id, audience=vault_service.REQUEST_AUDIENCE_AGENT)++ monkeypatch.setattr(cli, "_wait_for_provision", wait_mock)++ assert cli.cmd_vault_request(_ns(name="WAIT_KEY", wait=30)) == 1+ payload = json.loads(capfd.readouterr().err)++ assert payload["code"] == error_code+ request_id = payload["details"]["request_id"]+ with cli._open_vault_engine().connect() as conn:+ row = conn.execute(vault_requests.select().where(vault_requests.c.id == request_id)).mappings().one()+ assert row["status"] == terminal_status+ assert row["callback_status"] == "skipped"++def test_wait_for_provision_returns_denied_request():with cli._open_vault_engine().begin() as conn:req = vault_service.create_provision_request(conn, "WAIT_KEY")diff --git a/tests/test_vault_request_callbacks.py b/tests/test_vault_request_callbacks.pynew file mode 100644index 000000000..355875641--- /dev/null+++ b/tests/test_vault_request_callbacks.py@@ -0,0 +1,420 @@+"""P4: vault-request auto-resume callbacks.++A request transition to a terminal state arms ``callback_status='pending'``; the daemon sweep+turns each armed row into exactly one callback turn to the requesting session via the shared+``enqueue_session_callback`` entry (``source_kind='callback'``), then marks it sent/skipped.+"""++from __future__ import annotations++import json+from datetime import datetime, timedelta, timezone++import pytest+from sqlalchemy import select++from storage import vault_service as vs+from storage.db import create_sqlite_engine+from storage.models import metadata, vault_requests+from storage.vault_crypto import Sealed+++def vault(tmp_path):+ vs.GRANT_RUNTIME_CACHE.clear()+ engine = create_sqlite_engine(tmp_path / "vault_cb.sqlite")+ metadata.create_all(engine)+ return engine+++def _sealed(suffix: str = "1") -> Sealed:+ return Sealed(ciphertext=f"ct-{suffix}", nonce=f"n-{suffix}", wrap_meta=f"wm-{suffix}")+++def _callback_status(conn, request_id: str):+ return conn.execute(+ select(vault_requests.c.callback_status).where(vault_requests.c.id == request_id)+ ).scalar_one()+++def _row(conn, request_id: str) -> dict:+ return dict(conn.execute(select(vault_requests).where(vault_requests.c.id == request_id)).mappings().one())+++def _grant_from_request(conn, request: dict) -> dict:+ option = request["card"]["grant_options"][0]+ return vs.create_grant(+ conn,+ member_names=option["member_snapshot"],+ source_selector=option["source_selector"],+ purpose=option["purpose"],+ request_id=request["id"],+ cache_ready=True,+ )+++def _grant_from_request_with_cache_ready(conn, request: dict, *, cache_ready: bool) -> dict:+ option = request["card"]["grant_options"][0]+ return vs.create_grant(+ conn,+ member_names=option["member_snapshot"],+ source_selector=option["source_selector"],+ purpose=option["purpose"],+ request_id=request["id"],+ cache_ready=cache_ready,+ )+++# --- terminal transitions arm the callback --------------------------------------------------+++def test_access_approval_arms_callback(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="A_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "A_KEY", requester={"session_id": "ses_a"})+ _grant_from_request(conn, req)+ assert _callback_status(conn, req["id"]) == "pending"+ plan = vs.resolve_request_callback(_row(conn, req["id"]))+ assert plan is not None+ assert plan.session_id == "ses_a"+ assert "approved" in plan.message.lower()+++def test_deny_arms_callback(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="D_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "D_KEY", requester={"session_id": "ses_d"})+ vs.deny_request(conn, req["id"])+ assert _callback_status(conn, req["id"]) == "pending"+ plan = vs.resolve_request_callback(_row(conn, req["id"]))+ assert plan is not None and "declined" in plan.message.lower()+++def test_provision_fulfill_arms_callback(vault):+ with vault.begin() as conn:+ req = vs.create_provision_request(conn, "NEW_KEY", requester={"session_id": "ses_p"})+ assert req["status"] == "pending"+ assert vs.fulfill_pending_provision_requests_for_secret(conn, "NEW_KEY") == 1+ assert _callback_status(conn, req["id"]) == "pending"+ plan = vs.resolve_request_callback(_row(conn, req["id"]))+ assert plan is not None and "provided" in plan.message.lower()+++def test_expiry_arms_callback(vault):+ past = (datetime.now(timezone.utc) - timedelta(minutes=1)).isoformat()+ with vault.begin() as conn:+ vs.create_secret(conn, name="E_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "E_KEY", requester={"session_id": "ses_e"})+ conn.execute(vault_requests.update().where(vault_requests.c.id == req["id"]).values(expires_at=past))+ expired = vs._load_request_row(conn, req["id"]) # lazy expiry on read+ assert expired["status"] == "expired"+ assert _callback_status(conn, req["id"]) == "pending"+ plan = vs.resolve_request_callback(_row(conn, req["id"]))+ assert plan is not None and "expired" in plan.message.lower()+++# --- skip conditions ------------------------------------------------------------------------+++def test_optout_arms_but_resolves_to_skip(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="O_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "O_KEY", requester={"session_id": "ses_o", "callback_disabled": True})+ _grant_from_request(conn, req)+ # Transition still arms the row (dumb marker); the sweep decides to skip.+ assert _callback_status(conn, req["id"]) == "pending"+ assert vs.resolve_request_callback(_row(conn, req["id"])) is None+++def test_no_session_resolves_to_skip(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="N_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "N_KEY") # no requester → no session+ _grant_from_request(conn, req)+ assert vs.resolve_request_callback(_row(conn, req["id"])) is None+++# --- sweep bookkeeping + exactly-once -------------------------------------------------------+++def test_list_and_mark_are_exclusive(vault):+ with vault.begin() as conn:+ req = vs.create_provision_request(conn, "L_KEY", requester={"session_id": "ses_l"})+ vs.fulfill_pending_provision_requests_for_secret(conn, "L_KEY")+ assert [r["id"] for r in vs.list_pending_request_callbacks(conn)] == [req["id"]]+ vs.mark_request_callback(conn, req["id"], status="sent")+ assert vs.list_pending_request_callbacks(conn) == []+ assert _callback_status(conn, req["id"]) == "sent"+++def test_list_pending_request_callbacks_returns_all_pending_rows(vault):+ with vault.begin() as conn:+ for index in range(55):+ req = vs.create_provision_request(conn, f"PAGE_KEY_{index}", requester={"session_id": f"ses_{index}"})+ vs.fulfill_pending_provision_requests_for_secret(conn, f"PAGE_KEY_{index}")+ assert _callback_status(conn, req["id"]) == "pending"++ assert len(vs.list_pending_request_callbacks(conn, limit=50)) == 50+ assert len(vs.list_pending_request_callbacks(conn)) == 55+++def test_reresolve_does_not_rearm(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="R_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "R_KEY", requester={"session_id": "ses_r"})+ vs.deny_request(conn, req["id"])+ vs.mark_request_callback(conn, req["id"], status="sent")+ # The atomic WHERE status='pending' claim rejects a re-resolve, so the callback can't rearm.+ with pytest.raises(vs.InvalidRequestError):+ vs.deny_request(conn, req["id"])+ assert _callback_status(conn, req["id"]) == "sent"+++# --- message coverage (pure) ----------------------------------------------------------------+++ "request_type,status,needle",+ [+ ("provision", "fulfilled", "provided"),+ ("access", "approved", "approved"),+ ("sign", "approved", "approved"),+ ("access", "denied", "declined"),+ ("sign", "failed", "signing error"),+ ("provision", "expired", "expired"),+ ("access", "expired", "expired"),+ ],+)+def test_message_and_session_by_type_status(request_type, status, needle):+ row = {+ "id": "vrq_msg",+ "request_type": request_type,+ "status": status,+ "secret_name": "K",+ "requester": json.dumps({"session_id": "ses_m"}),+ "delivery": None,+ }+ plan = vs.resolve_request_callback(row)+ assert plan is not None+ assert plan.session_id == "ses_m"+ assert needle in plan.message.lower()+++def test_only_no_callback_disables_auto_resume_at_creation():+ # Only --no-callback pre-disables. --wait must NOT: a finite wait can time out with the+ # request still pending, and the agent must still be auto-resumed when it later resolves.+ # (A wait that observes fulfillment suppresses the redundant callback at that point instead.)+ from types import SimpleNamespace++ from vibe import cli++ assert cli._vault_callback_disabled(SimpleNamespace(no_callback=True, wait=None)) is True+ assert cli._vault_callback_disabled(SimpleNamespace(no_callback=False, wait=5.0)) is False+ assert cli._vault_callback_disabled(SimpleNamespace(no_callback=False, wait=None)) is False+++def test_expire_overdue_requests_arms_callback(vault):+ past = (datetime.now(timezone.utc) - timedelta(minutes=1)).isoformat()+ with vault.begin() as conn:+ req = vs.create_provision_request(conn, "T_KEY", requester={"session_id": "ses_t"})+ conn.execute(vault_requests.update().where(vault_requests.c.id == req["id"]).values(expires_at=past))+ # Untouched: still pending, no callback armed yet (expiry is lazy).+ assert _callback_status(conn, req["id"]) is None+ vs.expire_overdue_requests(conn)+ assert _row(conn, req["id"])["status"] == "expired"+ assert _callback_status(conn, req["id"]) == "pending"+++def test_request_callback_ready_defers_approved_access_until_grant_ready(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="GR_KEY", sealed=_sealed(), protection="protected")+ req = vs.create_access_request(conn, "GR_KEY", requester={"session_id": "ses_gr"})+ grant = _grant_from_request_with_cache_ready(conn, req, cache_ready=False)+ row = _row(conn, req["id"])++ assert vs.request_callback_ready(conn, row) is False # protected relay in flight → defer++ vs.mark_grant_agent_ready(conn, grant["id"])+ row = _row(conn, req["id"])+ assert vs.request_callback_ready(conn, row) is True # grant ready → deliver++ req_without_grant = vs.create_access_request(conn, "GR_KEY", requester={"session_id": "ses_missing"})+ conn.execute(vault_requests.update().where(vault_requests.c.id == req_without_grant["id"]).values(status="approved"))+ assert vs.request_callback_ready(conn, _row(conn, req_without_grant["id"])) is True++ # Non-access or non-approved terminal states are always deliverable (no grant lookup).+ assert vs.request_callback_ready(None, {"request_type": "provision", "status": "fulfilled", "id": "x"}) is True+ assert vs.request_callback_ready(None, {"request_type": "access", "status": "denied", "id": "y"}) is True+++def test_request_callback_ready_defers_sibling_access_until_covering_grant_ready(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="GR_A", sealed=_sealed("a"), protection="protected", tags=["deploy"])+ vs.create_secret(conn, name="GR_B", sealed=_sealed("b"), protection="protected", tags=["deploy"])+ primary = vs.create_access_request(+ conn,+ source_selector={"tags": ["deploy"]},+ requester={"session_id": "ses_gr"},+ delivery={"session_id": "ses_gr"},+ )+ sibling = vs.create_access_request(+ conn,+ "GR_A",+ requester={"session_id": "ses_gr"},+ delivery={"session_id": "ses_gr"},+ )++ grant = _grant_from_request_with_cache_ready(conn, primary, cache_ready=False)+ sibling_row = _row(conn, sibling["id"])++ assert sibling_row["status"] == "approved"+ assert _callback_status(conn, sibling["id"]) == "pending"+ assert vs.get_grant_created_by_request(conn, sibling["id"]) is None+ assert vs.request_callback_ready(conn, sibling_row) is False++ vs.mark_grant_agent_ready(conn, grant["id"])+ assert vs.request_callback_ready(conn, _row(conn, sibling["id"])) is True+++def test_access_request_restore_clears_callback_status_for_retry(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="RB_A", sealed=_sealed("a"), protection="protected", tags=["deploy"])+ vs.create_secret(conn, name="RB_B", sealed=_sealed("b"), protection="protected", tags=["deploy"])+ primary = vs.create_access_request(+ conn,+ source_selector={"tags": ["deploy"]},+ requester={"session_id": "ses_rb"},+ delivery={"session_id": "ses_rb"},+ )+ sibling = vs.create_access_request(+ conn,+ "RB_A",+ requester={"session_id": "ses_rb"},+ delivery={"session_id": "ses_rb"},+ )+ grant = _grant_from_request_with_cache_ready(conn, primary, cache_ready=False)++ restored = vs.restore_access_request_after_failed_grant(+ conn,+ request_id=primary["id"],+ member_names=grant["member_snapshot"],+ session_id=grant["session_id"],+ )++ assert restored == 2+ assert _row(conn, primary["id"])["status"] == "pending"+ assert _row(conn, sibling["id"])["status"] == "pending"+ assert _callback_status(conn, primary["id"]) is None+ assert _callback_status(conn, sibling["id"]) is None+++def test_access_grant_create_rollback_clears_callback_status(vault):+ with vault.begin() as conn:+ vs.create_secret(conn, name="RB_CONFLICT", sealed=_sealed(), protection="protected")+ first = vs.create_access_request(conn, "RB_CONFLICT", requester={"session_id": "ses_one"})+ existing = _grant_from_request(conn, first)+ second = vs.create_access_request(conn, "RB_CONFLICT", requester={"session_id": "ses_two"})++ second["card"]["grant_options"][0]["grant_id"] = existing["id"]+ delivery = json.loads(_row(conn, second["id"])["delivery"])+ delivery["card"]["grant_options"][0]["grant_id"] = existing["id"]+ conn.execute(vault_requests.update().where(vault_requests.c.id == second["id"]).values(delivery=json.dumps(delivery)))++ with pytest.raises(vs.InvalidGrantError):+ _grant_from_request(conn, second)++ row = _row(conn, second["id"])+ assert row["status"] == "pending"+ assert row["decided_at"] is None+ assert row["callback_status"] is None+++def test_sign_approved_callback_points_to_the_signature():+ # The signature is the deliverable; the wake message must tell the agent how to get it.+ row = {+ "id": "vrq_sig",+ "request_type": "sign",+ "status": "approved",+ "secret_name": "KEYPAIR",+ "requester": json.dumps({"session_id": "ses_s"}),+ "delivery": None,+ }+ plan = vs.resolve_request_callback(row)+ assert plan is not None+ assert "vrq_sig" in plan.message and "vault await" in plan.message+++def test_callback_enabled_followup_does_not_suggest_await(monkeypatch):+ from types import SimpleNamespace++ from vibe import cli++ # Callback armed → must NOT suggest `vault await` (awaiting would double-resume).+ enabled = cli._vault_request_followup_message(+ SimpleNamespace(no_callback=False, wait=None, session_id="ses_x"), "vrq_x", resolved_verb="approves or denies it"+ )+ assert "await" not in enabled.lower()+ assert "--no-callback" in enabled # points at the correct way to block synchronously+ # Opt-out path (no callback armed) DOES point at await.+ opted_out = cli._vault_request_followup_message(+ SimpleNamespace(no_callback=True, wait=None, session_id="ses_x"), "vrq_x", resolved_verb="approves or denies it"+ )+ assert "vault await" in opted_out++ monkeypatch.delenv("AVIBE_SESSION_ID", raising=False)+ no_session = cli._vault_request_followup_message(+ SimpleNamespace(no_callback=False, wait=None, session_id=None), "vrq_x", resolved_verb="approves or denies it"+ )+ assert "vault await" in no_session+++def test_non_terminal_status_has_no_callback():+ row = {+ "id": "vrq_pending",+ "request_type": "access",+ "status": "pending",+ "secret_name": "K",+ "requester": json.dumps({"session_id": "ses_m"}),+ "delivery": None,+ }+ assert vs.resolve_request_callback(row) is None+++# --- shared enqueue entry uses the same callback path Agent Run uses -------------------------+++def test_enqueue_session_callback_uses_callback_source(monkeypatch):+ from core import scheduled_tasks as st++ class _Key:+ def to_key(self) -> str:+ return "plat::channel::c1"++ class _Target:+ session_key = _Key()+ agent_name = "agentx"+ agent_id = "aid"+ agent_backend = "claude"+ model = None+ reasoning_effort = None++ calls: dict = {}++ class _Store:+ def enqueue_agent_run(self, **kw):+ calls.update(kw)+ return type("R", (), {"id": "run_1"})()++ monkeypatch.setattr(st, "resolve_session_id_target", lambda sid: _Target())++ out = st.enqueue_session_callback(_Store(), session_id="ses_x", message="resume now", source_actor="vault:vrq_1")+ assert out is not None and out.id == "run_1"+ assert calls["source_kind"] == "callback"+ assert calls["session_policy"] == "existing"+ assert calls["session_id"] == "ses_x"+ assert calls["message"] == "resume now"+ assert calls["source_actor"] == "vault:vrq_1"++ # Nothing to send → no enqueue.+ assert st.enqueue_session_callback(_Store(), session_id="", message="x", source_actor="a") is None+ assert st.enqueue_session_callback(_Store(), session_id="ses", message=" ", source_actor="a") is Nonediff --git a/vibe/cli.py b/vibe/cli.pyindex aff72df4d..05e84cb50 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -4658,9 +4658,23 @@ def _vault_cli_requester(args) -> dict:skill = (getattr(args, "skill", None) or "").strip()if skill:requester["skill"] = skill+ if _vault_callback_disabled(args):+ # Opt out of auto-resume: the daemon sweep marks this request's callback "skipped".+ requester["callback_disabled"] = Truereturn requester+def _vault_callback_disabled(args) -> bool:+ """Whether this request opts out of the auto-resume callback at creation time.++ Only explicit ``--no-callback``. ``--wait`` must NOT pre-disable it: a finite wait can time+ out with the request still pending, and the agent must then still be auto-resumed when it+ later resolves. The redundant callback for a wait that DOES observe fulfillment is suppressed+ at that point instead (see ``cmd_vault_request``).+ """+ return bool(getattr(args, "no_callback", False))++def _vault_cli_delivery(args, **fields) -> dict:delivery = {key: value for key, value in fields.items() if value is not None}session_id = _vault_cli_session_id(args)@@ -4967,7 +4981,7 @@ def cmd_vault_access(args):"vault_access_request",request_id=request["id"],request=request,- message="Request recorded. Wait for approval with: vibe vault await " + request["id"],+ message=_vault_request_followup_message(args, request["id"], resolved_verb="approves or denies it"),)return 0except vault_service.SecretNotFoundError:@@ -6007,6 +6021,16 @@ def cmd_vault_request(args):if wait_seconds:waited = _wait_for_provision(req["id"], timeout=float(wait_seconds))if waited:+ # The wait delivered a terminal outcome synchronously, so suppress the+ # now-redundant async auto-resume callback for this request (best-effort — a+ # race with the ~2s sweep risks at most one benign duplicate resume). A wait+ # that TIMES OUT skips this and leaves the callback armed, so a later resolution+ # still wakes the agent.+ try:+ with _open_vault_engine().begin() as conn:+ vault_service.mark_request_callback(conn, str(req["id"]), status="skipped")+ except Exception:+ passif waited.get("status") == "denied":_print_task_error(TaskCliError(@@ -6061,7 +6085,12 @@ def cmd_vault_request(args):secret_name=name,status="pending",request=req,- message=_vault_request_pending_message(name, req, has_spec=bool(spec)),+ message=_vault_request_pending_message(+ name,+ req,+ has_spec=bool(spec),+ callback_enabled=not _vault_callback_disabled(args) and bool(_vault_cli_session_id(args)),+ ),)return 0except TaskCliError as exc:@@ -6112,7 +6141,7 @@ def cmd_vault_sign(args):"vault_sign_request",request_id=request["id"],request=request,- message="Request recorded. Wait for approval with: vibe vault await " + request["id"],+ message=_vault_request_followup_message(args, request["id"], resolved_verb="approves or denies the signature"),)return 0except vault_service.SecretNotFoundError:@@ -6197,17 +6226,45 @@ def cmd_vault_await(args):return 1-def _vault_request_pending_message(name: str, request: dict[str, object], *, has_spec: bool) -> str:+def _vault_request_followup_message(args, request_id: str, *, resolved_verb: str) -> str:+ """Agent-facing follow-up for an access/sign request.++ By default this Session auto-resumes when the request resolves, so the agent should just end+ its turn. We deliberately do NOT suggest ``vault await`` here: with the callback armed, awaiting+ would return the synchronous result AND still leave the callback to fire a second turn. To+ block synchronously the agent must opt out at creation with ``--no-callback`` (then this points+ at ``vault await``).+ """+ if _vault_callback_disabled(args) or not _vault_cli_session_id(args):+ return f"Request recorded. Check the result yourself with: vibe vault await {request_id}"+ return (+ f"Request recorded. This Session resumes automatically once the user {resolved_verb} — "+ f"end your turn now; you'll be woken with the outcome. (To block synchronously instead, "+ f"re-issue the request with --no-callback.)"+ )+++def _vault_request_pending_message(+ name: str,+ request: dict[str, object],+ *,+ has_spec: bool,+ callback_enabled: bool = True,+) -> str:+ resume = (+ " This Session resumes automatically once it is provided — you can end your turn now."+ if callback_enabled+ else f" Check back with: vibe vault await {request['id']}."+ )if has_spec:return (- f"Recorded a request for '{name}'. The user fulfills request {request['id']} from the Vaults page pending "- f"requests list by opening its Provide secret row; that request-specific form preserves the requested "- f"tags, policy, and skill links. Then use: vibe vault run --env {name} -- <command>"+ f"Recorded a request for '{name}'. The user provides it from the chat request card or the Vaults "+ f"page 'Provide secret' row, whose request-specific form preserves the requested tags, policy, and "+ f"skill links.{resume} Then use: vibe vault run --env {name} -- <command>")return (- f"Recorded a request for '{name}'. The user fulfills it from the Vaults page pending requests list "- f"(Provide secret) or by adding a secret named {name}; saving it marks this request fulfilled. "- f"Then use: vibe vault run --env {name} -- <command>"+ f"Recorded a request for '{name}'. The user provides it from the chat request card, the Vaults page "+ f"'Provide secret' row, or by adding a secret named {name}.{resume} Then use: vibe vault run --env {name} -- <command>")@@ -10157,6 +10214,11 @@ def build_parser():vault_access_parser.add_argument("--skill", help="Skill requesting the secret")vault_access_parser.add_argument("--command", dest="operation_command", help="Command or operation shown to the user")vault_access_parser.add_argument("--egress", help="Egress description shown to the user")+ vault_access_parser.add_argument(+ "--no-callback",+ action="store_true",+ help="Don't auto-resume this Session when the request resolves (you'll re-check it yourself)",+ )_add_json_noop(vault_access_parser)vault_sign_parser = vault_subparsers.add_parser(@@ -10182,6 +10244,11 @@ def build_parser():vault_sign_parser.add_argument("--skill", help="Skill requesting the signature")vault_sign_parser.add_argument("--command", dest="operation_command", help="Operation shown to the user")vault_sign_parser.add_argument("--egress", help="Egress description shown to the user")+ vault_sign_parser.add_argument(+ "--no-callback",+ action="store_true",+ help="Don't auto-resume this Session when the signature resolves (you'll re-check it yourself)",+ )_add_json_noop(vault_sign_parser)vault_await_parser = vault_subparsers.add_parser(@@ -10271,6 +10338,11 @@ def build_parser():vault_request_parser.add_argument("--spec-json", help="Inline JSON object with non-secret creation hints")vault_request_parser.add_argument("--wait", type=float, metavar="SECONDS", help="Block until fulfilled, up to SECONDS")vault_request_parser.add_argument("--no-wait", action="store_true", help="Return immediately (default)")+ vault_request_parser.add_argument(+ "--no-callback",+ action="store_true",+ help="Don't auto-resume this Session when the secret is provided (you'll re-check it yourself)",+ )_add_json_noop(vault_request_parser)show_parser = subparsers.add_parser(