Skip to content

feat(tools): import transcript-archive as a released command (RIG-11569) - #165

Merged
rigel-nemo[bot] merged 5 commits into
mainfrom
nebula/rig-11569-import-transcript-archive-as-a-released
Nov 23, 2026
Merged

rigel-nemo[bot] merged 5 commits into
mainfrom
nebula/rig-11569-import-transcript-archive-as-a-released

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this do

Import transcript-archive into tools/ as a released command. removeSecret now returns its os.Remove error, so a leftover plaintext restore password or path list fails the command instead of passing silently.

This head also makes the first-run coverage check stream the snapshot once when unverified files span more than one restore batch. Before, each 5000-file batch ran a full restic pass.

Why do we need it

Hosts compile nothing, so the archive tool must ship as a nebula Release asset.

Summary

  • --config is required on inventory and pass, with no default. The schema is embedded from internal/config/schema.cue.
  • --escrow-recipient is required, so no operator key is built in.
  • flake.nix: one goCommands line, restic in checkTools, and a transcript-archive devShell with restic.
  • moon.yml: test runs in the transcript-archive devShell.
  • removeSecret returns the remove error; Get joins it into its result.
  • runStateCoverage streams when unverified files exceed one restore batch, or when most bytes are unverified.

Verification

Off-box on macpro2013, from git archive, in tools/transcript-archive, with no -timeout flag (default 10m). The full suite (nix develop ../..#transcript-archive --command env CGO_ENABLED=0 go test -count=1 -v ./...) was last run on an identical tree before the final restack: 182 PASS, 0 FAIL, 1 SKIP, 9 packages ok.

  • TestPassFirstRunManyPendingBoundedJournal at b8aca288aa3718626eb92173cde049375f89e1a7: 24.5s to 37.8s over three isolated runs. Before this round, it hit the 10m timeout.
  • TestCoverageStateDirIncremental: passes.
  • TestRemoveSecretReturnsRemoveError: fails on the pre-fix removeSecret and passes on this head.

Risks

Callers must now pass --config and --escrow-recipient. Tests need restic on PATH.

Spec impact

None.

Spec-impact: none

Checks skipped: nebula has no pre-push hook config; GitHub Actions ci.yaml runs its checks

Refs RIG-11569

Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Nov 21, 2026

Copy link
Copy Markdown

RIG-11569

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Review round 1 at bfbdee6: 1 high, 1 medium, 2 low

  • H1: moon test runs in the devShell, which has no restic. CI goes red and CD holds the project, so it would never be released. Action: add a transcript-archive devShell of basePackages ++ [ pkgs.restic ], following the jj-hooks pattern.
  • M2: The required-flag tests would still pass if the defaults came back: the recipient is invalid, and the inventory test only checks for a non-nil error. Action: use a generated recipient, and assert the required-flag error and an empty DefValue.
  • L3: The real per-host layout checks now live nowhere. Accepted: they stay private, next to the real config.
  • L4: Leftover "R2" wording in the pass.go help and the coverage_restic.go comment. Action: say "S3".

A fix is dispatched.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Review round 2 at 6478229: 1 high, 1 medium

  • H1: CI runs moon ci in the default shell, which has no restic, and TestGetRoundTripAndArgv fails there (reproduced off-box). The devShell fixes only CD. Action: make the test task run nix develop ../..#transcript-archive --command go test ./..., following tools/jj-hooks, and keep CGO_ENABLED=0 and cache: false.
  • M2 (inventory): TestInventoryRequiresConfig survives two mutations: a non-empty default, and dropping the empty check. Action: assert the inventory requires prefix and pin DefValue == "".

Fixed: M2 for pass (five mutations caught) and L4. gofmt, vet, tests and the nix build pass off-box in the tool shell. The red CI checks come from the tailnet secret and the main-wide ref-gate failure, not from this diff.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at 794d6f2
Base: main

All-clear at 794d6f2

Round 3: no findings. H1 and M2 are fixed. .#default has no restic, and nix develop .#default --command moon run transcript-archive:test passes all 9 packages, so the task now opens its own restic shell. Both inventory mutations are caught. Only moon.yml and inventory_test.go changed since round 2. gofmt and vet are clean.

@rigel-mintaka rigel-mintaka added the review-before-ready PR touches secrets or auth paths; review on the draft head before ready label Nov 21, 2026
@rigel-mintaka
rigel-mintaka marked this pull request as draft November 21, 2026 10:57
@rigel-mintaka
rigel-mintaka force-pushed the nebula/rig-11569-import-transcript-archive-as-a-released branch from 794d6f2 to 4a8c7d5 Compare November 21, 2026 10:58
@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Updating: rebased onto main at 4a8c7d5. The flake.nix devShell conflict with host-bao-seal from #172 is resolved by keeping both shells. The PR now carries review-before-ready, because it handles the restic password and S3 credentials. It stays draft until an all-clear names this head.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at 4a8c7d5
Base: main

All-clear at 4a8c7d5

Rebase and secret-handling review: no findings.

  • Since 794d6f29, the only change is the flake.nix devShell resolution, which keeps both the host-bao-seal and transcript-archive shells.
  • Secrets never reach logs, errors, argv or temp files. Restic stderr is discarded, and errors carry status only.
  • Escrow encrypts to the given age recipient only.
  • Secret files are 0600 and their directories 0700.
  • restic gets --password-file, and RESTIC_* variables are filtered out. Two tests check that the child's argv and environment never contain the password.
  • Tests use generated or placeholder secrets only.
  • Off-box: gofmt, vet, and nix develop .#default --command moon run transcript-archive:test (all 9 packages ok) pass.

@rigel-mintaka
rigel-mintaka marked this pull request as ready for review November 21, 2026 11:04
@rigel-nemo

rigel-nemo Bot commented Nov 21, 2026

Copy link
Copy Markdown

Hold: Architect read pending. This PR handles the restic repository password, its escrow encryption, and S3 credentials. Nemo is holding the merge until the Architect has read it. The Architect lifts this with a Hold lifted: comment.

@rigel-nemo

rigel-nemo Bot commented Nov 21, 2026

Copy link
Copy Markdown

Hold lifted: Architect read the diff at 4a8c7d5. The restic password reaches restic only through a 0600 --password-file. RESTIC_* is stripped from the child env, and restic stderr is discarded. No AWS values reach errors. Temp files are 0600 and removed. One Medium for a fix-forward, not a blocker: removeSecret (internal/retrieve/get.go:343) drops the os.Remove error, so a leftover plaintext restore password would pass silently. Merging.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Rebased onto main and resolved the flake.nix conflicts. New head: 63f5094.

Changes since 4a8c7d5:

  • Rebase only: main's rjc block is kept, and transcript-archive is added after it. The restic password path is byte-identical before and after.
  • removeSecret now returns its os.Remove error. Get joins it into its result through each deferred cleanup. The error names only the operation and the path.
  • New test TestRemoveSecretReturnsRemoveError fails on the old code and asserts the error string does not contain the secret.

Checks, run off-box with flake.lock pinned: go test ./... in tools/transcript-archive gives 182 PASS, 0 FAIL, 1 SKIP, 9 packages ok.

This head changed a sensitive path after the last all-clear, so it needs review before merge.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Review round at 63f5094b11269b3025c4340cabad916e510c03b6: 0 high, 2 medium, 2 low. No all-clear. The fixes go in this PR.

  • M1 runStateCoverage (coverage_state.go) chooses batched restore over streaming when there are many small unverified files. Each 5000-file batch scans every node: 12 batches of about 14.5s in the 60k test. A first run over 200k files would take about 27 minutes on a real host. Fix: also stream when there are more unverified files than one batch: len(unverified) > 0 && (len(unverified) > restoreFiles || 2*unverifiedBytes >= totalBytes). Measured: the test drops from 192.6s to 10.9s, and cmd from 261.8s to 76.9s. Keep the 60k test as the regression test. No -timeout is needed.
  • M2 internal/fence/fence.go: the comment above OMPVersion cites a file that exists only in the private repo. Fix: drop it or reword it by role ("the pinned oh-my-pi fork release").
  • L1 if a timeout is ever kept, it goes in flake.nix checkFlags, not moon.yml. Not needed once M1 is fixed.
  • L2 the body's Verification omits the flags it ran with. Fix: state them.

rigel-mintaka and others added 5 commits November 21, 2026 13:11
Ship transcript-archive as a released command, with no default config, recipient or host values.

- --config and --escrow-recipient are required on inventory and pass. Nothing is defaulted, so a missing flag exits non-zero.
- The CUE schema is embedded with go:embed. The config path is an input, and no archive.cue is imported.
- Tests run against a synthetic testdata/archive.cue (example-host) and throwaway age keys generated per test.
- Bucket, endpoint and secret paths are config or required inputs. Standard S3 and restic environment names are unchanged.
- moon.yml, component.cue, README and the flake goCommands line follow the dl-claim shape. restic is a flake check tool for the tests.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
removeSecret dropped os.Remove errors. A leftover plaintext restore
password or path list could pass silently. It now returns the error,
and the three deferred callers join it into the function result.

The error names only the operation and the path. It never carries file
contents, and not-exist is still treated as success.

Refs RIG-11569

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…atch (RIG-11569)

Restore batches cap at 5000 files, and each batch runs a restic pass over
every snapshot node. A first run with many small unverified files paid one
full pass per batch, so it took minutes on a large tree. Stream the digests
when the unverified files exceed one batch, as well as when most bytes are
unverified. The 60k-file regression test keeps its bounded-journal check.

Reword the OMPVersion comment to name the pinned fork release by role,
not by a file that exists only in the private repo.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Updating: round-1 fixes pushed at b8aca28; review round 2 running before Ready (review-before-ready).

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear at b8aca28
Base: main

All-clear at b8aca28

Review round 2 found 0 high, 0 medium and 3 low.

  • M1: fixed. Coverage streams when more than restoreFiles files are unverified, or when they are at least half the bytes. The 60k test now takes 24.5s to 37.8s on macpro2013; before this round it hit the 10m timeout.
  • M2: fixed. No private path is left.
  • L1: fixed.
  • L2 / L-A: fixed in the body. Verification now names this head and its timings.
  • L-B, not gating: in a steady state with more than 5,000 changed small files, the run streams the whole snapshot where two restore passes would cost less. That only affects cost, not correctness.
  • L-C, not gating: the OMPVersion comment should name forks/oh-my-pi/.github/rigel-version.

L-B and L-C wait for the next change to this tool.

@rigel-mintaka
rigel-mintaka marked this pull request as ready for review November 21, 2026 18:23
@rigel-nemo

rigel-nemo Bot commented Nov 23, 2026

Copy link
Copy Markdown

Checks read:

@rigel-nemo
rigel-nemo Bot merged commit a266d97 into main Nov 23, 2026
6 of 10 checks passed
@rigel-nemo
rigel-nemo Bot deleted the nebula/rig-11569-import-transcript-archive-as-a-released branch November 23, 2026 14:58

This branch had an error being deployed

1 failed deployment
ci — b8aca288 Deployed Nov 21, 2026 by rigel-mintaka via CI (x86_64-linux) #973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-before-ready PR touches secrets or auth paths; review on the draft head before ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant