Skip to content

Commit 4e8ca2d

Browse files
committed
Publish verbose launcher and verified OCI expiry diagnostics
1 parent 4b25067 commit 4e8ca2d

6 files changed

Lines changed: 91 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Existing scripts that read JSON must add `--json` and read the `result` field.
128128
pocketdeploy status --json | jq '.result'
129129
pocketdeploy plan --json --quiet > plan.json
130130
pocketdeploy converge --quiet
131+
pocketdeploy plan --verbose
131132
```
132133

133134
Progress and stage durations go to stderr. `--quiet` suppresses progress, while
@@ -315,3 +316,18 @@ usage error has `command: null` when argument parsing cannot identify a command.
315316
Running `./pocketdeploy` with no arguments prints the same help as `--help`
316317
to stdout and exits 0, without loading configuration or contacting providers.
317318
Unknown commands and a lone `--json` remain usage errors (exit 2).
319+
320+
### Verbose diagnostics
321+
322+
Use `pocketdeploy plan --verbose` or `pocketdeploy converge --verbose` to see
323+
individual OCI and SSH requests start, finish, and report elapsed time on
324+
stderr. Long-running requests periodically report that they are still waiting.
325+
Labels are authored by PocketDeploy; arguments, credentials and raw provider
326+
responses are never printed. `--json --verbose` keeps one JSON result on stdout.
327+
`--verbose` and `--quiet` conflict and exit 2 before deployment work begins.
328+
329+
For `oci-auth: security_token`, cloud workflows check the selected profile's
330+
local token expiry before invoking OCI. An expired token fails with a safe
331+
renewal instruction instead of waiting for a provider request. This local check
332+
does not prove a token is otherwise valid; OCI may still reject revoked or
333+
invalid credentials. `init` and Vault workflows do not require OCI credentials.

‎docs/verification.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,18 @@ parent files are ignored. Explicit `-f` paths remain relative to the caller, and
142142
state/key paths remain relative to the selected configuration. Validation passed
143143
117 tests, 12 copied-launcher checks and skill validation. Earlier upward-search
144144
verification above describes historical behavior.
145+
146+
## Verbose diagnostics and expired OCI sessions
147+
148+
The launcher now pins `4b250673977f1d0329e38251860c0d17aaaa4efb`. Validation passed
149+
146 tests, including safe OCI/SSH timing output, heartbeat cleanup and distinct
150+
expired-token versus rejected-authentication errors. The copied launcher passed
151+
15 isolated checks. A synthetic expired JWT was rejected in 0.17 seconds before
152+
the guarded OCI executable could run.
153+
154+
The operator's current OCI session had also expired. The published CLI rejected
155+
it locally with `oci_token_expired`, exit 1 and exact profile-specific refresh
156+
and reauthentication guidance in 0.90 seconds including launcher startup (5 ms
157+
in the CLI). No token contents or provider responses were emitted. This verified
158+
the real failure path; a successful live verbose plan was not run with renewed
159+
credentials during this change. No cloud resources or Vault snapshots changed.

‎scripts/test-launcher.py‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22
"""Exercise the published portable launcher outside this checkout; no cloud calls."""
33
import os
4+
import base64
5+
import time
46
import json
57
from pathlib import Path
68
import shutil
@@ -33,7 +35,7 @@ def main():
3335
launcher.chmod(0o700)
3436
environment = {
3537
key: value for key, value in os.environ.items()
36-
if not key.startswith('COLORS_PAR_') and key not in {
38+
if not key.startswith(('COLORS_PAR_', 'OCI_')) and key not in {
3739
'VIRTUAL_ENV', 'PYTHONPATH', 'PYTHONHOME', 'UV_PROJECT',
3840
'UV_PROJECT_ENVIRONMENT', 'UV_WORKING_DIRECTORY',
3941
}
@@ -45,6 +47,7 @@ def main():
4547
stub = launcher.parent / command
4648
stub.write_text(guard)
4749
stub.chmod(0o700)
50+
environment['OCI_CLI_CONFIG_FILE'] = str(root / 'oci-config')
4851
environment['PATH'] = str(launcher.parent) + os.pathsep + environment.get('PATH', '')
4952

5053
def invoke(directory, *arguments, expected=None, successful=False):
@@ -95,6 +98,10 @@ def invoke(directory, *arguments, expected=None, successful=False):
9598
fresh.mkdir()
9699
(fresh / 'colors.yml').write_text(CONFIG.replace('compute-require-existing-state: true',
97100
'compute-require-existing-state: false'))
101+
conflicting = invoke(fresh, 'init', '--json', '--verbose', '--quiet', expected='')
102+
conflict_envelope = json.loads(conflicting.stdout)
103+
assert conflicting.returncode == 2 and conflict_envelope['ok'] is False
104+
assert not (fresh / '.colors.sqlite').exists(), 'Conflicting flags initialized state.'
98105
initialized_run = invoke(fresh, 'init', '--json', '--quiet', successful=True)
99106
initialized_envelope = json.loads(initialized_run.stdout)
100107
assert initialized_envelope['schema_version'] == 1
@@ -109,6 +116,9 @@ def invoke(directory, *arguments, expected=None, successful=False):
109116
repeated = json.loads(invoke(fresh, 'init', '--json', '--quiet', successful=True).stdout)['result']
110117
assert initialized['deployment_id'] == repeated['deployment_id']
111118
assert contents == [path.read_bytes() for path in authority]
119+
verbose_run = invoke(fresh, 'init', '--json', '--verbose', successful=True)
120+
assert json.loads(verbose_run.stdout)['ok'] is True
121+
assert verbose_run.stderr.strip(), 'Verbose mode omitted progress.'
112122
text_run = invoke(fresh, 'init', '--quiet', successful=True)
113123
assert text_run.stdout.strip(), 'Quiet mode suppressed the text result.'
114124
assert text_run.stderr == '', text_run.stderr
@@ -135,7 +145,26 @@ def invoke(directory, *arguments, expected=None, successful=False):
135145
assert usage_envelope['error']['code'] and usage_envelope['error']['message']
136146
assert usage_json.stderr == '', usage_json.stderr
137147

138-
print('Portable launcher: 12 checks passed (no cloud access).')
148+
# Expired synthetic credentials must fail before the guarded OCI binary runs.
149+
token = root / 'synthetic-token'
150+
payload = base64.urlsafe_b64encode(json.dumps({'exp': int(time.time()) - 3600}).encode()).decode().rstrip('=')
151+
token.write_text('eyJhbGciOiJSUzI1NiJ9.' + payload + '.synthetic-signature')
152+
Path(environment['OCI_CLI_CONFIG_FILE']).write_text(
153+
'[synthetic]\nsecurity_token_file=' + str(token) + '\n'
154+
)
155+
started = time.monotonic()
156+
expired_run = invoke(fresh, 'plan', '--json', '--verbose', expected='')
157+
elapsed = time.monotonic() - started
158+
expired = json.loads(expired_run.stdout)
159+
assert expired_run.returncode == 1 and expired['ok'] is False
160+
assert expired['error']['code'] == 'oci_token_expired'
161+
assert 'expired' in expired['error']['message'].lower()
162+
assert 'oci session refresh --profile synthetic' in expired['error']['message']
163+
assert elapsed < 10, f'Expired token failed slowly: {elapsed:.1f}s'
164+
assert token.read_text() not in expired_run.stdout + expired_run.stderr
165+
print(f'Expired synthetic OCI token rejected locally in {elapsed:.2f}s; OCI was not invoked.')
166+
167+
print('Portable launcher: 15 checks passed (no cloud access).')
139168

140169

141170
if __name__ == '__main__':

‎skills/pocketdeploy/SKILL.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ failure. Read inventory fields under `result`, for example
106106
Errors carry a safe `code`, `message` and failing `stage` when known. Check the
107107
exit status as well as `ok`; do not parse human summaries or progress messages.
108108

109+
Use `--verbose` to diagnose slow plans or convergence: individual OCI and SSH
110+
requests report timings and periodic still-waiting messages on stderr. It never
111+
prints raw command arguments or provider output. `--json --verbose` preserves the
112+
single JSON result on stdout. `--verbose` conflicts with `--quiet` (exit 2 before
113+
work); neither option belongs in `colors.yml`.
114+
115+
With security-token authentication, cloud workflows check local token expiry
116+
before invoking OCI. Follow the safe renewal instruction for expired tokens;
117+
never print the token or substitute another identity. Local expiry validation
118+
cannot detect every invalid or revoked credential. `init` and Vault workflows
119+
remain independent of OCI authentication.
120+
109121
`--quiet` suppresses progress, not the result or text error diagnostics. Use
110122
`./pocketdeploy plan --json --quiet` for a JSON result without controller progress;
111123
launcher/runtime diagnostics may still appear on stderr. Exit codes are 0 for

‎skills/pocketdeploy/pocketdeploy‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env -S uv run --script
22
# /// script
33
# requires-python = ">=3.11"
4-
# dependencies = ["pocketdeploy @ git+https://github.com/pocketcontext/pocketdeploy.git@40f20bb2bbbd848e3a8c7bd10b1a7988faa18279"]
4+
# dependencies = ["pocketdeploy @ git+https://github.com/pocketcontext/pocketdeploy.git@4b250673977f1d0329e38251860c0d17aaaa4efb"]
55
# ///
66
"""Portable PocketDeploy CLI; deployment selection follows the caller's directory."""
77
from pocketdeploy.cli import main

‎skills/pocketdeploy/references/configuration.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,24 @@ its remote snapshot is encrypted.
133133

134134
## Output options
135135

136-
`--json` and `--quiet` are command-line options, not `colors.yml` settings.
136+
`--json`, `--quiet` and `--verbose` are command-line options, not `colors.yml` settings.
137137
Text is the default. `--json` returns a versioned envelope with `schema_version`,
138138
`command`, `ok` and either `result` or `error`; safe inventory fields are under
139139
`result`. Progress and timings use stderr, and `--quiet` suppresses them.
140140
Failure envelopes on stdout retain a nonzero exit status. SSH passes remote
141141
streams and exit status through without a footer and does not accept `--json`.
142+
143+
`--verbose` adds safe per-request timings and periodic still-waiting messages on
144+
stderr, including with `--json`. It never prints raw arguments or responses.
145+
Combining `--verbose` with `--quiet` is a usage error (exit 2).
146+
147+
For `oci-auth: security_token`, cloud workflows check local token expiry before
148+
starting OCI requests and fail with renewal guidance when it has expired.
149+
This check does not authenticate the token or detect all revoked credentials.
150+
Local `init` and explicit Vault workflows do not perform this OCI check.
151+
152+
The OCI CLI configuration comes from `OCI_CLI_CONFIG_FILE`, or `~/.oci/config`
153+
when unset. `oci-config-file-profile` selects the profile (default `DEFAULT`).
154+
An expired token returns `oci_token_expired`; refresh with
155+
`oci session refresh --profile PROFILE` using the same config file. If refresh
156+
fails, use `oci session authenticate` for that profile.

0 commit comments

Comments
 (0)