Skip to content

refactor: own stringOrUndefined helpers in value-coerce - #1782

Merged
obviyus merged 1 commit into
mainfrom
slop-string-or-undefined
Oct 9, 2026
Merged

obviyus merged 1 commit into
mainfrom
slop-string-or-undefined

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

  • src/value-coerce.ts now owns two string helpers:
    • stringOrUndefined(value): the string, or undefined when the value is not a string.
    • nonBlankStringOrUndefined(value): the string, unchanged, when it has non-whitespace text; else undefined.
  • Every former dependency-injected caller (the runtime copy) now imports nonBlankStringOrUndefined. review-structural-cache.ts imports the plain stringOrUndefined and drops its local copy. Behavior stays the same at every call site.
  • stringOrUndefined is removed from every dependency interface and Pick list (6 *-dependencies.ts files, the apply-source-freshness Pick, and 6 local create* dependency types), every consumer destructure, all 12 wiring lines in clawsweeper-runtime.ts, and the runtime local definition.
  • Test and e2e stubs that supplied stringOrUndefined are removed. test/primary-body-fixture.ts imports the plain helper from dist/value-coerce.js for its pullHeadShaFromContext stub.

Naming: the maintainer plan suggested trimmedStringOrUndefined for the runtime variant. That helper does not trim its result. It only rejects blank strings and returns the value as it is (callers such as ?.trim().toLowerCase() still trim themselves). trimmedStringOrUndefined would suggest a trimmed return value, so this PR uses nonBlankStringOrUndefined.

Why

SlopHelpers report, finding 1: stringOrUndefined had two definitions with different behavior. clawsweeper-runtime.ts returned undefined for " ", and review-structural-cache.ts returned " ". The runtime one was a pure function that went through 13 dependency types and 12 runtime wiring lines, so it was a seam with nothing to vary. One owner, with an explicit name for each behavior, removes the divergence and the plumbing.

Proof

  • pnpm run check: static checks, build:all, lint, and changed-coverage passed. Full coverage run: 6947 pass, 1 fail. The failure was test/repair/command-proof-consumer.test.ts "compiled Telegram consumer …", which hit its 180 s timeout under full-suite load. Alone on this branch it passes in 15 s. It is repair-lane code with no stringOrUndefined reference.
  • Focused: 291/291 pass across the 11 edited test files. node scripts/e2e/review-pinned-base.mjs passes both scenarios. scripts/e2e/ci-comment-read-budget.mjs runs inside test/context.test.ts and passes.
  • Grep counts (main → branch):
    • stringOrUndefined-family definitions in src/test/scripts: 3 (2 divergent in src + 1 test copy) → 2, both in value-coerce.ts (plain + nonBlank variant)
    • dependency type members (stringOrUndefined: (value: unknown) … plus | "stringOrUndefined"): 13 → 0
    • runtime wiring ( stringOrUndefined, in clawsweeper-runtime.ts): 12 → 0
    • consumer destructures: 14 → 0
    • test/e2e stubs: 22 → 0
    • \bstringOrUndefined\b tokens in src: 168 → 36 (all in review-structural-cache.ts and value-coerce.ts)
  • Render parity: render-comments.mjs with main dist (552822607) and branch dist over 21 saved real reports in 16 directories (prompt-rest, prompt-lean, prompt-dump and their codex/ subdirectories, async-proof/{base,branch}, retire-proof/166090, and /tmp/rules-slice/{reports,reports-leased,run-144991,run-144991/codex,run-167362,run-167362/codex,run-167362/codex/proof-scratch/167362}). All 16 outputs are byte-identical (same sha256), with 0 render failures.
  • Diff: 38 files, +132 / −156.

Codex review dispositions

codex review --base main: no findings. Codex reported that the shared helpers keep both original behaviors and that callers and interfaces are consistent.

Merge Danger

  • Door: two-way. This is a pure refactor with no prompt, policy, schema, or persisted-format change. A revert restores the old wiring.
  • Blast radius: low. Each runtime caller still gets the same non-blank behavior, and the structural cache still gets the plain behavior. Tests and stubs that used the plain variant now run the real non-blank helper, and all pass. The docs/proof/*/run-proof.mjs scripts still pass a stringOrUndefined stub. They are frozen proof records, so they are not changed. The extra property has no effect. Parallel PRs that edit the same dependency interfaces or clawsweeper-runtime.ts can get one-line, adjacent-line conflicts.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR consolidates two string-validation helpers in the shared value-coercion module and removes their dependency-injection wiring.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The extraction is consistent and useful, with confidence limited by harness-based validation and unverified production-entry-point parity.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: Removing injection plumbing for deterministic helpers reduces maintenance cost. The change follows the established shared-helper direction and preserves both intentional whitespace contracts.

Merge readiness

✅ Ready for maintainer review

Keep open: this useful, behavior-preserving cleanup remains absent from current main. No actionable patch defect was found.

Priority: P3
Reviewed head: 2cec5fd5882ecee05a28bf674bab515c1645a7d0

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Current-head review preparation and comment rendering through the shipped entry point are not established by the supplied factory-harness results and saved-report parity claim.
Agent review details

How this fits together

ClawSweeper interprets GitHub metadata while preparing reviews, checking freshness, and publishing results. These helpers preserve the different whitespace rules used by runtime processing and the review cache.

flowchart TD
  A[GitHub metadata] --> B[Shared string helpers]
  B --> C[Runtime rejects blank strings]
  B --> D[Review cache accepts any string]
  C --> E[Review preparation and freshness checks]
  D --> F[Cache identity]
  E --> G[Review results]
  F --> G
Loading

Technical review

Best possible solution:

Keep one shared implementation for each distinct string contract while preserving every consumer's existing whitespace behavior.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes a refactor rather than repairing a reported runtime failure.

Is this the best way to solve the issue?

Yes: direct imports from the established shared owner remove redundant wiring while preserving both distinct contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cf34fa9269dc.

Provenance checked

  • src/clawsweeper-runtime.ts and former injected string-helper consumers keeps the original intent (refactor: simplify sweep runtime and recover publication backlog #1012: Separate runtime responsibilities into focused modules while preserving conservative review and apply guards.)
  • src/review-structural-cache.ts plain string helper keeps the original intent (a3518a1: Add structural hydration caching; no separate reason for the helper's whitespace handling is stated.)
  • src/value-coerce.ts shared ownership keeps the original intent (refactor(core): consolidate coercion, hashing, and env readers #1391: Consolidate matching coercion contracts while preserving accepted inputs, fallback values, whitespace handling, and error messages.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c75901a adds src/value-coerce.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c75901a57a96; files: src/value-coerce.ts)

Review metrics

Metric Value Why it matters
Code footprint production +130/-147; tests and e2e +1/-25 The extraction reduces production code and removes redundant fixture wiring.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal cleanup that preserves existing runtime and cache behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-09T05:25:28.152Z sha da72174 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T06:07:45.771Z sha 97f43d0 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T06:26:45.826Z sha 7db6ecd :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 2:45 AM ET / 06:45 UTC (Revision 4).

@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@obviyus
obviyus force-pushed the slop-string-or-undefined branch from 5d8f848 to 97f43d0 Compare October 9, 2026 06:04
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@obviyus
obviyus force-pushed the slop-string-or-undefined branch from 97f43d0 to 7db6ecd Compare October 9, 2026 06:24
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@obviyus
obviyus force-pushed the slop-string-or-undefined branch from 7db6ecd to 2cec5fd Compare October 9, 2026 06:42
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 3ef195d into main Oct 9, 2026
13 checks passed
@obviyus
obviyus deleted the slop-string-or-undefined branch October 9, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant