Skip to content

A worker answers the fleet operations as a fleet of one #270

Closed

Description

@V3RON

Part of #88.

Scope

On a single host, simlock worker list and GET /v1/workers show that
host as one worker, with the same fields a gateway shows for each of its
workers. The fleet operations that cannot apply to a single host refuse
with their own code instead of UNKNOWN_REQUEST or 404.

Technical spec

Implements ADR 0012 in full.

Modules touched

  • src/contract: a pure function that turns the results of status.get,
    list.get (devices), catalog.get and the config into a worker view's
    fields (ADR 0012 §1). GATEWAY_ONLY_OPERATIONS is removed from
    operations.ts. The new error code in errors.ts.
  • src/gateway/worker-link.ts: builds its views with that function.
    Behaviour does not change.
  • src/daemon/dispatcher.ts: handlers for worker.list (one view of
    itself) and for worker.drain|undrain|remove|install-component (throw
    UNSUPPORTED_IN_WORKER_MODE). The dispatcher gains the instance id and
    gateway.label as options.
  • src/daemon/main.ts (or wherever the dispatcher is built): passes the
    instance id and label in.
  • src/http/app.ts: the four /v1/workers* routes are registered in both
    modes.
  • src/cli/index.ts: worker list prints the one view on a worker, with
    no special case.

Contract and event changes

  • worker.list answers on a worker. Its output shape does not change.
  • New error code UNSUPPORTED_IN_WORKER_MODE: HTTP 501, CLI exit 2,
    details { operation }. Added to ErrorDetailsMap, ERROR_TABLE and the
    declared-details table.
  • No protocol version change. No event changes.
  • Docs updated as ADR 0012 Consequences lists: HTTP-API.md (the worker
    routes paragraph, the 501 row), CLI.md (exit-code table and notes,
    every place a worker command answers UNKNOWN_REQUEST on a worker),
    CLIENT.md, docs/internal/ARCHITECTURE.md.

Rules in play

  • architecture.md: one place builds a worker view; the contract module
    stays free of engines and I/O.
  • testing.md: the gateway's views must still come out the same; prove it,
    don't assume it.
  • documentation.md: end-user docs describe the behaviour with no ADR
    links.

Tests

  • worker.list on a worker returns one view whose id is the instance id
  • worker.list on a worker carries gateway.label as label, and no label when it is unset
  • worker.list on a worker reports the same capacity, devices, leases, catalog, host and installs as its own reads
  • the worker view builder gives a gateway the same view it built before this change
  • worker.drain, worker.undrain, worker.remove and worker.install-component on a worker fail with UNSUPPORTED_IN_WORKER_MODE
  • GET /v1/workers on a worker answers 200 with one worker for an operator token
  • GET /v1/workers on a worker answers 403 for an agent token
  • POST /v1/workers/{id}/drain on a worker answers 501 UNSUPPORTED_IN_WORKER_MODE
  • POST /v1/components/install with workers on a worker answers 501
  • simlock worker list against a worker prints that worker (e2e)
  • simlock worker drain against a worker exits 2 with UNSUPPORTED_IN_WORKER_MODE (e2e)

The existing test in src/http/app.test.ts that expects 404 for the
worker routes on a worker is replaced, not kept.

Done when

  • simlock worker list on a single host prints one line for that host.
  • curl with an operator token to GET /v1/workers on a single host
    returns one worker, with the same fields a gateway returns.
  • simlock worker drain <id> on a single host exits 2 and names
    UNSUPPORTED_IN_WORKER_MODE.
  • A gateway's simlock worker list output is unchanged.
  • The docs named above say the new behaviour.

Out of scope

  • The console itself.
  • Draining or removing a single host.

Depends on

Approval

  • Approved for delivery

Written by an agent.

Activity

  1. added
    task:draft
    on Oct 2, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Oct 2, 2026
  3. github-actions commented on Oct 2, 2026

    @github-actions
    Contributor

    Now task:ready: approved, technical spec present.

  4. self-assigned this
    on Oct 2, 2026
  5. added 5 commits that reference this issue on Oct 2, 2026
    31e2725
    8742851
    f0c510b
    d7d4af4
    47de845
  6. added 2 commits that reference this issue on Oct 3, 2026
    cb8a503
    780bf3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions