Repository navigation
refactor: own ISO timestamp helpers in iso-time - #1786
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 changesThe branch consolidates timestamp parsing, validation, and age checks in one shared module and replaces duplicated helpers and dependency wiring with direct imports. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this is useful maintenance absent from current main, and the inspected patch introduces no concrete defect. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper reads timestamps from GitHub activity and saved reviews to determine freshness, cleanup eligibility, and status ordering. The shared helpers convert and validate those timestamps for the existing policies. flowchart TD
A[GitHub activity and saved reviews] --> B[Shared timestamp helpers]
B --> C[Parse timestamp instant]
B --> D[Validate UTC or offset format]
C --> E[Existing age and freshness policies]
D --> E
E --> F[Review eligibility and ordered status output]
Technical reviewBest possible solution: Keep one timestamp owner with explicit UTC and offset contracts while preserving the distinct ledger and webhook parsing rules. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a refactor, and source comparison supports preservation of existing timestamp formats and production age thresholds. Is this the best way to solve the issue? Yes: direct imports from one shared owner remove duplication while retaining the distinct persisted-format contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 405764da3257. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes: No label changes. Label justifications:
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 HistoryReviewed October 9, 2026, 2:24 AM ET / 06:24 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What
src/iso-time.tsowns timestamp parsing and age checks:parseIsoMs(value): epoch milliseconds, ornullwhen the value is empty or not a date. This is the oldtimestampMs, under the name the maintainer plan asked for.isIsoTimestamp(value, { allowOffset }): ISO date-time grammar check plusDate.parse.allowOffset: falseis theZ-only grammar;allowOffset: truealso accepts±HH:MM.isOlderThanMs/isOlderThanDays: theclawsweeper-item-policy.tsbehavior (a value that is not a date is never old; a zero or negative age is always old).timestampMs×3 (clawsweeper-review-planning-dashboard.ts,review-structural-cache.ts,scheduler-policy.ts),isOlderThanDays×2 (clawsweeper-item-policy.ts,repair/comment-router-core.ts), and the ISO regexes inclawsweeper-close-decision.ts(offset grammar),clawsweeper-regression-provenance.tsandrepair/sweep-status-merge.ts(Z-only grammar).timestampMsandisOlderThanDayswere pure functions passed through dependency injection. They are removed from every dependency interface andPicklist (apply,apply-guard,report-rendering,report-orchestration,review-comment,record-metadata,label-policy,dashboard,dashboard-audit,review-planning), every consumer destructure, all runtime wiring lines, and the test stubs. Callers import fromiso-time.js.ACTION_EVENT_TIMESTAMP_PATTERN_SOURCEwith calendar and clock range checks, plus its fraction-capturing parser). That grammar is a stricter, persisted-format contract, not a duplicate.dashboard/github-webhook-read-model.tshas a differenttimestampMs(it also accepts numbers and rejects negatives) in the Worker build; it is not changed.Behavior: none at production call sites.
repair/comment-router-core.tsisOlderThanDayshad nodays <= 0branch. All its callers pass positive constants (14, 60, 90), so the shared function gives the same result.Date.parse(String(value ?? ""))andDate.parse(value)give the same result for every input.timestampMscopies were byte-identical toparseIsoMs.timestampMs: () => null/isOlderThanDays: () => true|falsenow run the real helpers. All those tests pass unchanged.Why
SlopHelpers report, finding 6 ("ISO-timestamp validation owned by four modules") and finding 1 (
timestampMs×3 and the pure-function DI lattice). The same parse/age rules were redefined per module, so a fix in one copy did not reach the others.Proof
pnpm run check(before the rebase onto8347e8017): static checks,build:all,lintand changed-coverage passed. Full coverage run: 6947 pass, 1 fail:test/review-git-acquisition.test.ts"Git supervisor kills TERM-resistant descendants within the original deadline", a known git-acquisition load flake. Alone it passes 13/13.clawsweeper-close-decision.tsandscheduler-policy.ts, both additive):build:allandformat:checkare clean, and the focused suites pass (review-comment-publication,apply-source-freshness,apply-label-sync,apply-guard-read-cache,clawsweeper-record-metadata,audit-health-roundtrip,pr-label-policy,close-reasons,regression-provenance*,repair/sweep-status-merge*,scheduler*,review-structural-cache*).src/(main → branch):function timestampMs: 3 → 0;function parseIsoMs: 0 → 1function isOlderThanDays: 2 → 1iso-time.ts)timestampMsdependency members,Pickentries, destructures and wiring: 30 → 0isOlderThanDaysdependency members, destructures and wiring: 11 → 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 outputs byte-identical.Codex review dispositions
codex review --base main: no findings ("The shared timestamp helpers preserve the existing parsing, validation, and age-check behavior. All callers were updated.").Merge Danger
clawsweeper-runtime.ts(stringOrUndefinedrefactor: own stringOrUndefined helpers in value-coerce #1782,asRecord/login,sha256, front-matter helpers) can get one-line adjacent conflicts. Whichever lands second rebases.