Skip to content

chore(scripts): organize scripts/ by purpose and drop orphan scripts - #847

Merged
huichen merged 6 commits into
mainfrom
chore/scripts-reorg
Sep 25, 2026
Merged

huichen merged 6 commits into
mainfrom
chore/scripts-reorg

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

What

scripts/ had grown to 60+ flat entries mixing desktop packaging, local dev
launchers, release installers, coverage/profiling tools, doc generators and
offline tests — a reader could not tell which script belonged to which
workflow. Group them by purpose:

Directory Contents
build/ desktop packaging that mirrors the CI pipelines
dev/ local dev launchers (desktop + mobile)
release/ installers, signing and upload helpers (lib/ moves with them)
measure/ coverage, profiling and performance measurement
docs/ doc generation and structural checks
tests/ offline regression and native acceptance scripts

ci/, screenshots/, skill_reco/ and compaction_experiment/ keep their
existing directories. version.mjs and npm-install-if-needed.mjs stay at the
scripts/ root: the Makefile and every workflow invoke them from there.

Reference updates

Every reference moved with the files: Makefile, 8 workflow files, the
build.rs / build-info call sites, agent/src/sandbox/windows/integration_tests.rs,
desktop/src-tauri/src/remote_host/sync_measurement.rs, and the current docs.
docs/archives/** and docs/audits/** keep their historical paths on purpose —
they are dated snapshots, not current truth.

Relative path resolution inside the moved scripts was corrected as well
(__file__/parents[N], dirname, PSScriptRoot, ../), including the NSIS
fixtures that now sit next to tests/test-windows-installer-preflight.ps1.

Deletions

13 scripts had no remaining caller anywhere in the repo, the CI workflows or the
docs (verified with a repo-wide git grep for both the file name and every
reference form):

banner.sh, banner-png.py, build-mobile-android.sh,
measure-coldopen-run.py, measure-coldopen.ts, measure-coldopen-report.py,
measure-coldopen.html, measure-encoding-cpu.mjs, measure-live-wire.py,
measure-snapshot-composition.py, measure-stream-vs-snapshot.py,
measure-tauri.sh, reset-ios-simulator-permissions.sh.

docs/banner.png is kept — both READMEs still embed it.

New docs

scripts/README.md + scripts/README.zh-CN.md describe the layout with a
one-line purpose for every script, and are whitelisted in
scripts/docs/check-docs.py.

Verification

  • python scripts/docs/check-docs.py --scope scripts → 0 diagnostics
  • python scripts/tests/test-check-docs.py → 21/21 OK
  • python -X utf8 scripts/docs/check-channel-matrix.py → 13 rows match the code
  • every scripts/... path referenced from Makefile + .github/workflows exists
    (19/19), and no moved path is still referenced outside docs/archives|audits
  • independent verification pass re-derived the mapping, the deletions and the
    relative-path fixes from scratch (git grep, Test-Path, test suites)

Note

Four mobile/docs/*-2026-09-16.md files still live outside docs/ (a
pre-existing check-docs finding) and two of them reference the old
scripts/measure/measure-mobile-performance.mjs / serve-mobile-performance.py
paths; that slice is handled by the follow-up docs-reorg PR.

`scripts/` had grown 60+ flat entries mixing desktop packaging, local dev
launchers, release installers, coverage/profiling tools, doc generators and
offline tests. Group them by purpose so a reader can find the right script
without a full listing:

- build/    desktop packaging that mirrors the CI pipelines
- dev/      local dev launchers (desktop + mobile)
- release/  installers, signing, upload helpers (lib/ moves with them)
- measure/  coverage, profiling and performance measurement
- docs/     doc generation and structural checks
- tests/    offline regression and native acceptance scripts

`scripts/version.mjs` and `scripts/npm-install-if-needed.mjs` stay at the root:
the Makefile and every workflow invoke them from there.

Every reference was updated with the move (Makefile, 8 workflows, the build.rs
and build-info call sites, desktop/mobile package scripts, current docs);
`docs/archives/**` keeps its historical paths by design. Relative path
resolution inside the moved scripts (`__file__`/`parents[N]`, `dirname`,
`PSScriptRoot`, `../`) was corrected, including the fixtures that now sit next
to `test-windows-installer-preflight.ps1`.

Delete 13 scripts with no remaining caller anywhere in the repo or CI:
banner.sh, banner-png.py, build-mobile-android.sh, measure-coldopen-{run.py,
ts, report.py, html}, measure-encoding-cpu.mjs, measure-live-wire.py,
measure-snapshot-composition.py, measure-stream-vs-snapshot.py,
measure-tauri.sh and reset-ios-simulator-permissions.sh (docs/banner.png is
kept — the READMEs still reference it).

Add scripts/README.md + scripts/README.zh-CN.md documenting the layout, and
whitelist them in the docs checker.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 17:30
@huichen
huichen merged commit a9516ab into main Sep 25, 2026
13 checks passed
@huichen
huichen deleted the chore/scripts-reorg branch September 25, 2026 17:55
huichen added a commit that referenced this pull request Sep 25, 2026
* test(remote): measure the lean lane as received, over real E2EE

The existing lane tests count bytes at the FakeNats tap while the state runs
Transport::legacy_fixture(), i.e. plaintext before encryption. Add a harness
that wires the production v2 path instead — one secure::Transport shared by the
command loop and the event drain (build_transport), a phone-side Channel from
the real secure_pair handshake, and a subscription whose messages are counted
on receipt and again after Channel::open. Every record is asserted to be a
sealed one (FRE2 prefix, wire == plaintext + HEADER + TAG).

It measures both declaration states over the same journal (live lane) and both
get_session_entries shapes (full and before-paged), asserting the undeclared
state is byte-identical to the source and that withdrawing the declaration
restores it. The ignored measure_real_e2ee_bytes test replays a real run dump
supplied by scripts/verify-e2e-bytes.py (read-only agent.db + grpcurl dump of
the real history page, protojson int64 strings converted back to numbers).

* chore(scripts): file the E2EE measurement under scripts/measure/

`scripts/` was reorganized by #847 while this branch was open, and it settled on
`scripts/measure/` for measurement scripts. Moving this one there is more than a
path change: the script located the repo root with `parents[1]`, which was
correct at `scripts/` and points at `scripts/` itself one level deeper. It now
matches the two siblings already in that directory (`parents[2]`), verified by
resolving the path and by `--help`.

The doc comments and the test's `#[ignore]` reason were updated with it.
huichen added a commit that referenced this pull request Sep 25, 2026
…856)

* test(remote): rerun the lean-lane measurement on a real nats-server

The received-bytes harness ran on an in-process FakeNats: real E2EE, real
bridge, real client — but not a real broker process. Give the harness a
Broker choice and rerun the same measurement through `nats-server` on a
loopback port, so the numbers are witnessed by the server that production
would use.

Subscriptions are now synchronised with a publish/subscribe echo instead of
Client::flush(): flush only proves the bytes left this process, while the
server handles one connection's commands in order, so the echo of a publish
sent after the SUB proves registration. Without that, a publish could
overtake the SUB and be dropped (reproduced: ~1 fixture run in 5 stalled on
its first message).

When the script passes VERIFY_E2E_NATS_MONITOR, the test also snapshots the
server's own /connz counters for the phone connection before and after the
measured traffic and asserts the window delta equals what the harness
received and decrypted — a broker-side witness for every payload byte.

scripts/measure/verify-e2e-bytes.py (the post-#847 location) starts the
server, prints its version and launch command, runs both brokers and
compares the decoded results. It now also fails on a non-zero test exit
code: a panic after the result markers were printed looked like a pass.

* test(remote): exclude the harness's own probe from broker accounting

The real-broker accounting compared the server's `/connz` delta for the phone
connection against what the harness received and decrypted, and asserted they
were equal. They are not, and my reruns failed deterministically by exactly
32 bytes and 2 messages:

    left: 72696018 (server out_bytes)   right: 72695986 (decrypted)
    left:  176880 (server out_msgs)     right:  176878 (received)

The cause is this harness's own subscription-readiness probe, not the
transport: `await_subscription` subscribes to `{pattern}.verify-sub-probe` on
the **phone** connection and publishes `"verify-sub-probe"` (16 bytes) to it,
and `replay_live_lane` runs twice per measurement. That is 2 messages and
2 x 16 = 32 bytes the server counts and the harness does not.

Rather than loosen the assertion to a tolerance — which would stop it
catching the thing it exists to catch — the probe now reports its payload size
and the accounting subtracts it, so the comparison stays an **exact**
equality. Per-message framing or header inflation would still fail it.

The measurement itself is unaffected and reproduces: real broker and the
in-process fake agree byte-for-byte (`liveEqual: true, historyEqual: true`),
and the real-broker fixture numbers are identical to the fake's.
huichen added a commit that referenced this pull request Sep 25, 2026
#847 moved the measurement scripts into `scripts/measure/` and updated the
call sites it knew about, but three references still named the old paths, so
copying a command out of them fails with `No such file`:

- `desktop/src-tauri/src/remote/verify_e2e.rs` (doc)
- `scripts/measure/verify-e2e-bytes.py` (docstring)
- `packages/rpc/tests/measure_usage_run_nulls.rs` (doc)

Found by the independent review (it also flagged the two artifact mentions;
those are historical records and stay as written).
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.

1 participant