Repository navigation
feat(box): accept an optional box ID from library callers, and generate one as today when absent - #437
Conversation
|
Assessment: Comment The identity plumbing, the record-version handling, and the mismatch refusal are correct for every case I traced. My one finding is in the inline comment: a malformed Checked and held
Design note, no change requested: a box created before this change, or by a direct The tests that disable each guard in turn, as listed in the commit message, are a strong way to show each guard is load-bearing. |
## Problem
A library caller that names its own runs cannot make Box use that name as the box ID. Box always
generates `box-` and 16 hexadecimal digits on first use. So the caller prints one ID, while the
stored record and every telemetry record carry another. An operator cannot match a run that the
caller printed to the records of its box.
## Solution
- `RunOptions` gets `box_id: Option<String>`. `run` passes it to `BoxRoot::settle_identity`.
- On first use, the box stores the supplied ID instead of a generated one.
- A configured box accepts the same ID, and refuses a different one with
`ConfigError::IdentityMismatch`.
- A malformed ID is refused with `ConfigError::SuppliedIdentity` before the box has an ID.
- `None` generates `box-` and 16 hexadecimal digits, as before.
- `valid_box_identity` accepts a prefix of 1 to 16 `nameable` characters that does not start with
`.` or `-`, then `-` and 16 lowercase hexadecimal digits. `box-` and 16 digits stays valid.
- `MAXIMUM_BOX_NAME` grows from 32 to 33 bytes, so a caller can use the same string as `name` and
as `box_id`.
- `SUPPLIED_IDENTITY_RECORD_VERSION` (34) is the record version of a record whose `box_id` is not
`box-` and 16 digits. An older build refuses such a box by its version. A box with a generated
ID keeps its current record version.
- `Record::parse` checks the identity before it computes the expected version.
Interfaces that move, each approved by the owner before the code was written:
- `RunOptions::box_id`. A caller that names every `RunOptions` field without
`..Default::default()` must add the field.
- The stored `box_id` grammar, and record version 34.
- Telemetry `strands.box.name` carries the supplied ID.
- The `name` limit, 32 to 33 bytes. This widening has no record version of its own: an older
build refuses the configuration first.
The supplied ID grants no authority. Policy does not read the box name, and no path, socket, or
workload variable uses the ID. So the ID is a second spelling of the identity input, and not a
fifth input.
## Tests
- `record::layout`: `a_supplied_identity_names_a_new_box_and_survives_reopen`,
`a_supplied_identity_that_differs_from_the_stored_one_is_refused`,
`a_malformed_supplied_identity_is_refused_before_the_box_has_one`, and
`no_supplied_identity_generates_one_as_before`.
- `record::config`: `a_supplied_box_identity_requires_its_own_record_version`.
`a_record_with_an_invalid_box_identity_is_refused` drops `name-<hex>`, which is now valid, and
adds a 17-character prefix and a leading `-`.
- `tests/box_library.rs`: `a_supplied_box_id_names_the_box_and_its_telemetry` runs a real box
through `strands_box::run` on macOS. It checks the startup line, the stored `box_id`, the
`strands.box.name` value in telemetry, a matching rerun, a refused mismatch, and a generated ID
when none is supplied. Its config `name` differs from the ID.
- Each guard was removed once and its test failed: the supplied ID on first use, the mismatch
check, the version branch, the leading-character check, the prefix limit, and the telemetry
label.
- macOS: `cargo test -p strands-box --all-features` passed (1519 passed, 0 failed, 6 ignored, after a rebase onto main).
`cargo clippy -p strands-box --all-targets --all-features` has 0 warnings in `crates/box`.
`cargo fmt -p strands-box --check` passed.
- Not run: Linux (cross-compilation fails in `ring`), and `test-integ/run.sh` on a quiet host.
The end-to-end library test runs on macOS only. Linux runs the unit tests.
26d15fc to
ae571a4
Compare
|
Assessment: Comment (re-review at This push is a rebase onto Checked and held at this head
Optional and outside this PR: |
|
Assessment: Comment (re-review at The malformed-ID finding is fixed. Checked and held at this head
|
|
Assessment: Approve (re-review at This push only changes docs. The root README and the Checked and held: the new docs describe what the code does, and nothing else changed since my last review. |
Description
A library caller can now give a new box its own ID through
RunOptions::box_id. Box stores that ID,prints it, and labels telemetry with it. Without
box_id, Box generatesbox-and 16 hexadecimaldigits as before, so a direct
strands-box rundoes not change.Why. A caller that names its runs, such as a CLI built on the library, prints one ID while Box's
record and telemetry carry another. This makes the two the same.
Rules.
.,_, or-that does not start with.or-, then-and 16 lowercase hexadecimal digits.box-and 16 digits) is stored at record version 34, soan older build refuses it by version.
namegrows from 32 to 33 bytes, so a caller can use one string fornameandbox_id.Interface changes (approved before implementation):
RunOptions::box_id; the storedbox_idgrammar and record version 34;
strands.box.namecarrying the supplied ID; the 33-bytenamelimit. A caller that lists every
RunOptionsfield without..Default::default()must add thefield. The ID grants no authority: policy, paths, sockets, and the workload environment do not use
it, so it is a second spelling of the identity input, not a fifth input.
Not verified by CI here: Linux was not compiled locally. The end-to-end library test runs on
macOS only.
Related Issues
None.
Type of Change
New feature
Testing
cargo test -p strands-box --all-featureson macOS, 1519 passed,0 failed, 6 ignored.
cargo fmt -p strands-box --check, andcargo clippy -p strands-box --all-targets --all-featureswith 0 warnings incrates/box.Each new guard was removed once and its test failed. The commit message names each test.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.