Skip to content

runtime/flybot-image: recipe tests read the host's real /run/secrets model-api file and fail on a provisioned host #3490

Done

Description

@Birfy

The recipe's own contract tests are not hermetic: test/model-api.test.js:66 assumes the machine has no default model-api secret file, so npm test inside runtime/flybot-image fails on any host that has been provisioned with the deployment secret.

Exact commit: 4b8d4216781201383b34fcf84f86efed071527bb (tree cb0da4c0e8f64e90bd84eced6e95b1924e2490f1).

Reproduce on a host that has run the runtime image at least once (secret owned by uid 1000):

ls -l /run/secrets/flybot-workspace-model-api.json
cd runtime/flybot-image && npm test

Expected: 29 pass. The test builds its own temporary secret files under a temp dir and only wants to prove the allowlist behaviour.

Actual: 28 pass, 1 fail.

not ok 4 - reads only allowlisted secret paths and skips a missing file
  test/model-api.test.js:80
  + actual   '/run/secrets/flybot-workspace-model-api.json'
  - expected undefined

Cause: model-api.js resolveModelApiPath walks the hard-coded DEFAULT_FILES (/run/secrets/flybot-workspace-model-api.json, /data/secrets/model-api.json) and returns the first that exists. test/model-api.test.js:80 asserts resolveModelApiPath({}) === undefined, which only holds on a machine without those files; the test's own comment admits the helper hard-codes the default paths.

Why CI stays green: GitHub-hosted runners do not have /run/secrets/..., so the same test passes there. The red only appears on the operator host the recipe is built for.

Scope: test isolation, not a product defect — loadModelApi / applyModelApi behave as designed. A fix has to make the default list injectable (or make the assertion depend on the file's real presence) instead of assuming a bare host.

Related #3489

Activity

  1. added
    agent-ready
    agent-working
    on Dec 2, 2026
  2. Birfy commented on Dec 2, 2026

    @Birfy
    CollaboratorAuthor

    Claiming this for one reviewable slice.

    Branch: dev/3490-hermetic-model-api-tests (from main a062ba2158261ed0e5e5e217723e19df290ff02a).

    Plan: make the default candidate list an optional argument of resolveModelApiPath / loadModelApi, pass an explicit empty list from the test so it stops reading host state, and assert that every DEFAULT_FILES entry lives under an ALLOWED_PREFIXES directory so the invariant the old assertion was reaching for is still covered. Production callers keep the single-argument form.

    Local readings on this host (which does have /run/secrets/flybot-workspace-model-api.json, 272 B), not CI: runtime/flybot-image npm test 29/29 pass after the change versus 28/29 on main a062ba21; repo root tests/*.test.mjs 974/974 pass.

  3. Birfy commented on Dec 2, 2026

    @Birfy
    CollaboratorAuthor

    Implemented and merged.

    1f62d02b1df63ca8bd5215c7469c39223f4d7406 — squash of #3492, single parent a062ba21, tree 74859f440f2584fde3954984e466eb4584ea7df0, 2 files +15/-8 (runtime/flybot-image/model-api.js 5/5, runtime/flybot-image/test/model-api.test.js 10/3).

    resolveModelApiPath and loadModelApi now take an optional second argument (defaults = DEFAULT_FILES), so the recipe test asserts against an empty list instead of the host secret store; a new assertion keeps every entry of DEFAULT_FILES inside ALLOWED_PREFIXES. Production call sites (ds-bot-bridge.mjs:623, launch.mjs:10) still call with a single argument, so runtime behaviour is unchanged.

    Local check on a host that does have /run/secrets/flybot-workspace-model-api.json (272 B): the package goes from 28/29 to 29/29 rc 0, and reverting the defaults turns the new assertions red again.

    Related #3492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyagent-working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions