Skip to content

test: retire tests that pin source text - #640

Merged
Mathih13 merged 21 commits into
mainfrom
refactor/retire-text-pin-tests
Oct 10, 2026
Merged

Mathih13 merged 21 commits into
mainfrom
refactor/retire-text-pin-tests

Conversation

@Mathih13

Copy link
Copy Markdown
Contributor

A contributor's first pull request could fail for reasons unrelated to its behaviour. About 250 tests asserted that a function body contains a literal string, and three harnesses pinned a production adapter's source verbatim. A rename or a reformat turned CI red, and the only fix was to re-bless text. Comments also carried review narration, slice and phase labels, and bare work-item numbers that do not resolve.

This is phase 1 of #635. It changes no gameplay behaviour.

Tests

  • Deleted 255 test functions that scanned source text or pinned an adapter's source, in the Module and the Gateway.
  • Kept the Architecture Tests that protect an invariant: Character-owned table coverage, no spatial full scan and no gameplay read of the shard id, the transfer fence chokepoint, the gc reaper's TTL tables, packed grid cells, publish safety, and binding parity. Each failure message names its invariant, and each has a negative test that shows it fires.
  • The shared body scanner moved to lyracore-test-support, so the Module and Gateway no longer carry two copies.
  • The print-macro ban is a CI grep in the fmt job. The panic ban at untrusted-input boundaries is a clippy lint.
  • Wiring facts that a scan used to guard now have durable behaviour tests:
    • operator_gates: every gated reducer in the published schema (225 today) refuses an anonymous caller. A new reducer is covered automatically. This replaces mail_operator.
    • transfer_fence: login refuses a Character in escrow, background passes leave it unchanged, and the Instance reaper holds its Instance.
    • corpse_loot_residue, diminishing_returns, instance_party: corpse-loot purge, diminishing returns only after a placed aura, and solo Instance adoption by a new party.
    • The Gateway provision path has a test through the existing CLI seam.
    • Each new test failed when its guard was removed.

Operations

  • debug_repair_after_publish moved to an ungated operations module. The reducer name and arguments are unchanged, and it still requires the Operator. Production is unchanged, because every publish already builds with debug_reducers.
  • The debug module no longer claims that production publishes leave debug_reducers off.

Comments

  • Removed review narration, "this PR" and "formerly" history, slice and phase labels, and about 200 bare work-item numbers. Comments that carried an invariant now state it in the present tense.
  • Module docs longer than about sixty lines moved to docs/ (for example docs/module-build.md, docs/character-transfer.md, docs/runtime-script-host.md).
  • Spell ids, skill lines, DBC columns and other game data numbers stay.

Local gates: fmt, clippy with -D warnings, the five crate test commands and the wasm check pass. The new durable targets pass locally.

🤖 Generated with Claude Code (Claude Opus 5.5 lead, with Opus 5.5 and Sonnet 5.5 subagents; part of the comment sweep by GPT-6.1 Sol via Codex)

Mathih13 and others added 21 commits October 10, 2026 15:54
…feature

`debug_repair_after_publish` restores seeds and schedules on every published shard, so it now
lives in an ungated `operations` module. The reducer keeps its name and arguments, so the CLI,
scripts and runbooks keep working.

The debug module no longer claims that a production publish leaves `debug_reducers` off: every
publish enables it. The crate root names SpacetimeDB 2.7.1, the pinned version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Delete every Module test that asserted a function body or source file contains, lacks or equals a
literal string, including the verbatim pins of the creature cycle, mail escrow and transfer
production adapters. Behaviour tests in the same files stay. A rename or reformat no longer turns
CI red.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Delete the `include_str!` scans over the Gateway's handler, Store, view, subscription and
`main.rs` sources, and the decoy-defence tests on the `WorldStore` adapter. The Gateway's own
`code_of` copy loses its last caller and goes with them. The shared crate's scan of the Module
and Gateway proficiency call sites goes too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each retained Architecture Test now opens its failure message with the invariant it protects. The
spatial-scan, shard-id, transfer-fence and gc-reap scanners gain a negative test that feeds them a
small violating source. The gc-reap scan ignores comments in `gc.rs`.

Delete the issue-reference ban and the dead-code allowance rule. The print-macro ban becomes a
grep in the `fmt` CI job with the same scope: `module/src` and every `packages/*/src`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…-support

`code_of`, `shape_of` and `body_of` now live in `lyracore_test_support::source_scan`. The
Package API's `package_test` root re-exports `code_of` and `shape_of` from there under the same
names, because official Package tests still call them. The Module keeps only the helpers its
Architecture Tests use.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s with clippy

The logon handshake, the addon and auth-session decoders and the configuration parser deny
`unwrap`, `expect`, `panic!`, `unreachable!`, `todo!` and `unimplemented!` outside tests. This
replaces the source scan of the same four files, and the message is one clippy line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A durable test runs `lyracore-gateway provision` against a standalone with a World Shard and a
distinct Realm-core, then reads `game_account` on both. It replaces the scan of `provision`'s
source and runs in the durable workflow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Remove work-item and review history from source comments. Retain the current Transfer,
Realm authority, private-recipient, and tick contracts, and move long module guides to docs.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Exercise non-operator Mail refusals, Hunter-pet cleanup and retaming, mount reconstruction,
Region assignment tombstones, and aura ID reminting through existing reducer fixtures.
Run the real Gateway executable to prove startup leases, Group Intent consumption,
roster mirroring, Character deletion, and Transfer completion.

The file resolver test now compares the reader result without pinning a function-name string.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Scan existing Package source directories alongside the required Module source root.
Accept only grep's no-match status so violations and read errors both fail the gate.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Exercise the Gateway login and world-port reducers alongside the debug rebuild. Verify durable GM carry fields reach the rebuilt Entity.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Restore the unchanged Transfer Escrow, arrival fence, Instance and addressed-event subscriptions removed while shortening adjacent documentation.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Describe the current schema comparison in a lookup document and keep its test header short.

Co-Authored-By: GPT-6.1 Sol via Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Restore sentences the sweep broke, drop leftover work-item numbers and
slice, stage and phase labels, and state history notes as present-tense
invariants.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…able fixtures

Phase 1 deleted source scans that pinned these facts. Each test now drives the reducers on a
private Standalone.

- operator_gates: every reducer in the published schema, except debug, scheduled, lifecycle
  and claim_operator, refuses an anonymous caller at the Operator gate. It replaces
  mail_operator, which covered the Mail reducers only.
- transfer_fence: login, the timed-quest and rested passes, and the Instance reaper leave a
  Character in Escrow alone.
- corpse_loot_residue, diminishing_returns, instance_party: a kill purges both corpse-loot
  residue tables, a control aura without a free slot leaves diminishing returns unchanged, and
  a solo Instance becomes the party's Instance.

Standalone gains describe() for the schema read.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Remove pre-NNN phrases and parenthesised work-item numbers. Keep spell,
skill line, DBC field, update field and creature ids. No code change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Remove [NNN] tags, 'the NNN contract/gate', 'NNN's' references and
parenthesised work-item numbers. Keep spell, skill line and DBC ids. No
code change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

Code review: Standards and Spec

Reviewed at 67d87c7 against main (merge-base 9088335). The spec is Phase 1 of #635. The two axes are reported separately and are not ranked against each other. Priority: P1 fix before merge, P2 should fix, P3 nit or judgement call.

Standards

Hard violations (documented rules)

  • P1. Test gap. module/tests/operator_gates.rs:15: OPEN_PREFIX = "debug_" exempts every debug_* reducer. That exemption includes debug_repair_after_publish, which this PR moves out of the debug feature and which calls require_operator (module/src/operations.rs:27-28). The new gate test never checks the one production-critical debug-named reducer. Add it to the gated set explicitly, or narrow the exemption.
  • P2. Stale cross-references (CODING_STANDARDS: "Stale explanation is a defect"):
    • module/src/tripwires.rs:1144,1153 and module/src/transfer/mod.rs:1154 point at "the verdict table in transfer/mod.rs's module doc". That doc is now one line, and docs/character-transfer.md has no table.
    • tripwires.rs:1348-1349 quotes transport.rs text that this PR deleted.
    • module/src/test_scan.rs:8-9 describes raw_table_reads but sits above on_comment_line.
    • docs/package-delta-format.md is rustdoc moved over without edits. It opens with a fragment, says "This library" and "The crate", cites the bare ids and script modules, and has five H1 headings. docs/runtime-script-host.md has the same heading problem.
  • P2. Glossary Avoid words in new prose (AGENTS.md "Words", CONTEXT.md Shard: avoid "database" when it means a Shard):
    • docs/character-transfer.md: "same-database Transfer", "Across databases".
    • docs/realm-loot-routing.md: "another database", "only one database votes".
    • tripwires.rs:1290: "cross-database".
    • docs/actor-verbs.md: "rejected" for a Refusal.
  • P3. Unslop. Em dashes stay in rewritten lines, for example operations.rs:246. The "ratchet" metaphor stays at tripwires.rs:1145.

Judgement calls (smells)

  • P3. Possible Duplicated Code:
    • instance_of appears in both module/tests/instance_party.rs:53 and transfer_fence.rs:165.
    • The publish → claim_operator → install_guid_range setup repeats in transfer_fence.rs, mount.rs and item_guids.rs, although module/tests/support/mod.rs exists.
    • The quote-tracking loop appears in both source_scan.rs:29 and test_scan.rs:19.
    • The same 12-line deny(clippy::unwrap_used, …) block is copied into 4 Gateway files.
  • P3. Possible Mysterious Name. In operator_gates.rs:50, open holds the reducers that wrongly let a caller through, and the name clashes with OPEN. ungated would say what it holds.
  • P3. gateway/tests/startup_relays.rs:39 names a parameter probe (an Avoid word). Three new test names each join two behaviours (CODING_STANDARDS: one test covers one behaviour), for example tame_dismiss_and_retame_preserve_…_and_clean_live_state.
  • P3. gateway/src/world/trade_tests.rs:180-190 keeps "AC:" labels whose issue is gone.

Spec

Missing or partial

  • P2. "Remove … 'formerly' history, bare work-item numbers". The sweep did not finish:

    If the PR scopes the sweep to Rust on purpose, say so in the description.

  • P2. "Keep the Architecture Tests that protect an invariant". Text pins that are not on the keep list survive:

    • tripwires.rs:1910 core_source_names_no_official_package.
    • publish_safety.rs:423 pins strings in lyracore.
    • publish_safety.rs:661,690 pin scripts/publish-module.sh, which is not in the tree, so both tests skip silently and are dead. Delete them, or make them fail when the file is missing.
  • P3. "include_str! scans over … subscription sources". gateway/tests/schema_parity.rs:1254 still scans connection.rs for SELECT * FROM. It may count as the binding parity guard. If it does, name it that way.

  • P3. module/src/package_test.rs:10 still re-exports code_of/shape_of to Packages, so the text-pinning API stays public. No Package uses it.

Not asked for

  • P3. The clippy panic lint at untrusted-input boundaries (b2e64bc). The spec moved only the print ban. It is reasonable, but it is new scope.
  • Commit 8f775a0 fixes a regression that this PR introduced. The final subscription queries are identical to main, so there is no net change.

Looks done, but wrong

  • P2. "Keep present-tense invariants". Commit d30492a removed the indentation from about 101 chained-method lines in 16 files, for example gateway/src/world/tests.rs:7281-7286 (.lock() / .unwrap() at column 0). Other files include realm_core.rs, connection.rs, party_tests.rs and module/src/group.rs. rustfmt skips these macro bodies, so cargo fmt --check passes and CI will not catch it.

Confirmed done:

  • No code_of(...).contains assertions remain, and the three pins of verbatim adapter source are gone.
  • The issue-reference ban and the dead-code allowance rule are deleted.
  • The print ban is a CI grep that fails closed.
  • Each kept Architecture Test has a negative test.
  • No module doc is longer than 60 lines.
  • The crate-root SpacetimeDB claim matches the pin.
  • The debug-module claims are fixed.
  • debug_repair_after_publish keeps its name, its arguments and its Operator gate.

Summary:

  • Standards: 4 hard findings and 6 judgement calls. Worst: operator_gates exempts debug_repair_after_publish through the debug_ prefix (P1).
  • Spec: 7 findings. Worst: the comment sweep is incomplete, and indentation was stripped from about 101 lines that CI will not flag (P2).

Generated by Claude Code

@Mathih13
Mathih13 merged commit a4ea7c7 into main Oct 10, 2026
9 checks passed
@Mathih13
Mathih13 deleted the refactor/retire-text-pin-tests branch October 11, 2026 18:21
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