Skip to content

feat(engine): orchestrator external_ref on boxes (CRI uid analog)#747

Merged
G4614 merged 1 commit into
refactor/drop-legacy-boxid-fieldfrom
feat/engine-external-ref
Jun 12, 2026
Merged

feat(engine): orchestrator external_ref on boxes (CRI uid analog)#747
G4614 merged 1 commit into
refactor/drop-legacy-boxid-fieldfrom
feat/engine-external-ref

Conversation

@law-chain-hot

Copy link
Copy Markdown
Contributor

Summary

Stacked on #744. Implements the identity follow-up discussed on #735 (see the "Identity model note" comment there): the engine gains a CRI-style orchestrator reference, and the runner stops squatting the engine's name slot to carry the control-plane box id.

before                                after
──────                                ─────
runner: WithName(cloudId)             runner: WithExternalRef(cloudId)
engine: name = cloudId (squatted)     engine: external_ref = cloudId
        name unavailable for users            name free for a future
                                              user-facing box name

Industry precedent (verified sources):

  • CRI PodSandboxMetadata.uid — the orchestrator's id travels as a dedicated metadata field; the runtime mints its own id (cri-api api.proto, message PodSandboxMetadata)
  • ECS agent attaches com.amazonaws.ecs.task-arn as a docker label (docker_task_engine.go)
  • The caller-supplied-id pattern (OCI runtime spec create <container-id>) applies to stateless executors (runc/firecracker), not to stateful daemons like this engine — hence a reference field, not id injection.

What changed

  • engine: BoxOptions.external_ref (opaque, json-persisted via the existing config blob — no DB migration; lookup_box already scans configs). Duplicate refs are rejected at create. Lookup order: exact id → name → external_ref → id prefix. BoxInfo exposes it, omitted when unset.
  • C SDK: boxlite_options_set_external_ref, CBoxInfo.external_ref (NULL when unset, freed on drop — the leak-count test now expects 5 inner CStrings), header regenerated by the crate build.
  • Go SDK: WithExternalRef, BoxInfo.ExternalRef.
  • Node SDK: field filled with None (orchestrator-facing knob; not exposed in JS options yet).
  • CLI: inspect shows ExternalRef only when present; list columns unchanged (nothing empty is rendered).
  • runner: WithName(dto.Id)WithExternalRef(dto.Id); restart recovery (runtime.Get(dto.Id)) resolves through the external_ref match.

Verification

  • engine lib tests: 735/735; the new lookup_box_by_external_ref test was verified two-sided (fails with the lookup clause reverted, passes restored)
  • boxlite-c: 55/55
  • CLI / Node / Python crates compile; go vet clean on sdks/go and apps/runner/pkg/boxlite (final cgo link needs the prebuilt libboxlite.a, absent in this worktree)

Merge order

#743#735#744 → this PR. Self-contained: reverting is closing this PR.

…r's name-slot workaround

Mirror CRI's PodSandboxMetadata.uid: an orchestrator can attach an opaque
external_ref to a box at create time. The engine never interprets it,
rejects duplicates at create, and resolves lookups by id, name,
external_ref, then id prefix. The runner now attaches the control-plane
box id as external_ref instead of squatting the name slot, freeing name
for a future user-facing box name.

- engine: BoxOptions.external_ref (serde default, json-persisted; no DB
  migration — lookup_box already scans configs), create-time uniqueness
  check, BoxInfo exposes it (omitted when unset).
- C SDK: boxlite_options_set_external_ref + CBoxInfo.external_ref
  (freed on drop; leak-count test updated 4 -> 5 strings), header
  regenerated.
- Go SDK: WithExternalRef option, BoxInfo.ExternalRef.
- Node SDK: field defaulted to None (orchestrator-facing knob, not
  exposed in JS options yet).
- CLI: inspect shows ExternalRef only when present; list unchanged.
- runner: WithName(dto.Id) -> WithExternalRef(dto.Id); recovery via
  runtime.Get(dto.Id) now resolves through the external_ref match.

Tests: engine lib 735/735 (new lookup_box_by_external_ref test verified
two-sided: fails without the lookup clause, passes with it);
boxlite-c 55/55; CLI/node/python compile; go vet clean on sdks/go and
runner pkg (final cgo link needs prebuilt libboxlite.a, absent here).
@law-chain-hot law-chain-hot requested a review from a team as a code owner June 12, 2026 12:12
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 579fec00-c1c5-44fa-807e-da4bcca0f3e8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/engine-external-ref

Comment @coderabbitai help to get the list of available commands and usage tips.

@G4614 G4614 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can

@G4614 G4614 merged commit 1ca097a into refactor/drop-legacy-boxid-field Jun 12, 2026
3 checks passed
@G4614 G4614 deleted the feat/engine-external-ref branch June 12, 2026 14:18
law-chain-hot added a commit that referenced this pull request Jun 12, 2026
## Summary

Stacked on #744. Implements the identity follow-up discussed on #735
(see the "Identity model note" comment there): the engine gains a
CRI-style orchestrator reference, and the runner stops squatting the
engine's `name` slot to carry the control-plane box id.

```text
before                                after
──────                                ─────
runner: WithName(cloudId)             runner: WithExternalRef(cloudId)
engine: name = cloudId (squatted)     engine: external_ref = cloudId
        name unavailable for users            name free for a future
                                              user-facing box name
```

Industry precedent (verified sources):
- CRI `PodSandboxMetadata.uid` — the orchestrator's id travels as a
dedicated metadata field; the runtime mints its own id ([cri-api
api.proto](https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1/api.proto),
`message PodSandboxMetadata`)
- ECS agent attaches `com.amazonaws.ecs.task-arn` as a docker label
([docker_task_engine.go](https://github.com/aws/amazon-ecs-agent/blob/master/agent/engine/docker_task_engine.go))
- The caller-supplied-id pattern (OCI runtime spec `create
<container-id>`) applies to stateless executors (runc/firecracker), not
to stateful daemons like this engine — hence a reference field, not id
injection.

## What changed

- **engine**: `BoxOptions.external_ref` (opaque, json-persisted via the
existing config blob — no DB migration; `lookup_box` already scans
configs). Duplicate refs are rejected at create. Lookup order: exact id
→ name → external_ref → id prefix. `BoxInfo` exposes it, omitted when
unset.
- **C SDK**: `boxlite_options_set_external_ref`, `CBoxInfo.external_ref`
(NULL when unset, freed on drop — the leak-count test now expects 5
inner CStrings), header regenerated by the crate build.
- **Go SDK**: `WithExternalRef`, `BoxInfo.ExternalRef`.
- **Node SDK**: field filled with `None` (orchestrator-facing knob; not
exposed in JS options yet).
- **CLI**: `inspect` shows `ExternalRef` only when present; `list`
columns unchanged (nothing empty is rendered).
- **runner**: `WithName(dto.Id)` → `WithExternalRef(dto.Id)`; restart
recovery (`runtime.Get(dto.Id)`) resolves through the external_ref
match.

## Verification

- engine lib tests: 735/735; the new `lookup_box_by_external_ref` test
was verified two-sided (fails with the lookup clause reverted, passes
restored)
- boxlite-c: 55/55
- CLI / Node / Python crates compile; `go vet` clean on `sdks/go` and
`apps/runner/pkg/boxlite` (final cgo link needs the prebuilt
`libboxlite.a`, absent in this worktree)

## Merge order

#743#735#744 → this PR. Self-contained: reverting is closing this
PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants