Skip to content

docs: record the six-lens review of nostream-relay and nostream-storage - #1335

Merged
chappie-daemon merged 4 commits into
rewrite/mainfrom
factory/045-review-relay-storage
Nov 30, 2026
Merged

chappie-daemon merged 4 commits into
rewrite/mainfrom
factory/045-review-relay-storage

Conversation

@chappie-daemon

@chappie-daemon chappie-daemon commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

Phase 6 row 5 of #868, closing #1299: the six-lens review of nostream-relay and nostream-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 under crates/, src/, resources/, scripts/ or .github/ changes.

The record

  • Reviewed tree: 8488bf13 (base = head; the row adds no source, so every finding is measured on the tree the lenses read).
  • Six lens sections, each with a scope table — one row per file, five cells: the file, its line count, its responsibility, a command run against it and the line it printed, and a line quoted from inside the cited range — plus its findings and what it did not read.
  • 45 findings, each a block with path:line, a one-line severity and the loss, rerunnable evidence (43 command-backed with 43 distinct commands, 2 reading with their basis), the dedupe check, and the disposition.
  • Three defects found twice are six blocks, not three merges. The ux and ui lenses both report the console's fixed metrics failure state (F25, F41) and its permanent Redis fault (F26, F42), and the security lens measured the store-directory rule from the opener side (F21) where the architecture lens measured it from the migration tool (F11). Each block carries its own lens, citation and evidence, and one sentence naming its twin, so a reader can see which lens measured which line.
  • Four surface sections: MCP authentication and authorisation, the settings loader and its precedence, the PG→LMDB migration tool, and LMDB file permissions and directory creation, each with its own command and measured output.
  • ## 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 so scripts/storage-parity.sh cannot 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

count
filed, with evidence in the issue 35 distinct numbers (38 blocks; #1303, #1317 and #1334 are each reported by two lenses)
linked to an issue already open 5 (#1106, #1207, #1210, #1211, #1283)
accepted-risk, with the reason 2 (F15 the unreachable worker branch, F45 one literal colour)

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:line and 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 at recon.md:253-283. Labels rewrite, 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:

  • AC15's evidence assertion, as amended, prints 45 lines over the 45 blocks — 44 evidence absent and one where absent. The amended awk strips 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: the where of the ux storage-count block, whose lens range starts on a blank line (the record cites the first non-blank line and says so).
  • AC9's last assertion fails for two ui blocks: the rewritten ui lens's F2 and F4 name resources/admin/dashboard.html in where: but run their evidence command over dashboard.css and health.rs. The record transcribes both verbatim rather than inventing a command.

Known-baseline notes

  • The open-issue count moved from 147 (at the row's cut) to 182 (at assembly), the difference being this row's own filings. The record states both with their timestamps rather than a count a later reader should expect.
  • The workspace test run's 8 nostream-admin --test query_limits failures are environmental and are not a finding; the record says so where the oracle rule is stated.

@chappie-daemon chappie-daemon added rewrite nostream 4.0 Rust/LMDB rewrite rust Rust implementation work factory Built by the software factory labels Nov 30, 2026
@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 970c128

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@coderabbitai

coderabbitai Bot commented Nov 30, 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ab3cb9e-2a4d-44d8-888b-7542599a8f39

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · This documentation-only update has no blocking findings; the earlier documentation corrections remain non-blocking.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This documentation-only update has no blocking findings; the earlier documentation corrections remain non-blocking.

Findings

  1. P2 Existing migration tests are missed ▶
  2. P2 Finding numbers point elsewhere ▶
  3. P2 Migration accepts these permissions ▶
  4. P2 Existing tests are reported missing ▶
  5. P2 Finding references lead elsewhere ▶
  6. P2 Directory refusal is misstated ▶

Summary

Records the six-lens review of nostream-relay and nostream-storage, with evidence, issue links, and coverage limits.

  • A six-lens review of relay and storage is recorded for later readers.

Reviews (3) · Last reviewed commit: "docs: correct three rotated issue number..." · Reviewed by Greptile

Comment on lines +358 to +365
### 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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!

Comment on lines +817 to +819
| [#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` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

Comment on lines +361 to +365
- 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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!

Comment on lines +817 to +819
| [#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` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 30, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 30, 2026 09:42

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@chappie-daemon
chappie-daemon merged commit 9c25d74 into rewrite/main Nov 30, 2026
18 checks passed
@chappie-daemon
chappie-daemon deleted the factory/045-review-relay-storage branch November 30, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory Built by the software factory rewrite nostream 4.0 Rust/LMDB rewrite rust Rust implementation work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant