Skip to content

refactor: own ISO timestamp helpers in iso-time - #1786

Merged
obviyus merged 1 commit into
mainfrom
slop-iso-time
Oct 9, 2026
Merged

obviyus merged 1 commit into
mainfrom
slop-iso-time

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

  • New src/iso-time.ts owns timestamp parsing and age checks:
    • parseIsoMs(value): epoch milliseconds, or null when the value is empty or not a date. This is the old timestampMs, under the name the maintainer plan asked for.
    • isIsoTimestamp(value, { allowOffset }): ISO date-time grammar check plus Date.parse. allowOffset: false is the Z-only grammar; allowOffset: true also accepts ±HH:MM.
    • isOlderThanMs / isOlderThanDays: the clawsweeper-item-policy.ts behavior (a value that is not a date is never old; a zero or negative age is always old).
  • Deleted copies: 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 in clawsweeper-close-decision.ts (offset grammar), clawsweeper-regression-provenance.ts and repair/sweep-status-merge.ts (Z-only grammar).
  • timestampMs and isOlderThanDays were pure functions passed through dependency injection. They are removed from every dependency interface and Pick list (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 from iso-time.js.
  • Kept as is: the action ledger's strict grammar (ACTION_EVENT_TIMESTAMP_PATTERN_SOURCE with 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.ts has a different timestampMs (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.ts isOlderThanDays had no days <= 0 branch. All its callers pass positive constants (14, 60, 90), so the shared function gives the same result. Date.parse(String(value ?? "")) and Date.parse(value) give the same result for every input.
  • timestampMs copies were byte-identical to parseIsoMs.
  • Test stubs that pinned timestampMs: () => null / isOlderThanDays: () => true|false now 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 onto 8347e8017): static checks, build:all, lint and 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.
  • After the rebase (two import-line conflicts in clawsweeper-close-decision.ts and scheduler-policy.ts, both additive): build:all and format:check are 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*).
  • Grep counts in src/ (main → branch):
    • function timestampMs: 3 → 0; function parseIsoMs: 0 → 1
    • function isOlderThanDays: 2 → 1
    • copies of the simple ISO date-time regex: 3 → 2 (the two named grammars in iso-time.ts)
    • timestampMs dependency members, Pick entries, destructures and wiring: 30 → 0
    • isOlderThanDays dependency members, destructures and wiring: 11 → 0
  • Render parity: render-comments.mjs with main dist (552822607) and branch dist over every saved report directory under handoffs/clawsweeper-review-quality/{prompt-rest,prompt-lean,prompt-dump,async-proof/*,retire-proof/*} and /tmp/rules-slice/* (72 directories, 104 .md files): 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

  • Door: two-way. No prompt, policy-version, schema or persisted-format change. A revert restores the copies.
  • Blast radius: low. Age guards (close policies, stale checks, router trusted close) and cache freshness comparisons use the same arithmetic as before. Parallel PRs that remove other members from the same dependency interfaces or clawsweeper-runtime.ts (stringOrUndefined refactor: own stringOrUndefined helpers in value-coerce #1782, asRecord/login, sha256, front-matter helpers) can get one-line adjacent conflicts. Whichever lands second rebases.

@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

The branch consolidates timestamp parsing, validation, and age checks in one shared module and replaces duplicated helpers and dependency wiring with direct imports.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The consolidation is useful and mechanically consistent, with confidence limited by the supplied runtime evidence.
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: Repeated timestamp rules and pure-function injection wiring create avoidable maintenance drift. The consolidation preserves existing policy outputs and reduces code.

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
Reviewed head: 4372334ea0eaeef9aef53d8262d9aed248440229

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Current-head evidence through the shipped CLI or router exercising age eligibility and activity freshness is absent.
Agent review details

How this fits together

ClawSweeper 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced implementation: The pinned introduced diff preserves the existing parsing expressions, UTC-only and offset grammars, and strict age comparison while removing duplicate implementations and injection wiring. (src/iso-time.ts:3, 4372334ea0ea)
  • Current-main necessity: Live main remains at the supplied target revision, retains the separate scheduler parser, and has no src/iso-time.ts. The ISO-owner search found this PR and the adjacent merged value-coercion work, without a merged replacement for this consolidation. (src/scheduler-policy.ts:69, 405764da3257)
  • Trusted-close compatibility: The router's callers use positive policy thresholds of 14, 60, and 90 days; the shared helper preserves their results for GitHub timestamp inputs. (src/repair/comment-router-core.ts:1396, 4372334ea0ea)
  • Stored contracts and Bay: Sweep-status validation keeps its UTC-only grammar and rejection behavior. Stored fields, serialization, defaults, and migrations are unchanged; the stricter action-ledger grammar and distinct webhook parser remain separate. OpenClaw Bay's data and observer contracts are unaffected. (src/repair/sweep-status-merge.ts:285, 4372334ea0ea)
  • Current-base integration: The test merge's raw parents are exactly the pinned main followed by the reviewed head. Its router patch preserves main's newer command-marker work and introduces only the timestamp-helper import and removal; the substantive edits do not overlap. (src/repair/comment-router-core.ts:41, afdf793315fa)
  • Supplied validation and proof: The fully read current body reports focused suites and byte-identical rendering across saved reports. It provides no current-head shipped-path trace of age eligibility or activity freshness; discussion adds only review requests and automation status. Captured body identity: 28281deb2b4b0100a74b9566fcb0c3fce9f9bf23bf6295e97fb6142f37a302f5. (4372334ea0ea)

Likely related people:

  • Peter Steinberger: Raw commit 4b5246a adds src/clawsweeper-item-policy.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b5246acdf7e; files: src/clawsweeper-item-policy.ts)
  • brokemac79: Raw commit d5fce9f adds src/scheduler-policy.ts:142 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d5fce9fddebb; files: src/scheduler-policy.ts)
  • Vincent Koc: Raw commit a3518a1 adds src/review-structural-cache.ts:787 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a3518a1aa4b9; files: src/review-structural-cache.ts)

Review metrics

Metric Value Why it matters
Production and test LOC Production +117/-148; tests +0/-33 Consolidation reduces production code and removes test stubs without adding a competing implementation.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal maintenance that preserves existing behavior and reduces helper duplication.
  • 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 (2 earlier review cycles)
  • reviewed 2026-10-09T06:02:19.855Z sha 39a8e79 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T06:07:45.138Z sha 331d873 :: needs maintainer review before merge. :: none

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

@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

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