Repository navigation
Description
Goal
The Worker can talk to a Tapis tenant, and everything about that conversation is tested against a stand-in before a tenant exists.
After this phase there is a typed Tapis client with two interchangeable credential strategies, a stand-in server with failure modes, the dark switch computeEnabled, and an admin status view the owner can use to check credentials once secrets are set.
Routing
- Readiness: ready; the phase must list what is unverified (below) in the PR body.
- Implementer: Sonnet
- Opus checkpoint: none
- Depends on: Phase A1: Compute contract and ADR 0118 #2006, Phase A2: Allocation ledger and owner policy #2007 (it adds a command to Phase A2: Allocation ledger and owner policy #2007's group) ; Unblocks: Phase A5: Job lifecycle, webhooks, settlement and results #2010
- Repository and base branch: nemarOrg/nemar-cli, epic branch
feature/issue-#2005-epic-compute-core. Run after Phase A3: Job records and the results and records buckets #2008, not beside it: both edittypes/bindings.tsandwrangler-sccn.toml.
Scope
In: backend/src/services/tapis/; backend/test/helpers/tapis-standin.ts; computeEnabled; GET /admin/compute/status and nemar admin compute status.
Out: orchestration, webhooks and cron (#2010), the person-level Tapis username and token minting for people (Epic D), any real tenant call, any secret value.
Design references
Design sections 3 (Tapis identity, the compromised-partner caution), 7 (states, webhooks), 12 (questions 1, 2, 10, 13, 16). Implementation notes section 5 (Tapis facts). Template for the token cache: backend/src/services/github-auth.ts; for errors: HttpError and isRetryable in services/retry.ts; for the base URL override: GITHUB_API() in services/github/shared.ts; for the switch and its pin: autoRepullEnabled in services/repull-switches.ts and backend/test/repull-switches-flag.test.ts. Tapis OpenAPI files: JobsAPI.yaml in tapis-project/openapi-jobs, service/resources/openapi_v3.yml in tapis-project/tokens-api and tapis-project/authenticator.
Changes
backend/src/services/tapis/config.ts:tapisConfig(env)returns{ strategy: "password" | "service", baseUrl, tenantId, ... }or{ unconfigured: true }. Optional bindings intypes/bindings.ts:TAPIS_BASE_URL,TAPIS_TENANT_ID,TAPIS_AUTH_STRATEGY,TAPIS_USERNAME,TAPIS_PASSWORD,TAPIS_SERVICE_TOKEN. They are Worker secrets or owner-set vars, never in the toml (a tenant name is not public); the toml comment block lists the names only.TAPIS_BASE(env)returnsglobalThis.NEMAR_TAPIS_API_URLif set, elseenv.TAPIS_BASE_URL.tapis/auth.ts: password strategyPOST /v3/oauth2/tokenswith{ username, password, grant_type: "password" }; service strategyPOST /v3/tokenswith the service token inX-Tapis-Tokenand{ account_type: "user", token_tenant_id, token_username, access_token_ttl }. Both answerresult.access_token.access_tokenwithexpires_in. Module-scope cache keyed by strategy and username, refresh lead, one shared in-flight promise, a failed mint is dropped;invalidateTapisTokenafter a 401 and exactly one retry. Dev and production never share a credential because each Worker reads its own secrets.tapis/schemas.ts: zod from the OpenAPI schemas (ReqSubmitJob,Job,JobListDTO, the response envelope{ status, message, version, result }, history events, output listing, subscription)..passthrough()on responses, strict on what NEMAR sends; a response that fails its schema isinvalid_response, never partially trusted.tapis/client.ts:submitJob,getJob,getJobHistory,cancelJob,searchJobsByTag,listJobs({ listType, limit, skip }),subscribeWebhook(uuid, address, ttlMinutes),listOutputs,downloadOutput(uuid, path, maxBytes). All paths are under/v3/jobs/(/submit,/{uuid},/{uuid}/history,/{uuid}/cancel,/search,/list,/subscribe/{uuid},/{uuid}/output/list/{path},/{uuid}/output/download/{path}). Every call has a 15-second timeout and a bounded body read; failures are aTapisErrorwith kindunconfigured | unauthorized | not_found | rejected | unavailable | invalid_responsewrappingHttpError; reads retry throughisRetryable,submitJobnever retries inside the client (the caller searches by tag first). GPUs have no field onReqSubmitJob; the request builder passes them as aparameterSet.schedulerOptionsentry and the partition asexecSystemLogicalQueue. Say so in a comment.backend/test/helpers/tapis-standin.ts:Bun.servebuilt from the request and response examples in the OpenAPI files, in-memory jobs withadvance(uuid, status, condition?), tag search, subscription capture andfireWebhook(uuid)(POSTs the recorded address with a CloudEvents-shaped body), a request log with headers, and failure modes: forced status per route, hang, non-JSON body,401 then accept after refresh, down. Header comment: no response was recorded from a real tenant. Addif (import.meta.main)so it can be started by hand.backend/src/services/compute-switches.ts:computeEnabled(env)is(env.ENVIRONMENT === "production" || env.ENVIRONMENT === "development") && env.COMPUTE_ENABLED === "1", so staging (the dev Worker) can run compute against the dev tenant with its own credentials while every compute cron stays production-only; in development a job advances by its webhook, the read-through refresh andnemar admin compute jobs advance(Phase A5: Job lifecycle, webhooks, settlement and results #2010);computePipelinesDispatchEnabled(env)iscomputeEnabled(env) && env.COMPUTE_PIPELINES_DISPATCH_ENABLED === "1". Both names are absent from every table ofwrangler-sccn.toml.GET /admin/compute/status(admin) inroutes/admin/compute.tsandnemar admin compute status [--json]: both switches as the Worker reads them, the strategy, whether each of Tapis, the two R2 bindings with the signing secrets, and the ACCESS key is configured (booleans, never values), and the result of one token mint and one health call, as fixed words.
Tests (write these first)
backend/test/compute-switches-flag.test.ts(templaterepull-switches-flag.test.ts): walks every table of the toml and fails if either switch name appears;computeEnabledis false for"true"," 1", unset, and anENVIRONMENTthat is unset or anything other than exactlyproductionordevelopment, and true for exactly"1"in those two. Mutation: make the check=== "true"; it must fail.backend/test/tapis-client.test.tsagainst the stand-in: each call sendsX-Tapis-Tokenand the documented body; a 401 refreshes the token once and retries once, a second 401 isunauthorized; a hang ends asunavailablewithin the timeout; a non-JSON or schema-failing body isinvalid_response; concurrent calls mint one token.- Same file, both strategies: password sends the password grant body, service sends the service token header and the owner username; the same client function works under either.
submitJobbuilds the documented request (tag, no archive system fields,schedulerOptionsfor GPUs); a test asserts the exact JSON the stand-in received.backend/test/compute-status-route.test.tsand a CLI test: an unconfigured Worker reportsunconfigured; no secret value or tenant URL appears in any output.
Acceptance criteria
- Neither strategy needs a code change to switch; selection is configuration.
- No tenant name, hostname or credential in the diff or the logs; the status view prints booleans and fixed words.
- The PR body lists what is unverified: which strategy the operator grants, whether
listType=ALL_JOBSreturns every person's jobs, the POST search body shape, the service-token minting permission, the webhook retry policy, and theschedulerOptionsspelling for GPUs. - The stand-in file says no real response was recorded.
Gates
bun test backend/test/compute-switches-flag.test.ts backend/test/tapis-client.test.ts backend/test/compute-status-route.test.ts test/admin-route-inventory.unit.test.ts test/api-export-surface.unit.test.tsbun run typecheck,bunx biome check src shared backend/src,bun test
Rules that bite here
- Switches are dark by default and pinned absent from the toml; production means exactly
production. - Tokens are secrets: never logged, never in an error message, never in a test snapshot.
- A hung upstream must not hang a Worker request: every call has a timeout.
- Never mock the client: the stand-in is a real HTTP server and the client under test is the production one.
Escalate to the owner if
- The OpenAPI files and the stand-in examples disagree on a field NEMAR depends on.
- A new Worker secret name is needed beyond the list above.
When merged
Add the verified-or-unverified list to design section 12 as "assumed in code", and the secret names to the owner actions.
Activity
neuromechanist commentedon Nov 4, 2026
Driver amendment, 2026-11-04, from the phase A1 review (PR #2030) and the Opus advisor. This comment is part of the phase brief; where it differs from the body above, this comment wins.
parameterSetwith the environment variables. The launch specification, includingjob_token, travels in the environment variableNEMAR_LAUNCH_SPEC, so whoever can read the Tapis job record can read the token. Record in the client's notes exactly which job fields and which roles can readparameterSet, and say so in the PR body. Who the Tapis owner of a CLI or web job is stays the repository owner's decision (see the amendment on Phase A5: Job lifecycle, webhooks, settlement and results #2010); do not decide it here.neuromechanist commentedon Nov 4, 2026
Owner decision, 2026-11-04 (recorded by the driver). This comment is part of the phase brief; where it differs from the body or an earlier comment above, this comment wins.
The Tapis owner question is settled: there is a single NEMAR tenant and NEMAR owns every job, so the client's
ownerstays a parameter (a NEMAR service identity from configuration, never a person). Record in the PR body which Tapis roles can read a job'sparameterSet, as already asked, but the person-readable-token concern is closed: no person has Tapis access.neuromechanist commentedon Nov 4, 2026
Merged into the epic branch by #2038 (squash c3e815b). Round 1 (two reviewers) and round 2 (delta) converged; 20 round-1 items and four round-2 Low findings fixed; 357 targeted tests pass; every guard mutated. Nothing was verified against a real Tapis tenant: the unverified list is in the PR body. Owner decision pending: the secret name
ACCESS_GATEWAY_API_KEYis provisional. The amendment for the next phase is on #2010.