Skip to content

ref: codebase cleanup sweep — dedup, constant, dead-code#847

Merged
Chemaclass merged 5 commits into
mainfrom
ref/cleanup-sweep-2
Jul 23, 2026
Merged

ref: codebase cleanup sweep — dedup, constant, dead-code#847
Chemaclass merged 5 commits into
mainfrom
ref/cleanup-sweep-2

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

A second multi-agent cleanup sweep across the same eight quality axes as #843. Five axes were already clean (constants mostly, fragile constructs, defensive code, source cycles, comments); four small, provably-safe changes surfaced.

💡 Changes

  • Dedup (DRY): the array/date/duration/json/files/folders assertions now resolve their failure label through the fork-free bashunit::assert::label_to_slot helper instead of a per-call find_test_function_name + normalize command substitution (34 sites, matching assert.sh); and the three byte-identical skipped/incomplete/risky summary renderers collapse into one flush_deferred_block. Net −70 lines, fewer forks, identical output.
  • Constant: the _BASHUNIT_EMPTY_ base64 wire sentinel (hardcoded in 3 encode/decode sites) is centralized into _BASHUNIT_BASE64_EMPTY_SENTINEL in state.sh so the two sides can't drift.
  • Dead code: removed a provider_data array in find_total_tests that carried a shellcheck SC2034 (unused) disable — only the scalar counter is read.
  • Comment: tightened the join_to_slot contract comment (dropped refactor-history narration).

Label resolution is behavior-identical: both the old and new resolvers scan the full FUNCNAME stack for a test_* frame, so the extra helper frame is irrelevant whenever an assertion runs inside a test (always, in practice). Verified: full suite + --parallel --simple --strict (1384 passed), the label-sensitive failure-path tests, make sa, make lint, ./build.sh --verify — all green, run locally without cross-process interference.

https://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED

The "_BASHUNIT_EMPTY_" wire token was hardcoded in three places across two
files: encode_base64 (helpers.sh) emits it and both decode sites
(helpers.sh, runner.sh) recognize it. Extract it into a single constant
next to _BASHUNIT_BASE64_WRAP_FLAG in state.sh so the encode and decode
sides can never drift. No behavior change; the on-wire byte sequence is
unchanged.

Claude-Session: https://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED
Drop the dangling "behave exactly as the previous command-substitution
did" clause (refactor-history narration with no referent in the current
code) while keeping the useful contract: output matches
$(printf '%s\n' "$@") exactly, including trailing-newline stripping.

Claude-Session: https://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED
Route the specialized assertions (arrays, dates, duration, json, files,
folders) and the bashunit::assertion_failed facade through the existing
fork-free bashunit::assert::label_to_slot slot helper instead of
re-deriving the label with a per-call find_test_function_name +
normalize_test_function_name command substitution, matching assert.sh.
Output, custom-label overrides ($2 folders, $3 files) and the derived
default are unchanged; label resolution stays on the failure path.

Collapse the three byte-identical skipped/incomplete/risky summary
renderers into one bashunit::console_results::flush_deferred_block;
each caller keeps its own guard.
The local array carried a shellcheck SC2034 (unused) disable; only the scalar
provider_data_count is read in the counting loop. Leftover from an earlier
provider-counting refactor.

Claude-Session: https://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED
@Chemaclass Chemaclass added the refactoring Refactoring or cleaning related label Jul 22, 2026
@Chemaclass Chemaclass self-assigned this Jul 22, 2026
@Chemaclass
Chemaclass merged commit db47208 into main Jul 23, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the ref/cleanup-sweep-2 branch July 23, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring or cleaning related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant