Repository navigation
Phase A4: Tapis client and stand-in - #2038
Merged
neuromechanist merged 12 commits intoNov 4, 2026
Merged
neuromechanist merged 12 commits into
neuromechanist merged 12 commits into
Conversation
4 tasks
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2038Version: 🤖 Updated on each push. |
neuromechanist
merged commit Nov 4, 2026
c3e815b
into
feature/issue-2005-epic-compute-core
1 check passed
neuromechanist
deleted the
feature/issue-2009-phase4-tapis-client-and-stand-in
branch
November 4, 2026 20:59
This was referenced Nov 4, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase A4 of the compute gateway core (epic #2005, issue #2009, ADR 0118): the Worker can talk to a Tapis tenant, and every part of that conversation is tested against a stand-in before a tenant exists. No tenant, secret or production object was touched, and nothing here has been verified against a real tenant.
What changed
backend/src/services/tapis/:config.ts(tapisConfig(env)is{ strategy, baseUrl, tenantId, ... }or{ unconfigured: true, problems };TAPIS_BASE(env)isglobalThis.NEMAR_TAPIS_API_URLelseTAPIS_BASE_URL, which must be https),auth.ts(password grant and service-minted user tokens behind one cache keyed by strategy and username, refresh lead, one shared in-flight mint, a failed mint dropped, compare-and-deleteinvalidateTapisToken),http.ts(15-second timeout nobody can lengthen, bounded streaming body read, no redirect, no body ever read into an error),errors.ts(TapisErrorwith kindunconfigured | unauthorized | not_found | rejected | unavailable | invalid_responsewrappingHttpError, andoutcomeUnknown),schemas.ts(zod from the OpenAPI schemas: strict on what NEMAR sends,.passthrough()on responses) andclient.ts(submitJob,getJob,getJobHistory,cancelJob,searchJobsByTag,listJobs,subscribeWebhook,listOutputs,downloadOutput,tapisHealth,nemarJobTag).backend/test/helpers/tapis-standin.ts: a realBun.servestand-in with in-memory jobs (advance), the documented tag search, subscription capture,fireWebhook(CloudEvents-shaped notification,User-Agent: Tapis/v3), a request log with headers,ALL_JOBSas the documentation defines it (own plus shared,shareJob), afullRecordsmode that ignoresselectand serves whole records (fullRecordsServednotes a job only when the answer really carries bothparameterSetandsubscriptions), and the failure modes (forced status per route, hang, non-JSON or wrong-shape or invalid-UTF-8 bodies, chunked and broken streams, expired tokens, every token rejected, down and up). Its header says no response was recorded from a real tenant, andbun backend/test/helpers/tapis-standin.tsstarts it by hand.backend/src/services/compute-switches.ts:computeEnabled(env)is exactlyproductionordevelopmentandCOMPUTE_ENABLEDexactly the string"1", read at call time;computePipelinesDispatchEnabled(env)also needsCOMPUTE_PIPELINES_DISPATCH_ENABLEDas the string"1". Both names, and every Tapis name, are absent from every table ofwrangler-sccn.tomland pinned bycompute-switches-flag.test.ts; the toml comment block lists the Tapis secret names only.GET /admin/compute/status(admin) andnemar admin compute status [--json]: both switches as the Worker reads them, the strategy, whether each of Tapis, the two R2 bindings, the signing secrets and the ACCESS key is configured, and one fresh token mint and one health call as fixed words. Booleans and words only: no secret, address, tenant name or username..context/compute-program/implementation-notes.mdhas a new section 9.Round 1 review: what was fixed
TapisJobis derived from the schema (TapisJobSchema.omit(...)withz.infer), sojob.uuidandjob.statusare typed; the oldOmitof a passthrough type collapsed every field tounknown. A compile-time assertion inschemas.ts(covered bytsc -p backend, unlike the tests) fails the typecheck if it collapses again or ifparameterSetorsubscriptionsbecomes a named key.invalidateTapisToken(env, owner, refusedToken)deletes only when the cache still holds the refused token, so callers that hold one stale token share one new mint (8 concurrent calls after expiry add exactly one mint).parameterSetorsubscriptions" rule is now tested on search and list against a tenant that ignoresselectand serves whole records, as well as on get and submit.expires_in0 or missing or fractional,[],null,{}) areinvalid_response, send no emptyX-Tapis-Token, cache nothing, and are reported asinvalid_responseby the status route.parameterSet.archiveFilter: { includeLaunchFiles: false }(field and nesting checked againstReqSubmitJob->JobParameterSet.archiveFilter->IncludeExcludeFilter.includeLaunchFilesin the Jobs OpenAPI), the request schema allows exactly that key with that value, anddownloadOutputandlistOutputsrefuse a path whose basename istapisjob.envortapisjob.shin any case. The application definition'sarchiveIncludeLaunchFiles: falsestays as the second layer (nemar-process phase C5).LAUNCH_SPEC_ENV_KEYisLAUNCHER_ENV.SPEC, not a second copy of the word, and the tests assert the contract's word.submitJobrefuses an owner that is not the configured account (kindunconfigured, a fixed sentence that names no one); under the service strategy the owner stays a free parameter.RangeError, not a clamp);maxAttemptsthat is not a finite number is the default 3 and anything else is kept within 1 and 3 (a NaN used to stop a read from running at all);retryDelayMsis kept within 0 and 5000 ms (not a number: 500).subscribeWebhookrefuseshttp:addresses unless the test-only base URL override is active, because the address carries a token.unavailableandinvalid_responseofsubmitJob,cancelJobandsubscribeWebhookcarryoutcomeUnknownand say so in the message (a 2xx answer that fails its schema means the job may exist, so search by tag before any re-submit); the status the answer came with is carried, and a refusal, a failed read or a mint that failed before anything was sent is not marked.=== "1", andisOneis a refactor that names the rule. The new tests pin that a TOML integer,true,["1"],new String("1"),{ toString },1nand" 1"do not turn a switch on, and thatString(x) === "1"andx == "1"would.ALL_JOBSin the stand-in is the caller's own jobs plus the jobs shared with the caller, as the documentation says (the stand-in used to return every job in the tenant), and the client's comment says the same; the stand-in's status list is written out from the specification and a test compares it with NEMAR's.AbortSignal.timeoutwhatever a caller asks for, the chunked bound is exact (the bound accepted, one byte over refused), a body that stalls or breaks after the headers isunavailable(and a read tries three times, a submit once), and invalid UTF-8 isinvalid_response. The status route's own default timeout is pinned at 8 seconds for the mint and for the health call.Round 2 review (delta): four low findings, fixed
isOneis a refactor with no change of behaviour (the code was already a strict=== "1"); the comment incompute-switches.tsand the round-1 bullet above now say so, and what the round added is the tests.invalid_responseis pinned at every site that carries it, each checked by replacing the status with null at that site and running the client file: the mint's non-JSON body (new test, 200), the mint's schema failure (201, asserted in the wrong-shape test), the over-bound body (200, asserted in the chunked test), the job calls' non-JSON body (200, asserted on a read and on a submit), their schema failure, the health call's non-JSON body (200), the health schema failure, and the parse helper's own error. All eight were killed (three of them, and the job-call and health non-JSON sites, survived before this round).invalidateTapisTokenwith an empty refused token never drops a mint in flight: a direct test holds a mint in flight, passes"", and asserts that a secondgetTapisTokenshares the single mint (two strategies); removing therefused !== ""guard was killed.fullRecordsServednow notes a job only when the answer really carries bothparameterSetandsubscriptions(for search and for list, after paging), so a stand-in that honouredselectunderfullRecordsmakes the test fail (killed, and the list variant too); the archive-filter comment says the request's filter is merged over the default (assumed, unverified); and the circular test line that read the stand-in's own echo ("Tapis's record says so") is gone, leaving the assertion on the body that was sent.Who can read a job's
parameterSet(the amendment on #2009; all of it unverified against a real tenant)The launch specification, including
job_token, travels inNEMAR_LAUNCH_SPEC, which Tapis keeps in the job record'sparameterSet.envVariables. From the Jobs specification and documentation, the roles that can read it are: the job's owner, its creator and a tenant administrator, throughGET /v3/jobs/{uuid}and the search with every attribute; a user the job'sJOB_HISTORYresource was shared with (the documentation says that grantee can get the job's history, status and "job's detail information", and search the jobs shared with them); a user itsJOB_RESUBMIT_REQUESTresource was shared with, throughGET /v3/jobs/{uuid}/resubmit_request(the whole submission request); and a user itsJOB_OUTPUTresource was shared with, through the launch filestapisjob.envandtapisjob.shthat Tapis archives with the output unlessarchiveFilter.includeLaunchFilesis false.JobListDTO(the list), the status and the history have no such field. The same record'ssubscriptionsfield carries the webhook address, which holds a token. Per the owner's decision there is one NEMAR tenant and NEMAR owns every Tapis job, so no person can read any of this; the client'sownerstays a parameter (a NEMAR service identity from configuration), and a test pins that it is never a constant. As defence in depth the client never returnsparameterSetorsubscriptionsfrom any record, the tag search asks only for named fields, every submit asks Tapis not to archive the launch files, and the client will not read those two files.Gates
bun testonbackend/test/tapis-client.test.ts,compute-switches-flag.test.ts,compute-status-route.test.ts,test/admin-compute-status-cli.test.ts,test/compute-admin-contract.unit.test.ts,test/contract-schemas.test.ts,repull-switches-flag.test.ts,compute-buckets-config.test.ts, the admin route inventory, the CLI export surface,test/compute-contract.unit.test.tsandtest/admin-compute-cli.test.ts:803 pass, 0 fail, 12 filesat the current head (the client file alone is 168 tests in about 2.7 seconds).bun run typecheck: clean (tsc --noEmit && tsc --noEmit -p backend).bunx biome checkonsrc shared backend/src: only the 5 known errors in untouchedzenodo.tsanddoi-orcid-discovery.ts; the touched test files have warnings only (anyin test bodies, as in the neighbours).What was mutated, and how
Each mutation is one line (or one expression) of production code changed, the one test file that guards it run, and the file restored; the run was done with the test file as a separate argument from the command.
schemas.ts,auth.ts,client.ts,http.ts,errors.ts,compute-switches.tsandcompute-status.ts, covering items 1 to 5, 7 to 16 and 19 of the review (theTapisJobcollapse and a secret field left in the type, both caught bytsc -p backend; unconditional and never-firing invalidation; search, list, get and submit left uncleaned; an empty token returned after a failed mint parse;min(1)dropped from the token andexpires_in; the health check dropped, and its status dropped; the archive key not sent, loosened, made optional or open; each launch file left readable, the case fold and the basename logic; the password owner check off or applied to the service strategy; each cap, bound and guard of attempts, delay and download size, at its helper and at each call site; http webhook addresses allowed or https refused; the outcome flag and sentence left out, set on reads, or set on the wrong kinds; the transport ceiling bypassed; the chunked bound at three times and at plus one; the body error catch removed; a lenient UTF-8 decoder;String(x),==andx === 1in place of the string test; the status route's timeout), plus two of the stand-in (ALL_JOBSback to the whole tenant, a status removed from its list). All were killed. One mutation (the healthsafeParse) first did not apply because of formatting, was redone and killed; one (the health status carried as null) survived and got an assertion. Replacing the status carried on aninvalid_responsewith null was killed at the schema-failure site and the health-schema site of that round only; round 2 found the others and pinned them (below).statusand the CLI command that round 1 did not touch were covered in the first pass; the retry log lines ([retry] ...) are the Worker's own and fixed-text.AbortSignal.timeoutis asked for (the real one still does the timing), and the retry waits by recording whatsetTimeoutis asked for (cut to 1 ms), so those two tests wrap a platform primitive and do not replace any NEMAR logic.Unverified (nothing was checked against a real tenant)
X-Tapis-Tokenis howPOST /v3/tokenstakes the service credential: the issue and the notes say so, while the Tokens API specification does not state it and declares a basic-auth security scheme for that API.listType=ALL_JOBS: the documentation says it lists the caller's own jobs plus the jobs shared with the caller, not every job in the tenant, which contradicts the earlier assumption (and the first stand-in) that it returns every person's jobs. A search by tag before a re-submit is therefore safe only while one identity submits and searches, which the 2026-11-04 owner decision gives; whether a tenant administrator sees more is unknown.{ "search": ["tags IN ('nemar_job:<id>')"] }is the Jobs documentation's example, and the specification only saysobject.parameterSet.archiveFilter.includeLaunchFilesfrom the request, and how it merges with the application definition's setting (the documentation says theincludesandexcludesarrays are merged and is silent on the flag).ttlminutesof the subscription lifetime (both the specification and the documentation use it; the notification service's own field isttlMinutes).schedulerOptionsspelling for GPUs:{ "arg": "--gpus=N" }, as Expanse's user guide writes it, and that a scheduler profile does not hide it.memoryMBtakes Tapis's 100 MB default unless the application sets one).parameterSetas a string or an object, a history event'seventDetailorjobStatus, a file'surloruri); the client accepts both.;and&): its documentation says such values are double quoted and rejects control characters, and does not say how a quote inside one is escaped. This could breakNEMAR_LAUNCH_SPECon the first real job and is worth a deliberate test on thedebugpartition.Deviations from the issue and from the review list
ACCESS_GATEWAY_API_KEY; no secret exists, so renaming is a few lines.TAPIS_USERNAMEis optional and is the NEMAR service identity the status probe mints a token for; without it the token step answersskipped.{ env, owner, timeoutMs?, retryDelayMs?, maxAttempts?, now? }first, which the issue's signatures leave out; the knobs exist so tests do not wait, and each is now bounded (see above).submitJob,cancelJobandsubscribeWebhooknever retry inside the client. A 401 is refreshed once and retried once for every call, submit included. 403 isunauthorizedand not refreshed; other 4xx and a 3xx arerejected, and a redirect is never followed.parameterSetandsubscriptions, the named-field search, the archive filter and launch-file refusal,outcomeUnknown, and the status response schema inshared/contract/compute-admin.ts(open, like its neighbours).maxAttemptsorretryDelayMsis the default, and a finite one is clamped; the webhook rule reuses the base URL override; the password-owner refusal is kindunconfigured; the transport and status-timeout tests recordAbortSignal.timeoutandsetTimeoutinstead of waiting 15 or 5 seconds.tapis/source files each carry several of the review items, so one commit holds the client work, one the switches, one the status route tests and one the notes..rules/testing.mdin this checkout has no "Test cost" section; the whole client file runs in under three seconds.origin/main. The issue's "When merged" docs step (design section 12 as "assumed in code", the secret names in the owner actions) is the driver's and is not done here.--fail-on-problemflag onnemar admin compute status(it exits 0 by documented design) and a call-level time budget in the client (the ceiling is per request; phase A5's brief says read-through calls passmaxAttempts: 1and a shorttimeoutMs).Not run, would check
bun test: the owner's rule is that it runs at epic to dev as CI.bun run migrations:d1-check: there is no migration in this phase.compute-jobs,compute-records,compute-s3): this phase does not touch them, and the status suite starts the same harness.