Skip to content

Runner refresh exchange always 400s; keep a renewable credential for long-running apps #39

Open
0 of 1 issue completed

Description

@birme

Source: nordiccare report (Slack #C0BS2FZ1YE7, 2026-11-05): "the app's token expires after an hour". Investigation shows the premise differs from what the entrypoint intends.

Not a regression, but a blocker for the hardening

Nothing changed recently. The header-only call has never matched what POST /runner-token/refresh expects (JSON body required since the endpoint was added on 2026-02-25; the runner block predates 2026-06-08, per git history, not re-run against old versions). It stays invisible because || true swallows the failure and the 365-day runner-refresh token stays in OSC_ACCESS_TOKEN.

This must be fixed before REJECT_RUNNER_REFRESH_TOKENS is enabled (token-service #116, default false, not set in infra-osaas). Once it is on, apps and sibling runners that rely on that token stop working. Blocks: enabling that flag in prod.

Findings (from code reading; the 400/401 was probed against dev and prod with a junk token)

  • The OSC_ACCESS_TOKEN a python My App receives is a runner-refresh token (type: runner-refresh, scope config-access, 365 days; osaas-lib-token src/pat/token.ts:48-73).
  • scripts/docker-entrypoint.sh:214-218 tries to exchange it at POST token.svc/runner-token/refresh for a 1h PAT, but sends the token only in an x-pat-jwt header. The endpoint requires a JSON body {"token": ...} (token-service src/model.ts:29-31): header only gives 400 body must be object.
  • curl -sf ... || true swallows the failure, so the 365-day token stays in the env var. Apps work today by accident; they depend on REJECT_RUNNER_REFRESH_TOKENS staying false (osaas-deploy-manager src/server.ts:219).
  • Sibling runners: wasm-runner (:128-130) has the same bug; golang-runner (:131-133) and dotnet-runner (:137-139) send a Bearer header with no body and also fail; web-runner (:303-305) and php-runner (:116-118) are correct.

Change (contract change, needs birme approval before merge)

Fixing the body alone turns today's 365-day env token into a 1h PAT and breaks any app using it after an hour. The two parts must ship together:

  1. POST {"token": $OSC_ACCESS_TOKEN}, as web-runner does.
  2. Keep the original token available as OSC_REFRESH_TOKEN so the app can call /runner-token/refresh itself; document with a Python snippet.
  3. Log a [CONFIG] warning on a failed exchange instead of || true.

Acceptance criteria

  • Items 1-3 above, in one PR
  • Tests for the success and failure paths
  • Consumer audit for apps reading OSC_ACCESS_TOKEN, and Contract change approved by birme: <url> on this ticket before merge
  • Sibling tickets filed for wasm-, golang- and dotnet-runner (linked below)

What a human does next

Nothing.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. self-assigned this
    on Nov 6, 2026
  2. birme commented on Nov 6, 2026

    @birme
    ContributorAuthor

    Sibling added for python-job-runner: Eyevinn/python-job-runner#6 (the audit's seventh runner; wasm, golang, dotnet are #37, #32, #31).

  3. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Architect Triage

    Classification: NEEDS_HUMAN (contract gate: the ticket's own item 1 changes what a python My App receives in OSC_ACCESS_TOKEN; the ticket itself says "contract change, needs birme approval before merge" and carries no agent-actionable label)
    Necessity-test arm: treated

    Premises verified (python-runner 1761ffb, osaas-token-service dc067f6, osaas-lib-token 3d507d6, osaas-deploy-manager e9ad56e, web-runner 3aaca7c, all main today):

    • The exchange is header-only. scripts/docker-entrypoint.sh:229-233 (the ticket cites 214-218, shifted by fix: redact decrypted config output from pod logs on config load failure #40) sends -H "x-pat-jwt: $OSC_ACCESS_TOKEN" and no body. Probed just now: POST https://token.svc.dev.osaas.io/runner-token/refresh carrying that header alone answers 400 {"code":"FST_ERR_VALIDATION","message":"body must be object"}. The route needs {token} (src/model.ts:29-31, handler src/api_service_token.ts:548-626) and answers {token, expiresIn: 3600} from generatePat(tenantId, userId, undefined, undefined, 3600).
    • OSC_ACCESS_TOKEN of a python app is the runner-refresh token: deploy-manager src/apps/python.ts:138-152 stores PatToken.generateRunnerRefreshToken(...) as OscAccessToken (rebuild migration and rotation at :635-675); the token is type: runner-refresh, scope: ['config-access'], 365 days (osaas-lib-token src/pat/token.ts:48-73).
    • Why the flag needs this: with REJECT_RUNNER_REFRESH_TOKENS=true, rejectIfRunnerRefreshToken (token-service src/api_service_token.ts:77-93) answers 401 pat_invalid on PAT routes, deploy-manager's verifiers do the same (src/security/runner-refresh.ts). Config load survives because /servicetoken exempts eyevinn-app-config-svc (:71, :167-174), and /runner-token/refresh stays open (api_service_token.test.ts:683).
    • || true plus an unconditional OSC_ACCESS_TOKEN=$(...) is the whole failure handling. Note the assignment (no export) still reaches the app: an assignment to a variable imported from the environment keeps its export attribute, so on a 200 the app would inherit the 1h PAT.
    • Precedent: web-runner (scripts/docker-entrypoint.sh:298-365) does the correct exchange and already exports the 1h PAT as the app's OSC_ACCESS_TOKEN. It has no OSC_REFRESH_TOKEN, so web-runner apps have no way to renew in-process either. Failure movement there: 200 exports the fresh PAT; 401 refresh_token_expired|revoked runs exit 1; 401 refresh_token_invalid keeps the original silently; any other 401 and any non-200 after 3 tries warn and keep the original.
    • OSC_REFRESH_TOKEN name collision check: no code in deploy-manager src, lib-token, token-service, web-runner or python-runner uses it, and an org code search finds it only in ADR-0005 (adr/0005-runner-refresh-tokens.md, which names this exact variable as the exchange input and says it is checked first). Naming follows ADR-0005; no new ADR needed.
    • Endpoint latency for any timeout on the new call (8 POSTs each, junk token, JSON body, time_total): dev p50 36 ms, max 133 ms; prod p50 34 ms, max 38 ms. Thin sample, so a ceiling must be generous.

    The contract change, stated precisely (needs birme's approval, rejected here as a contract break)

    Element: item 1 as written, i.e. the app-visible OSC_ACCESS_TOKEN becomes the exchange result.

    Before (every python My App pod today) After (ticket as written)
    OSC_ACCESS_TOKEN in the app env 365-day runner-refresh JWT, accepted by every PAT route while the flag is false 1-hour PAT JWT that expires 1h after container start; env is static, so a long-running app gets 401 on its own calls after one hour and a new value on restart
    OSC_REFRESH_TOKEN not set the 365-day token
    Startup one failing call, silent one succeeding call, plus a [CONFIG] warning on failure
    Failure modes none from the exchange none from the exchange (a warning line is printed), same as today

    This is the only element that changes behaviour for existing apps, and it cannot be made contract-preserving because changing the meaning of OSC_ACCESS_TOKEN is exactly what unblocks REJECT_RUNNER_REFRESH_TOKENS. Consumer audit so far (gh search code OSC_ACCESS_TOKEN --owner Eyevinn): python hits are open-videocore e2e/job/run_cycle.py (CI job env, not a My App), eng-nordic-care-web app/config.py:174 (the reporting tenant: an optional ENV_OSC_ACCESS_TOKEN constant), eng-softbind param_store.py, eng-nordic-care-agents. Unverified: how eng-nordic-care-web uses the value after startup. Coverage limit: tenant apps outside the Eyevinn org cannot be searched, a residual that is inherent to this change.

    Contract-preserving direction (what agent-actionable alone releases)

    Per task 5.5a: if the label is added without a birme comment that approves item 1, implement this section alone. It does not by itself unblock the flag (apps still lean on the 365-day token); it makes the exchange real, gives apps the renewable credential before the swap, and leaves the swap a one-line change.

    Checklist (the ticket's four acceptance criteria and three change items, none dropped; AC 1 and 3 rewritten as noted):

    1. [change 1, contract-preserving form] Replace the call at docker-entrypoint.sh:229-233: POST {"token": "<exchange input>"} with Content-Type: application/json, where the input is ${OSC_REFRESH_TOKEN:-$OSC_ACCESS_TOKEN}. Put the body in a mode-600 temp file and pass --data @file, as web-runner does (:307-313), so the token never sits in curl's argv; read the HTTP status with -w. A --max-time 10 is allowed (measurement above); on timeout the outcome is unknown, so fall back to the original token and continue, never fail. On 200 with a non-empty .token, use it as OSC_ACCESS_TOKEN for the config-to-env command, set inline on that command (config_env_output=$(OSC_ACCESS_TOKEN="$fresh" timeout 60s npx ...)). Never assign the shell's OSC_ACCESS_TOKEN (see the export-attribute note above): that assignment is the contract change.
    2. [change 2] Before the exchange, export OSC_REFRESH_TOKEN="${OSC_REFRESH_TOKEN:-$OSC_ACCESS_TOKEN}". A tenant param-store key of the same name is loaded after this and wins; say so in the README.
    3. [change 3] Replace || true with a handler that prints [CONFIG] WARNING: runner token exchange failed (HTTP <status>, code=<.code>); using the original token, status and .code only, never the body or the token. No exit on exchange failure: the config load stays the only fatal path, so no new failure mode appears. Do not copy web-runner's exit 1 on refresh_token_expired|revoked.
    4. Add OSC_REFRESH_TOKEN and the fresh token to the redaction loop in redact_config_log (:211-222, added by fix: redact decrypted config output from pod logs on config load failure #40; its test asserts literal-token redaction at tests/test-entrypoint-config-load-failure.sh:88).
    5. README: add OSC_REFRESH_TOKEN next to OSC_ACCESS_TOKEN (README.md:60) with a short Python snippet that POSTs {"token": os.environ["OSC_REFRESH_TOKEN"]} to https://token.svc.<env>.osaas.io/runner-token/refresh and reads .token.
    6. [AC 2] Tests: extend tests/test-entrypoint-config-load-failure.sh or add tests/test-entrypoint-runner-token-refresh.sh with the same awk extraction (the extracted block runs from # Load environment variables from config service if configured to # Install Python dependencies, so it includes the refresh block; today's curl stub is exit 22, so every existing case runs through the failure path and must stay green). Success path: stub curl answers 200 and {"token":"fresh","expiresIn":3600}; assert npx saw OSC_ACCESS_TOKEN=fresh, the shell's OSC_ACCESS_TOKEN after the block is still the original, OSC_REFRESH_TOKEN equals the original, and the block reaches REACHED_PIP. Failure paths (401 expired, 401 invalid, 500, curl exit 22 and 28): warning with status, no token in stdout or stderr, original token used, block continues. A passing-path test is mandatory per CLAUDE.md.
    7. [AC 1, rewritten] Was "Items 1-3 above, in one PR". Now: items 2 and 3 plus the corrected exchange used for the runner's own config load, in one PR, with the app-visible OSC_ACCESS_TOKEN unchanged. Rewritten because item 1 as written replaces the app's token.
    8. [AC 3, rewritten] The Contract change approved by birme: <url> line is required for the swap below, not for this PR. The audit for this PR is the name-collision and redaction work in items 2 and 4.
    9. [AC 4] Sibling tickets exist and are open: python-job-runner#6, wasm-runner#37, golang-runner#32, dotnet-runner#31 (checked). They copy this ticket's text, so their stage follows birme's decision here.

    python-runner has no PR CI that runs tests (.github/workflows holds sync-fork-dev.yml and sync-fork-prod.yml and nothing else), so the implementer runs for t in tests/*.sh; do bash "$t"; done locally and pastes the result in the PR body.

    If birme approves the swap (a comment Contract change approved by birme: <url> stating item 1 as written): change item 1 to export OSC_ACCESS_TOKEN="$fresh" before the config load (web-runner behaviour), keep OSC_REFRESH_TOKEN, flip the success test to assert the app-visible token is the fresh one. Same PR, same files. Say in the PR body that existing apps get the 1-hour token on their next restart.

    E2E Impact

    Verdict: None
    Grepped python-runner|eyevinn-python-runner|OSC_ACCESS_TOKEN|runner-token|OSC_REFRESH_TOKEN in osaas-e2e-tests tests/ and utils/ (main, fast-forwarded). Hits: tests/test-service-creation-token.ts (creates a service with OscAccessToken: '{{secrets.oscaccesstoken}}' through create-service-instance and asserts the template survives in the listing; it never runs the python entrypoint), tests/account.teardown.ts, tests/account-personal.teardown.ts and tests/test-mcp-myapps-paramstore-large.ts (the test process passes its own OSC_ACCESS_TOKEN to the CLI). No spec boots a python runner pod, so none asserts the entrypoint's token behaviour. Dev verification is agent-doable after merge: .claude/scripts/dev-remake.sh https://github.com/Eyevinn/python-runner eyevinn-python-runner, then create a python My App with a parameter store on the dev test tenant and read the pod startup log for the exchange line (the GHCR digest check is not possible on this runner, ghcr_dev=denied; use the maker order status and the pod log).

    Existing test coverage: python-runner tests/test-entrypoint-config-load-failure.sh (extracts and runs the refresh plus config block; satisfied by item 6). No e2e spec, see above.
    Guard tests lifted: None. Grepped tests/ for ADR- (0 hits) and for text assertions on the entrypoint source (none; the harness runs the extracted block).

    Necessity test

    Split decision: not split. One issue, 9 checklist items (4 of 4 acceptance criteria and 3 of 3 change items are checklist items 1 to 9; AC 1 and AC 3 are rewritten as stated in items 7 and 8, none dropped).

    Scope reductions

    cut ADR citation owning ticket # decision owner
    Replacing the app-visible OSC_ACCESS_TOKEN with the 1h PAT (item 1 as written) waits for approval ticket body: "Change (contract change, needs birme approval before merge)"; AC 3; ADR-0005 does not cover the app-visible swap #39 (its item 1 and the "If birme approves" paragraph above) birme

    Needed now: birme decides item 1. Either comment Contract change approved by birme: <url> on this ticket and add agent-actionable (the ticket is then implemented as written, swap included), or add agent-actionable alone to release the contract-preserving direction above. Mention in the same comment which stage the four sibling tickets follow.
    Cause category: product decision
    Prevent next time: the audit that filed the seven runner tickets should name the stage split up front when a fix changes what an env var means (a before/after row in the issue template for runner entrypoint tickets), so the approval is a one-line choice; proposed wording for .claude/skills/daily-triage.md task 5.5a: "a runner entrypoint change that alters an env var an app reads is a contract change; list before and after".
    Owner of that change: birme (the audit that filed #39 came from his account; the CEO/PM team does not own runner entrypoints)

    Add the agent-actionable label once this decision is made and automation will pick it up.

    Automated triage by architect agent

  4. added
    Human Needed
    on Nov 8, 2026
  5. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Architect note: jq is not in the runner image (found while triaging Eyevinn/wasm-runner#37)

    The Stage 1 directions in the triage comment above read the exchange response's .token and .code. In this image that parsing cannot use jq: the entrypoint's only jq call is docker-entrypoint.sh:233, and the Dockerfile (python:3.12-slim plus the apt list at lines 4-17, then NodeSource Node) installs no jq; Debian's awscli package does not depend on it either. Today the call never runs because curl fails first. Once the body is fixed it runs, jq is "command not found", and the current OSC_ACCESS_TOKEN=$(echo "$REFRESH_RESULT" | jq -r '.token // empty') assigns an empty string (and so would any Stage 2 swap written the same way), after which config-to-env runs without a token and the container exits through the fatal config path.

    Direction for the implementer on this ticket: parse the response with node (already in the image, no new dependency), treat an empty parse result as an exchange failure (warning, original token kept), and add a jq stub that exits 127 to the success-path test, because the harness PATH includes /usr/bin and a developer machine with jq would hide the problem. Read from the Dockerfile; the built image was not inspected (ghcr.io answers 401 on this runner). The same check is needed for python-job-runner#6, golang-runner#32 and dotnet-runner#31 when they are triaged; wasm-runner's image has the same gap (see Eyevinn/wasm-runner#37).

    Automated triage by architect agent

  6. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Decision (birme, 2026-11-08)

    Stage 1 now for all five runners. Stage 2 ships together with the REJECT_RUNNER_REFRESH_TOKENS rollout, not before.

    This decision governs all five sibling tickets: python-runner#39, Eyevinn/dotnet-runner#31, Eyevinn/golang-runner#32, Eyevinn/wasm-runner#37 and Eyevinn/python-job-runner#6.

    Stage 1 — do it now (no human decision left, nothing a tenant can observe)

    Make the refresh exchange actually work, and have config-to-env authenticate with the fresh 1h PAT. The app keeps today's token and additionally gains OSC_REFRESH_TOKEN.

    Stage 2 — gated, not now

    The app-visible OSC_ACCESS_TOKEN becomes the 1h PAT. This ships with the REJECT_RUNNER_REFRESH_TOKENS rollout. Shipping it before is a genuine regression for any My App that calls a platform API more than an hour after boot: today the 365-day token works, after Stage 2 it dies at 60 minutes with no in-process renewal unless the app has adopted OSC_REFRESH_TOKEN. Shipping it after the flag is strictly an improvement, because the 365-day token is rejected on every route by then. Do not implement Stage 2 under these tickets; it belongs to the flag rollout.

    Why this is consistent with the decision already taken

    osaas-token-service#109 (birme, 2026-11-03, option B) rejected option (C) — "fix the five runner entrypoints" — with: "(C) stays the better end state but needs runner image releases and restarts first; it would be a new ticket by whoever wants it." These five tickets are that new ticket. The same comment already records that "Apps on web-runner and php-runner hold a 1h PAT after the swap and are unaffected", so the swap is accepted existing platform behaviour, not a new proposal.

    What is actually broken (re-probed on dev, not taken from the triage)

    POST https://token.svc.<env>.osaas.io/runner-token/refresh requires a JSON body {"token": "<jwt>"} (osaas-token-service src/model.ts:29-31, handler src/api_service_token.ts:544-630) and answers {token, expiresIn: 3600}. All five runners send no body, so the exchange has never once succeeded:

    form result
    x-pat-jwt header, no body (python, wasm, python-job) 400 FST_ERR_VALIDATION "body must be object"
    Authorization: Bearer + Content-Type: application/json, no body (golang, dotnet) 400 FST_ERR_CTP_EMPTY_JSON_BODY
    correct {"token": ...} body reaches the verifier (401 on a junk token)

    token-service is correct and needs no change. This is five near-identical entrypoint patches. web-runner (3aaca7c:303-336) and php-runner (fe16600:114-126) are the reference implementations — both already send the body and both already do the swap.

    Two traps that the literal "just add the body" fix would hit

    Both verified from the Dockerfiles; implementers must handle them:

    1. jq is absent from the python-runner and wasm-runner images (python:3.12-slim and ubuntu:22.04, neither apt-installs it; node is present in both). Today jq never runs because curl fails first. Fix only the body and OSC_ACCESS_TOKEN=$(... | jq ...) assigns empty, config-to-env runs tokenless, and the config path fails. Parse with node in those two images, or add jq to the image — do not assume it exists. golang, dotnet, web and php images do have jq.
    2. golang and dotnet parse with grep -o ... | cut under set -e without pipefail, so the || echo "$OSC_ACCESS_TOKEN" fallback is unreachable and a 200 without a token key silently yields an empty string. Replace with jq -r '.token // empty' and treat empty as a failure — otherwise fixing the body converts a silent no-op into a silent tokenless config load.

    Also replace the || true on the config load with a [CONFIG] warning, so a future failure is visible rather than silent.

    Line numbers have drifted — re-verify before editing

    Verified on current main; the ticket bodies cite the older numbers:

    repo main real location ticket says
    python-runner 1761ffb scripts/docker-entrypoint.sh:230-233 214-218
    wasm-runner 178542d :127-130 128-130
    golang-runner 90b62fa :130-133 131-133
    dotnet-runner 142b9d4 :136-142 137-139
    python-job-runner — :85-88 (unlabelled until now)

    wasm-runner is exempt from Stage 2 entirely

    wasm-runner api/server.js:16-18 is spawn('/runner/bin/wasmedge', ['/usercontent/main.wasm']) — no env option, no --env flags, and grep -rn OSC_ACCESS_TOKEN api/ is empty. The WASM module cannot observe OSC_ACCESS_TOKEN at all, so both stages only touch the runner's own Node process. Its AC2 was copied verbatim from #39 into a runtime where the premise is false and should be struck, not deferred.

    Consumer audit for Stage 2 (for when it ships, recorded now so it is not redone)

    The originating tenant repo eng-nordic-care-web (private) reads OSC_ACCESS_TOKEN only as a Bearer header for a boot-time parameter-store fetch (app/config.py, _maybe_fetch_parameter_store()), so it is Stage-2-safe. gh search code OSC_ACCESS_TOKEN --owner Eyevinn otherwise surfaces only catalog services (intercom-manager, open-live, strom, just-go-live), none runner-hosted. Go and C# searches return 0 runner-app hits. Coverage limit: tenant repos outside the Eyevinn org cannot be code-searched — that residual is inherent and accepted.

    Caveat on provenance — read this before treating #39 as the fix for the report

    The originating Slack report could not be read (slack-read.sh returns invalid_auth and the Slack MCP connector is down with a 404). Since every runner's exchange 400s, the reporting tenant's app is holding the 365-day token — so their complaint cannot be about OSC_ACCESS_TOKEN expiring after an hour. #39 is a hardening finding the investigation surfaced, not the fix for the reported symptom, and the reported symptom may still be unexplained (most likely a 1h service access token minted downstream). Whoever closes these tickets must not treat the tenant's report as resolved by them.

    Cause category / Prevent next time

    • Cause category: missing test coverage — a credential exchange that has never succeeded once in production shipped in five images, because no test and no alert distinguishes "refreshed" from "silently kept the old token". The || true guaranteed silence.
    • Prevent next time: an entrypoint block that exchanges or refreshes a credential gets a success-path test that asserts the new value is in use, not merely that the script exits 0; and the failure path logs instead of || true. The reference implementation to copy is web-runner's, not the nearest sibling's.
    • Owner of that change: the architect agent, as a rule in docs/repo-patterns-backend.md plus the per-runner tests in the Stage 1 PRs.

    For the implementer

    Re-verify every line number above against current main before editing. Write the fresh token to a mode-600 temp file rather than an argv or env interpolation. Extend each repo's existing entrypoint test (e.g. wasm-runner's tests/test-entrypoint-config-load-failure.sh, which extracts the # BEGIN CONFIG LOAD block and stubs curl) with both a success case and a jq-exits-127 stub, so a dev machine that happens to have jq cannot mask the gap. These repos have no PR CI (only sync-fork-*.yml), so run tests/*.sh locally. Dev verification afterwards is agent-doable via .claude/scripts/dev-remake.sh.

    Removing Human Needed on all five; moving to Backlog.

  7. added
    agent-actionable
    and removed
    Human Needed
    on Nov 8, 2026
  8. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Moved back to Backlog by daily-review (Step 6c). PR #41 is merged but is Part of #39 (Stage 1 only); Stage 2 (app-visible OSC_ACCESS_TOKEN becomes the 1h PAT, shipped with the REJECT_RUNNER_REFRESH_TOKENS rollout) is not shipped and no other open ticket owns it. dotnet-runner#32 and golang-runner#33 are in other repos. Needs re-spec by daily-triage.

  9. eyevinn-developer commented on Nov 8, 2026

    @eyevinn-developer
    Contributor

    Spec Invalid

    Attempted

    Read the issue and all comments, then checked the repo state before writing code. PR #41 ("working runner token exchange + OSC_REFRESH_TOKEN (stage 1 of #39)") is MERGED (2026-11-08T11:52:35Z). No other PR or open issue exists in python-runner.

    What the triage directions claim

    The architect triage describes Stage 1 (body-correct exchange, OSC_REFRESH_TOKEN, [CONFIG] warning, redaction, README, tests) and an optional swap (app-visible OSC_ACCESS_TOKEN becomes the 1h PAT) that needs Contract change approved by birme: <url>.

    What is actually true

    • Stage 1 is already on main via fix: working runner token exchange + OSC_REFRESH_TOKEN (stage 1 of #39) #41, so there is nothing left to implement from the triage directions.
    • The only remaining scope is Stage 2 (the swap). birme's decision on 2026-11-08 says: "Do not implement Stage 2 under these tickets; it belongs to the flag rollout." It ships together with the REJECT_RUNNER_REFRESH_TOKENS rollout.
    • No Contract change approved by birme: <url> line exists on the ticket, and no ticket owns Stage 2 (daily-review's Step 6c comment says the same).

    Why this blocks implementation

    Implementing Stage 2 now would contradict birme's explicit decision, and the app-visible token swap is a contract change that regresses any My App calling a platform API more than an hour after boot.

    What a re-spec must resolve

    Automated by backend-developer agent

  10. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Architect Triage

    Classification: LARGE (decompose: one child that owns Stage 2; nothing is left for an implementer under #39 itself)
    Necessity-test arm: treated
    Re-spec: 1 prior ## Spec Invalid (eyevinn-developer, 2026-11-08T17:23Z). Its "What is actually true" verified below.
    Corrects the prior spec: the triage of 2026-11-08T07:01Z directed Stage 1 plus an optional swap under this ticket. Stage 1 has shipped (PR #41), and birme's decision (#39 (comment)) moved the swap to the REJECT_RUNNER_REFRESH_TOKENS rollout, for which no ticket exists. Replaced with: this ticket gets one child that owns Stage 2 for every runner the decision covers, created in Triage with Human Needed, and released by birme's rollout call. #39 goes to In Review with Decomposed and closes when that child closes. Nothing goes to Backlog, so no implementer is sent to find nothing to do (the cause of the Spec Invalid).

    Premises verified (python-runner 4e01bf2 = main, osaas-deploy-manager 0d7b430)

    • Stage 1 is on main. PR fix: working runner token exchange + OSC_REFRESH_TOKEN (stage 1 of #39) #41 merged 2026-11-08T11:52:35Z (merge 4e01bf2), body Part of #39. In scripts/docker-entrypoint.sh: export OSC_REFRESH_TOKEN="${OSC_REFRESH_TOKEN:-$OSC_ACCESS_TOKEN}" at :236, a JSON body from a mode-600 file at :238-247, a node parse at :248-251, a [CONFIG] WARNING with status and code only at :258, the fresh token passed inline at :278 (OSC_ACCESS_TOKEN="$config_token" timeout 60s npx ...), and OSC_REFRESH_TOKEN in the redact_config_log loop at :213. Tests are in tests/test-entrypoint-runner-token-refresh.sh. No open PR or other open issue exists in this repo.
    • The swap is not on main. The shell's OSC_ACCESS_TOKEN is never assigned, and the success test asserts that the app sees the original token (tests/test-entrypoint-runner-token-refresh.sh:66, APP_TOKEN=$OSC_ACCESS_TOKEN).
    • The refresh block runs whenever the app holds the token. It is guarded by OSC_ACCESS_TOKEN and CONFIG_SVC at :223. deploy-manager sets OscAccessToken only inside if (params.configService) (src/apps/python.ts:131-161), so there is no python app that holds a runner-refresh token and skips the exchange. In python-runner, Stage 2 is the if [ -n "$fresh_token" ] branch at :253-254.
    • Nobody owns Stage 2 today.
      • dotnet-runner#31 and golang-runner#32 were closed COMPLETED on 2026-11-08 with "AC2 here is deferred to that rollout".
      • wasm-runner#37 is closed, and is exempt (birme's decision, wasm section).
      • python-job-runner#6 is open, with no labels.
      • The rollout of the flag is not a ticket. osaas-token-service#109 (option B, closed) says enabling it on prod is "a prod config change and birme's call", and the seven verifier tickets (#112, catalog-manager#340, osaas-ai#2522, money-manager#483, deploy-manager#2029, maker-manager#264, osaas-app#7061) are all closed.
      • gh search issues REJECT_RUNNER_REFRESH_TOKENS --owner Eyevinn finds no open rollout ticket. The only open hits are this ticket, python-job-runner#6 and osaas-app#7052.

    Requirement map (every acceptance criterion and change item of #39, plus the Stage 2 work that birme's decision defers in the sibling tickets)

    # Requirement (citation) Owner
    R1 Change 1, exchange POSTs {"token": ...} (body) PR #41, done
    R2 Change 1, the app-visible OSC_ACCESS_TOKEN becomes the 1h PAT (body; birme's decision: Stage 2 ships with the REJECT_RUNNER_REFRESH_TOKENS rollout, not before) child S2
    R3 Change 2, OSC_REFRESH_TOKEN plus docs (body) PR #41, done
    R4 Change 3, [CONFIG] warning instead of || true (body) PR #41, done
    R5 AC "Items 1-3 above, in one PR" (body) Rewritten by birme's decision into two stages: Stage 1 PR #41, Stage 2 child S2
    R6 AC "Tests for the success and failure paths" (body) Stage 1: PR #41 (9 cases). Stage 2: child S2 flips the success assertion
    R7 AC "Consumer audit ... and Contract change approved by birme: <url>" (body) Audit: recorded in birme's decision comment (eng-nordic-care-web reads the token only at boot, so it is Stage-2-safe; coverage limit stated there). Approval line: child S2 carries it
    R8 AC "Sibling tickets filed for wasm-, golang- and dotnet-runner" (body) Done: wasm-runner#37, golang-runner#32, dotnet-runner#31, plus python-job-runner#6
    R9 Stage 2 for golang-runner and dotnet-runner, deferred by the decision on golang-runner#32 and dotnet-runner#31 and owned by no ticket child S2
    R10 Stage 2 for python-job-runner (birme's decision governs all five tickets) child S2 (with an exemption check, as for wasm)

    Child S2 (created by the orchestrator after review)

    Title: Stage 2 of #39: app-visible OSC_ACCESS_TOKEN becomes the 1h PAT in the python, golang, dotnet and python-job runners, with the REJECT_RUNNER_REFRESH_TOKENS rollout. It is created in Triage with Human Needed. The decision it waits for is birme's call to start the prod rollout of the flag.

    Directions it carries, re-verified against main when released:

    • python-runner: export OSC_ACCESS_TOKEN="$fresh_token" in the :253-254 branch. In tests/test-entrypoint-runner-token-refresh.sh, flip the success case so that APP_TOKEN=fresh and REFRESH=orig-token-secret. Keep the failure cases, which must still show APP_TOKEN=orig-token-secret.
    • golang-runner and dotnet-runner: the same swap at the place where their Stage 1 PRs set the fresh token, with the same test flip.
    • python-job-runner: first check whether the job process can observe OSC_ACCESS_TOKEN. If it cannot, record it as exempt, as birme's decision does for wasm-runner. web-runner and php-runner already swap.
    • Release order (birme's call, stated rather than ticketed): Stage 2 runner image releases, then the flag on the seven verifiers, then a restart of runner apps.

    E2E Impact

    Verdict: None
    Same grep as the 2026-11-08T07:01Z pass, re-run with no new hits: python-runner|eyevinn-python-runner|OSC_ACCESS_TOKEN|runner-token|OSC_REFRESH_TOKEN in osaas-e2e-tests tests/ and utils/. No spec boots a runner pod, so none asserts which token the entrypoint hands to the app.

    Existing test coverage: tests/test-entrypoint-runner-token-refresh.sh (Stage 1, 9 cases). Child S2 flips its success assertion.
    Guard tests lifted: None for #39. Child S2 flips tests/test-entrypoint-runner-token-refresh.sh:66 (the success case asserts the original token is visible to the app). It is not ADR-pinned: there are 0 ADR- hits in tests/. The flipped success case is its replacement protection.

    Necessity test

    Split decision: split.

    child reason (1-4) evidence
    S2 3 A human-only step blocks it. birme's decision says Stage 2 ships "together with the REJECT_RUNNER_REFRESH_TOKENS rollout, not before", and #109 says the rollout is "birme's call". Merged earlier, Stage 2 reaches prod at the next unrelated runner release and breaks long-running apps after one hour (the regression the decision names). Reason 2 also applies: it spans four runner repos and deploy units.

    10 of 10 requirements (R1-R10) are owned: 6 by merged PR #41 or existing tickets, and R2, R6 (Stage 2 part), R7 (approval line), R9 and R10 by S2.

    Human steps

    step why only a human which tickets it blocks
    Start the prod rollout of REJECT_RUNNER_REFRESH_TOKENS (reply on S2, add agent-actionable) Prod config and runner releases are birme's call (osaas-token-service#109, birme's decision on this ticket) S2 only. It is the first step of the remaining chain, because Stage 1 has already merged.

    Scope reductions

    None. Stage 2 is sequenced into child S2, which contains it literally. The start condition (with the rollout, not before) is birme's own decision, not a cut.

    Automated triage by architect agent

  11. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Architect Review (BLOCK)

    Verdict: BLOCK (architect-reviewer, scope gate). Nothing was created or moved. All findings are spec_fix; none needs a new decision from birme.

    1. [BLOCKER] S2 scope item 2 ("golang-runner: the same swap ...") adds a line that golang-runner tests/test-entrypoint-runner-refresh.sh:211-212 (case 10, "entrypoint never assigns OSC_ACCESS_TOKEN= inside the refresh block (Stage 2 swap)") forbids. It is not ADR-pinned (0 ADR- hits, no adr/ reference). The guard scan reads only *.test.* files and misses .sh guards. Needed: name this test and case 10 as lifted, not ADR-pinned; name the replacement protection (flipped success case asserting the app sees the fresh token) with its own AC; forbid moving the swap outside the markers to keep the guard green.
    2. [BLOCKER] Scope item 4 / AC5 let an implementer record python-job-runner as exempt. birme exempted wasm-runner only and his decision governs all five; the python-job-runner#6 triage (2026-11-08T08:14Z) verified the job inherits OSC_ACCESS_TOKEN (exec python job.py) and PR Strip embedded credentials from GIT_HOST to prevent PAT leak #8's test reads it at :73. Needed: remove the exemption branch, cite the Scrub PAT from origin remote URL after clone (security fix) #6 evidence, require the swap.
    3. [MAJOR] AC3 "Add the same success and failure pair to each other runner's entrypoint test" contradicts existing Stage 1 success pins: golang-runner tests/test-entrypoint-runner-refresh.sh:131-137, dotnet-runner :125, python-job-runner PR Strip embedded credentials from GIT_HOST to prevent PAT leak #8 :73; python-runner's assertion is at :75 on 4e01bf2, not :66. Needed: AC3 names each success assertion and says to flip it; failure-path and jq-127 "unchanged" assertions stay (e.g. dotnet :144).
    4. [MAJOR] The python-job-runner dependency ("once Runner refresh exchange always fails (see python-runner#39) python-job-runner#6 has merged") is prose only; S2 has no marker line. Needed: Blocked by: Eyevinn/python-job-runner#6 on its own line (a leaf), explanation on the next line.
    5. [MINOR] AC2 requires a [CONFIG] WARNING naming HTTP status and error code on every failure path, but merged golang/dotnet Stage 1 prints different text and leaves OSC_REFRESH_TOKEN unset on 401. Needed: reword so each runner keeps its Stage 1 failure behaviour as pinned by its existing tests and the app sees the original token.
    6. [MINOR] S2's last PR carries Closes Eyevinn/python-runner#39 without birme's caveat ("Whoever closes these tickets must not treat the tenant's report as resolved by them"). Needed: add to S2's closing statement that the nordiccare report (Slack, 2026-11-05) is not resolved by this work.
    7. [MINOR] AC4 puts the 1-hour-lifetime statement in PR bodies only; python-runner README.md:61 calls OSC_REFRESH_TOKEN "the original long-lived OSC_ACCESS_TOKEN". Needed: AC4 requires each runner's README OSC_ACCESS_TOKEN row to say it is a 1-hour PAT renewed with OSC_REFRESH_TOKEN.

    One revision cycle follows in the same run.

  12. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Architect Triage (revision after Architect Review BLOCK)

    Classification: LARGE (unchanged), one child S2 in Triage with Human Needed. This revises the proposal in #39 (comment) and applies all 7 findings of #39 (comment) in one pass. Delta only; everything else in the earlier triage stands.

    Changes to the S2 body:

    1. golang-runner guard (finding 1). Scope item 2 now names the swap point (config_access_token="$refresh_token", scripts/docker-entrypoint.sh:167-168 at 5d526be, inside # BEGIN runner-refresh .. # END runner-refresh). It names tests/test-entrypoint-runner-refresh.sh case 10 (:211-215) as lifted, not ADR-pinned (no ADR- reference in the file, no adr/ file names it), and forbids moving the swap outside the markers. New AC6: case 10 is replaced by a case asserting the refresh block holds exactly one export OSC_ACCESS_TOKEN= line, plus the flipped case 1. dotnet-runner (:135-196 at c5fbca0) has no such guard; scope item 3 says so.
    2. python-job-runner exemption removed (finding 2). Scope item 4 now requires the swap. Evidence: exec python job.py (scripts/docker-entrypoint.sh:158 on PR fix: make runner refresh exchange work (Stage 1) python-job-runner#8 head c282c8e), PR Strip embedded credentials from GIT_HOST to prevent PAT leak #8's test reads the job's token at :73, and the Scrub PAT from origin remote URL after clone (security fix) #6 triage (Runner refresh exchange always fails (see python-runner#39) python-job-runner#6 (comment)) found the same. AC5 is now "swap applied, no exemption". R10's citation includes the Scrub PAT from origin remote URL after clone (security fix) #6 triage.
    3. AC3 names the assertions to flip (finding 3), re-verified on current heads: python-runner :75 (on 4e01bf2, main), golang-runner case 1 :133 (SHELL_TOKEN; :134 and FRESH_EXPORTED=0 at :135 stay), dotnet-runner :125 (:126 and :144 stay), python-job-runner :73 on c282c8e (:74 stays). Every failure-path assertion stays.
    4. Leaf blocker (finding 4). The body now carries Blocked by: Eyevinn/python-job-runner#6 on its own line, with the explanation on the next line.
    5. AC2 (finding 5) now keeps each runner's Stage 1 failure behaviour as its tests pin it (golang and dotnet leave OSC_REFRESH_TOKEN unset on a 401 with refresh_token_expired, refresh_token_revoked or refresh_token_invalid), and the app sees the original token.
    6. Tenant-report caveat (finding 6). What a human does next and the last PR's body state that the nordiccare report (Slack, 2026-11-05) is not resolved by this work, quoting birme's decision.
    7. README rows (finding 7). AC4 requires each runner's README OSC_ACCESS_TOKEN row to say it is a 1-hour PAT renewed with OSC_REFRESH_TOKEN (python-runner :60, golang-runner :22, dotnet-runner :20, python-job-runner :16) and corrects the lines that say the app keeps the original token (python-runner :61, golang-runner :98, dotnet-runner :26).

    Guard tests lifted: golang-runner tests/test-entrypoint-runner-refresh.sh case 10, not ADR-pinned, replaced per AC6. Other tests/*.sh in golang-runner, dotnet-runner and python-runner grepped for OSC_ACCESS_TOKEN assertions: none other.

    Scope reductions

    None.

    scope-cut-lint.sh on the revised proposal: 13 findings, the same count as the earlier proposal; the one phrase hit is the quoted closing text of golang-runner#32 ("deferred to that rollout"), and the pointer hits are context references to closed Stage 1 tickets and osaas-token-service#109.

  13. birme commented on Nov 8, 2026

    @birme
    ContributorAuthor

    Decomposition (scope gate cleared)

    architect-reviewer verdict: APPROVE on re-review (one BLOCK cycle before it). Stage 1 of this ticket is merged (python-runner PR #41, 4e01bf2; golang-runner#32, dotnet-runner#31, wasm-runner#37 closed). The only unowned remainder is Stage 2.

    Criterion or pointer -> ticket: R1, R3, R4, R8 -> done (PR #41, sibling tickets); R2, R5-R7, R9-R13 -> #42; Stage 2 pointers in golang-runner#32, dotnet-runner#31, python-job-runner#6/PR #8 -> #42.

    This parent stays OPEN and moves to In Review with the Decomposed label; it closes when #42 closes.

  14. added
    Decomposed
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Decomposedagent-actionable

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions