Repository navigation
refactor: import asRecord and login from value-coerce - #1787
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR centralizes record coercion and GitHub login extraction in value-coerce, removes duplicate helpers and dependency wiring, and consistently excludes arrays. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this is useful, bounded cleanup that is absent from pinned main. The complete introduced diff reveals no concrete correctness defect. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper reads GitHub metadata to prepare reviews, publish comments, and check whether proposed actions remain safe. These shared helpers turn unknown values into objects and extract GitHub usernames for those consumers. flowchart TD
A[GitHub metadata] --> B[Shared value helpers]
B --> C{Object or array}
C -->|Object| D[Read named fields]
C -->|Array or scalar| E[Empty record]
D --> F[Review and action checks]
E --> F
F --> G[Review context and comments]
Technical reviewBest possible solution: Keep one shared coercion owner while preserving supported GitHub-object behavior and the repair lane’s typed JSON interface. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR addresses duplicate helper ownership rather than a reported user-facing bug. Is this the best way to solve the issue? Yes: direct imports from the existing coercion owner remove redundant implementations and injection seams without adding another abstraction. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8347e8017901. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 9, 2026, 2:02 AM ET / 06:02 UTC. |
What
src/value-coerce.tsownsasRecord(the existingrecordOrEmpty, renamed so that there is one name) andlogin(moved fromclawsweeper-item-policy.ts).asRecordcopies:clawsweeper-item-policy.ts,clawsweeper-review-comments.ts,codex-item-profile.ts,repair/comment-webhook.ts,repair/issue-source-guard.ts. Deleted aliases:recordOrEmpty as asRecord(review-structural-cache.ts) andasJsonObject as asRecord(repair/issue-implementation-intake.ts). Repair code uses its typed JSON ownerasJsonObject, andisJsonObjectnow delegates its runtime check tovalue-coerce.isRecord.asRecordandloginwere pure functions passed through dependency injection. They are removed from every dependency interface andPicklist (15asRecordmembers, 5loginmembers, 4Pickentries), every consumer destructure, all 19 runtime wiring and import lines, and the test/e2e stubs. Callers import fromvalue-coerce.js.test/value-coerce.test.tspins the one behavior choice (below).Behavior choice: the copies differed on arrays.
item-policy/review-commentsreturned an array as-is (cast to a record);codex-item-profile, the repair copies andrecordOrEmptyreturned{}. This PR uses the array-excluding version: a record is not an array. Callers that change are the formeritem-policyconsumers (all DI users) andreview-comments. Every audited call reads named fields (.login,.body,.head…), which areundefinedon an array either way. The only shape-sensitive uses (Object.entries(asRecord(x))inassist.ts, spreads initem-context.ts) receive GitHub objects, never arrays.codex reviewagreed: "Array rejection is intentional, and no actionable regression was found."scheduled-review-noop.tskeeps its own locallogin(it lower-cases and trims, which is a different concept). Other existing import aliases of the oldrecordOrEmpty(record,jsonRecord,objectValue,object) now aliasasRecord. Renaming their call sites is out of scope.Why
SlopHelpers report, finding 1:
asRecord×5 with different array semantics, plus two alias names, andasRecord/logininjected through 15+ dependency types as a seam with nothing to vary.Proof
pnpm run build:all(src, repair, dashboard) andformat:checkare clean after the rebase onto8347e8017(one additive import conflict inrepair/issue-source-guard.ts).primary-body-fixtureusers,pr-surface-stats,pr-review-comment-risk,fixed-sha-pull-resolution,apply-label-sync,apply-source-freshness,apply-guard-read-cache,context,review-planning-locked,review-comment-publication,apply-lease-guards,assist-artifact,oversized-pr-admission,pr-review-history,clawsweeper-action-ledger,repair/gitcrawl-sqlite,related-context,pr-label-policy,review-comment-noise) plus the newvalue-coercetest (2/2).pnpm run checkwas not run on this branch. The sibling branches ran it on the same base and saw only the listed load flakes. CI is the full-suite gate for this PR.src/(main → branch):function asRecord: 5 → 1;function recordOrEmpty: 1 → 0;as asRecordaliases: 2 → 0asRecord: (value: unknown) …dependency members: 15 → 0;login: (value: unknown) …: 5 → 0;"asRecord"/"login"Pickentries: 4 → 0asRecord,/login,lines inclawsweeper-runtime.ts: 19 → 0render-comments.mjswith main dist (552822607) and branch dist over every saved report directory underhandoffs/clawsweeper-review-quality/{prompt-rest,prompt-lean,prompt-dump,async-proof/*,retire-proof/*}and/tmp/rules-slice/*(72 directories, 104.mdfiles): 72/72 byte-identical.Codex review dispositions
codex review --base main: no findings.Merge Danger
recordOrEmpty→asRecordbreaks any open branch that adds a newrecordOrEmptyimport (a compile error, so easy to see). Arrays now coerce to{}for the former item-policy consumers. This PR conflicts with refactor: own stringOrUndefined helpers in value-coerce #1782 (stringOrUndefined) onreview-structural-cache.tsline 1 and on adjacent dependency-member lines, and with refactor: own ISO timestamp helpers in iso-time #1786 (iso-time) on adjacent lines. Whichever lands second rebases.