Repository navigation
docs: record the six-lens review of nostream-relay and nostream-storage - #1335
Conversation
🦋 Changeset detectedLatest commit: 970c128 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
[Low impact] This documentation-only update has no blocking findings; the earlier documentation corrections remain non-blocking. Findings
|
| ### F18 the migration's copy and verify loops have no executing test | ||
| - lens: security | ||
| - where: `crates/nostream-cli/src/commands/migrate.rs:153` | ||
| - severity: low — the copy and verify loops have no executing test: migrate_with and verify_with are driven by nothing that runs here and the Postgres replay target is ignored, so a cursor or checksum regression reaches a cutover unmeasured | ||
| - evidence: `grep -n 'pub async fn migrate_with' crates/nostream-cli/src/commands/migrate.rs` → 153:pub async fn migrate_with( | ||
| - dedupe: none — checked against 149 open issues (gh issue list --state open --limit 400 --json number) and the 31 at recon.md:253-283 | ||
| - disposition: filed #1315 | ||
| The fourteen in-file tests cover the target refusals, the pin and the checksum arithmetic (migrate.rs:1245-1700); none drives `migrate_with` or `verify_with`. The one test that replays a batch and folds the checksum is `crates/nostream-storage/tests/migration_pg.rs`, which is `#[ignore]`d and needs PARITY_ADMIN_URL, so it runs in CI's storage job and nowhere a CLI change is developed. Resumability is therefore proven by construction and by a comment (the batch commits first, the manifest is replaced second, every write is a put of the source's key and value), not by a case that kills a run mid-table and resumes it. The security relevance is the cutover: a cursor that skips a batch or a checksum that folds the same row twice is exactly the class the manifest exists to catch, and no test that runs here would fail. #1176 is a different test (the pin swap), so this is filed rather than linked. |
There was a problem hiding this comment.
Existing migration tests are missed
F18 says no test drives migrate_with or verify_with, but crates/nostream-cli/tests/migrate_cli.rs tests both with a constructed source and a real LMDB store, without Postgres. It covers interrupted runs, replay after a batch commit, and changed-row verification. Correct this finding and the migration surface's repeated claim, and reconcile the filed issue with those tests so maintainers do not rebuild coverage that already exists.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| | [#1314](https://github.com/cameri/nostream/issues/1314) | low | security | `crates/nostream-cli/src/commands/migrate.rs:153` | | ||
| | [#1315](https://github.com/cameri/nostream/issues/1315) | low | security | `crates/nostream-mcp/src/credential.rs:273-292` | | ||
| | [#1316](https://github.com/cameri/nostream/issues/1316) | low | security | `crates/nostream-storage/src/lmdb/mod.rs:284-288` | |
There was a problem hiding this comment.
Finding numbers point elsewhere
The table assigns #1314 to migration tests, #1315 to credential ownership, and #1316 to the lock file, but the finding blocks assign those numbers differently. The surface sections also cite F19 for credential ownership and F20 for the lock file, although those subjects are F20 and F17. Reconcile the issue links and finding numbers throughout so readers reach the intended defect.
| - evidence: `sed -n '862p' crates/nostream-cli/src/commands/migrate.rs` → if mode & 0o022 != 0 { | ||
| - dedupe: none — checked against 149 open issues (gh issue list --state open --limit 400 --json number --jq length, 149 at this head where recon measured 147) and the 31 at recon.md:253-283 | ||
| - disposition: filed #1303 | ||
| The rule "a store directory is writable by its owner alone" has two halves in two crates. The owner creates one: `LmdbEnv::open` (`crates/nostream-storage/src/backend.rs:96-119`) makes the directory with `DirBuilder::mode(0o700)` and then opens it. The owner never judges an existing one: `create` is a no-op on a directory that is already there, and no code in `nostream-storage` outside its own tests reads a mode (`permissions()` appears once there, at `lmdb/mod.rs:1478`, inside `mod tests`) — the two `0o022` checks in the workspace are both in `migrate.rs`, at `:862` and `:942`. The migration target therefore refuses `<root>/lmdb` at 0755 (`refuse_unsafe_target_for` tests both `options.target` and `store_path(&options.target)`, `migrate.rs:825`), while `nostreamd` and `nostream-cli export`/`clean-db`/`seed` open the same directory through the same `LmdbEnv::open` and serve it. A store restored from a backup, copied with `cp -r`, created by root under `umask 0`, or simply `chmod`ed is thus in a state the tool that copies rows refuses and the process that serves them accepts; the migration tool's own message ("the target must be a directory only its owner can write to") describes an invariant nothing on the serving path checks. This is the "moved rule with no single owner" shape: the invariant belongs to the crate that owns the store and the files in it (`backend.rs` already owns the create half and the `data.mdb` naming), and it is enforced by one client. Move the mode and ownership judgement for an existing store into a `backend::verify_store_dir` called from `LmdbEnv::open` before `open_with`, so both binaries and the migration target ask the same question; the CLI keeps its ancestry walk and directory pin, which are about the copy's destination and the TOCTOU window rather than the store. |
There was a problem hiding this comment.
Migration accepts these permissions
F11 says migration refuses a caller-owned 0755 store directory, but refuse_unsafe_target_for only rejects group or other write bits with mode & 0o022 != 0. 0755 has neither bit and passes that check. Use a group- or world-writable example such as 0777, which the next paragraph already measures, so operators get the right explanation of which permissions migration accepts.
| - severity: low — the copy and verify loops have no executing test: migrate_with and verify_with are driven by nothing that runs here and the Postgres replay target is ignored, so a cursor or checksum regression reaches a cutover unmeasured | ||
| - evidence: `grep -n 'pub async fn migrate_with' crates/nostream-cli/src/commands/migrate.rs` → 153:pub async fn migrate_with( | ||
| - dedupe: none — checked against 149 open issues (gh issue list --state open --limit 400 --json number) and the 31 at recon.md:253-283 | ||
| - disposition: filed #1315 | ||
| The fourteen in-file tests cover the target refusals, the pin and the checksum arithmetic (migrate.rs:1245-1700); none drives `migrate_with` or `verify_with`. The one test that replays a batch and folds the checksum is `crates/nostream-storage/tests/migration_pg.rs`, which is `#[ignore]`d and needs PARITY_ADMIN_URL, so it runs in CI's storage job and nowhere a CLI change is developed. Resumability is therefore proven by construction and by a comment (the batch commits first, the manifest is replaced second, every write is a put of the source's key and value), not by a case that kills a run mid-table and resumes it. The security relevance is the cutover: a cursor that skips a batch or a checksum that folds the same row twice is exactly the class the manifest exists to catch, and no test that runs here would fail. #1176 is a different test (the pin swap), so this is filed rather than linked. |
There was a problem hiding this comment.
Existing tests are reported missing
F18 says no test drives migrate_with or verify_with, but crates/nostream-cli/tests/migrate_cli.rs already tests copying, interrupted runs, verification, and replay after a batch commits before its manifest is saved. These tests use a constructed source and real LMDB without Postgres. Correct this finding and its repeated claim in the migration surface so maintainers do not duplicate existing coverage.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| | [#1314](https://github.com/cameri/nostream/issues/1314) | low | security | `crates/nostream-cli/src/commands/migrate.rs:153` | | ||
| | [#1315](https://github.com/cameri/nostream/issues/1315) | low | security | `crates/nostream-mcp/src/credential.rs:273-292` | | ||
| | [#1316](https://github.com/cameri/nostream/issues/1316) | low | security | `crates/nostream-storage/src/lmdb/mod.rs:284-288` | |
There was a problem hiding this comment.
Finding references lead elsewhere
The issue table assigns #1314, #1315, and #1316 to different defects than the finding blocks do. F17 assigns #1314 to search-index.lock, while this table assigns it to migration tests. The surface sections also use stale finding numbers: the MCP owner check points to F19 instead of F20, and LMDB lock permissions point to F20 instead of F17. Reconcile the issue assignments and finding references throughout the record so readers reach the right evidence and tracker.
| - evidence: `sed -n '862p' crates/nostream-cli/src/commands/migrate.rs` → if mode & 0o022 != 0 { | ||
| - dedupe: none — checked against 149 open issues (gh issue list --state open --limit 400 --json number --jq length, 149 at this head where recon measured 147) and the 31 at recon.md:253-283 | ||
| - disposition: filed #1303 | ||
| The rule "a store directory is writable by its owner alone" has two halves in two crates. The owner creates one: `LmdbEnv::open` (`crates/nostream-storage/src/backend.rs:96-119`) makes the directory with `DirBuilder::mode(0o700)` and then opens it. The owner never judges an existing one: `create` is a no-op on a directory that is already there, and no code in `nostream-storage` outside its own tests reads a mode (`permissions()` appears once there, at `lmdb/mod.rs:1478`, inside `mod tests`) — the two `0o022` checks in the workspace are both in `migrate.rs`, at `:862` and `:942`. The migration target therefore refuses `<root>/lmdb` at 0755 (`refuse_unsafe_target_for` tests both `options.target` and `store_path(&options.target)`, `migrate.rs:825`), while `nostreamd` and `nostream-cli export`/`clean-db`/`seed` open the same directory through the same `LmdbEnv::open` and serve it. A store restored from a backup, copied with `cp -r`, created by root under `umask 0`, or simply `chmod`ed is thus in a state the tool that copies rows refuses and the process that serves them accepts; the migration tool's own message ("the target must be a directory only its owner can write to") describes an invariant nothing on the serving path checks. This is the "moved rule with no single owner" shape: the invariant belongs to the crate that owns the store and the files in it (`backend.rs` already owns the create half and the `data.mdb` naming), and it is enforced by one client. Move the mode and ownership judgement for an existing store into a `backend::verify_store_dir` called from `LmdbEnv::open` before `open_with`, so both binaries and the migration target ask the same question; the CLI keeps its ancestry walk and directory pin, which are about the copy's destination and the TOCTOU window rather than the store. |
There was a problem hiding this comment.
Directory refusal is misstated
F11 says the migration tool refuses an existing directory at 0755, but the cited check only rejects group or other write bits: 0755 & 0o022 is zero. A directory owned by the caller at 0755 can pass this check. Use 0775 or 0777 for the claimed write-permission disagreement, and distinguish that from the stricter 0700 mode used when creating directories.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
What this is
Phase 6 row 5 of #868, closing #1299: the six-lens review of
nostream-relayandnostream-storage, written as a durable record and a set of issues, with nothing fixed.The record is
docs/rewrite/reviews/2026-11-30-relay-storage.md(884 lines), plus one empty changeset. No file undercrates/,src/,resources/,scripts/or.github/changes.The record
8488bf13(base = head; the row adds no source, so every finding is measured on the tree the lenses read).path:line, a one-line severity and the loss, rerunnable evidence (43 command-backed with 43 distinct commands, 2readingwith their basis), the dedupe check, and the disposition.## Not covered: the 6 of 68 source files no lens read with the reason for each, and every gap this sandbox cannot close (no Docker soscripts/storage-parity.shcannot run; the 9 ignored Postgres/TLS tests; the TLS leg no workflow runs, The storage parity TLS leg is the only ignored test no workflow runs #1201; no live Postgres arm; no benchmark run; no browser).Dispositions
Nine of the 35 were filed by the lenses during the round (#1300–#1308) and each was amended by this assembly to carry the record's path, a
path:lineand its milestone; 26 were filed by the assembly (#1309–#1334). Every one was deduped against the open list first:gh issue list --state open --limit 400 --json number,title,body, plus the 31 known defects atrecon.md:253-283. Labelsrewrite,rust,factory,bug, milestone Phase 2, Phase 3 or Phase 6 as the code warrants.Verification
Acceptance criteria AC1–AC16 of the row's spec were each run against this branch;
docs/rewrite/reviews/did not exist at base, so every criterion fails there. The build record in the job folder quotes each command's output.Two assertions do not pass, and neither is reachable from this side:
evidence absentand onewhere absent. The amendedawkstrips every backtick from the document's- evidence:value and greps the lens file raw, and every lens file writes its command inside backticks, so no evidence line of the form AC9 requires can match. The same document under the pre-amendment extraction prints 1 line: thewhereof the ux storage-count block, whose lens range starts on a blank line (the record cites the first non-blank line and says so).resources/admin/dashboard.htmlinwhere:but run their evidence command overdashboard.cssandhealth.rs. The record transcribes both verbatim rather than inventing a command.Known-baseline notes
nostream-admin --test query_limitsfailures are environmental and are not a finding; the record says so where the oracle rule is stated.