Skip to content

refactor(crypto): share SHA-256 identifier helpers - #140887

Merged
steipete merged 2 commits into
mainfrom
steipete/dedup-infra-crypto-0906
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/dedup-infra-crypto-0906

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Transport diagnostics and core identifier labels independently implement SHA-256 hashing and prefix formatting. Their matching logic can drift across package boundaries.

Why This Change Was Made

A dedicated @openclaw/normalization-core/node-crypto subpath owns hexadecimal digests, raw prefixes, and identifier labels. The private logging implementation is removed and its callers migrate together. Existing core, AI utility, and public logging-core exports remain available; no public export is removed or renamed.

The Node-only leaf stays outside the browser root barrel. Raw prefixes retain native slice semantics; labels retain trimming, missing-value output, length clamping, and the public logging function's single read of opts.len. Status still hashes its existing trimmed value with an eight-character prefix. File hashing, base64 variants, Retry-After, readers, and CJK budgeting remain with their owners. Explicit source mapping lets NodeNext resolve the new subpath before artifacts exist.

User Impact

None intended. Hashes, diagnostic labels, status output, and public logging signatures remain unchanged. No dependency, configuration, schema, persistence, or protocol change.

Evidence

Candidate e3d62154b051e203eb488399baa788c3515c0fe3 is rebased onto main 00f795a62bda4699ecf41252c037635bfa76b54d, including #141238 (5a9ad4d4939996e8e78dd0da608fce03736d3fcc). That main-side change fixes stale rotation fixtures against #139465's documented retry budget; this PR makes no failover-policy or rotation-assertion changes.

  • Focused eleven-file consumer run: 286 tests passed, including all 31 auth-profile rotation tests. The formerly failing long-window case now passes as “rotates auto-pinned profiles on long-window rate limits after transient retries.”
  • Command: node scripts/run-vitest.mjs packages/ai/src/transports/openai-responses-continuation.test.ts packages/ai/src/transports/openai-responses-debug.test.ts src/infra/crypto-digest.test.ts src/agents/auth-profiles/state-observation.test.ts src/agents/embedded-agent-error-observation.test.ts src/agents/embedded-agent-runner/run/failover-observation.test.ts src/agents/workspace-run.test.ts src/commands/status-all/channels.mattermost-token-summary.test.ts src/agents/embedded-agent-runner.run-embedded-agent.auth-profile-rotation.e2e.test.ts src/agents/sessions/session-manager.test.ts src/config/sessions/session-accessor.test.ts.
  • Fresh Codex autoreview: scoped-clean at the requested command's default P0 threshold, zero findings.
  • node scripts/check-changed.mjs: ratchets, formatting, SDK exports/surface budgets, core/test/UI/extension types, unused-export scans and core lint passed. Extension lint preparation then hit the documented nested-worktree limitation: Declaration input escapes checkout through the ancestor node_modules/punycode/package.json. No suppression, baseline or ancestor-install change was made; the required isolated CI/Testbox gates cover that boundary.
  • pnpm build: passed in 5m 27s, including package/SDK declarations, plugins and Dashboard budgets. Startup JavaScript: 349,599 / 350,953 B gzip, 8 / 18 requests.
  • Fresh emitted Node package probe: 24 contract assertions passed. The emitted browser root bundled with 13 compiled inputs, no Node crypto, no external imports and no normalization source fallback. This confirms the Node-only subpath stays outside the browser root.
  • Exact-head CI, attempt 2 passed after one authorized UI timing-flake rerun. Dependency Guard passed after one failed-job rerun following a GitHub contents HTTP 429 and a 180-second backoff.
  • Production TypeScript +35/-56 (net -21); package/source-map wiring +8; test imports +3/-3 with unchanged assertions relative to main. No existing public export is removed or renamed.

The earlier four rotation failures were fixture assumptions on main, not SHA-256 output differences. The blocker is resolved by #141238. No dependency, configuration, persistent-state, or protocol behavior was changed to clear it.

CI retry evidence

UI shard 4/7 passed 302 tests and failed one: chat-stream-runtime-budgets.e2e.test.ts → commits a streamed delta burst in frame-bound transcript batches. At line 517 the measured frame-scheduled share was 8/9 = 0.8888888888888888, below the required 0.9. This PR does not change chat rendering or the budget assertion.

One isolated reproduction on the same source passed with 3/3 frame-scheduled host updates: CI=1 OPENCLAW_UI_E2E_SKIP_REAL_GATEWAY=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-stream-runtime-budgets.e2e.test.ts -t 'commits a streamed delta burst in frame-bound transcript batches' (Node 24.20.0, macOS; one passed, four filtered). That pass does not replace failing Linux CI. No UI code, assertions or budget was changed. The single authorized test rerun passed UI shard 4/7, and the complete CI run is green on this exact head. The earlier Dependency Guard HTTP 429 retry was an infrastructure retry, separate from this test rerun.

@clawsweeper

clawsweeper Bot commented Sep 7, 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.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete force-pushed the steipete/dedup-infra-crypto-0906 branch from 801a9ef to d31dc01 Compare September 7, 2026 05:50
@steipete
steipete marked this pull request as ready for review September 7, 2026 05:51
@steipete
steipete requested a review from a team as a code owner September 7, 2026 05:51
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 10:43 AM ET / 14:43 UTC.

ClawSweeper review

What this changes

The PR consolidates SHA-256 digests and diagnostic identifier labels into a shared Node-only helper while preserving existing public exports and output formatting.

Merge readiness

✅ Ready for maintainer review

The consolidation remains useful and is absent from current main. No actionable introduced defect was found. The earlier validation concern has an evidence-backed disposition; the reported UI CI failure remains a normal landing gate.

Priority: P3
Reviewed head: e3d62154b051e203eb488399baa788c3515c0fe3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with preserved contracts, reported package and consumer validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported emitted-package and browser-bundle probes address the changed packaging boundary; consumer tests are supplemental, and this review did not execute them.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported emitted-package and browser-bundle probes address the changed packaging boundary; consumer tests are supplemental, and this review did not execute them.
Evidence reviewed 8 items Current main still contains the duplicate implementation: Fetched main retains transport-local SHA-256 and identifier-label implementations; inspection also found the separate core logging helper. The consolidation is therefore still distinct work.
Preserved hashing and label contracts: The shared owner retains Node SHA-256 byte handling, native prefix slicing, trimming, missing-value output, finite-length clamping, and a single read of the public logging option. Existing digest tests cover Unicode and arbitrary bytes.
Published logging behavior remains compatible: The latest release's identifier helper uses the same trimming, default length, clamping, and label format retained by this PR. The logging-core public export remains available.
Findings None None.
Security None None.

How this fits together

OpenClaw hashes identifiers for transport diagnostics, agent logs, and credential fingerprints in status output. The shared helper converts strings or bytes into stable hexadecimal digests while existing callers retain their presentation and authorization decisions.

flowchart LR
  A[Transport diagnostics] --> D[Shared Node hashing helper]
  B[Agent logging] --> D
  C[Status credential summaries] --> D
  D --> E[Hexadecimal digests]
  D --> F[Trimmed identifier labels]
  E --> G[Logs and status output]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -21, Tests 0, Config +8. Total -13 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 14 35 56 -21
Tests 3 3 3 0
Docs 0 0 0 0
Config 2 9 1 +8
Generated 0 0 0 0
Other 0 0 0 0
Total 19 47 60 -13

Review metrics

None.

Technical review

Best possible solution:

Keep one Node-only hashing owner, preserve the established SDK exports and diagnostic formats, and keep browser imports independent of Node crypto.

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

Not applicable: this PR removes duplicate implementations rather than repairing a reported runtime defect; the duplication is directly visible on current main.

Is this the best way to solve the issue?

Yes. A shared Node-only leaf removes the duplication while retaining existing public entrypoints, raw-prefix semantics, and logging presentation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal consolidation with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported emitted-package and browser-bundle probes address the changed packaging boundary; consumer tests are supplemental, and this review did not execute them.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-07T05:56:48.285Z sha d31dc01 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T06:08:27.321Z sha 9e11b7e :: blocked before merge. :: none
  • reviewed 2026-09-07T12:39:20.552Z sha 65b859f :: blocked before merge. :: none
  • reviewed 2026-09-07T12:45:29.595Z sha 65b859f :: blocked before merge. :: none

Preserve raw digest slicing and logging label normalization in a Node-only normalization-core subpath. Keep browser exports and public logging contracts unchanged.

Proof: 453 old/new comparisons and browser-root compilation passed; independent review clean. Consumer and package gates continue in the PR.
NodeNext requires the exact TypeScript source mapping before package artifacts exist. A resolver probe fails without this mapping and resolves the canonical owner with it; independent review is clean.
@steipete
steipete force-pushed the steipete/dedup-infra-crypto-0906 branch from 65b859f to e3d6215 Compare September 7, 2026 14:14
@steipete
steipete merged commit 5d4494f into main Sep 7, 2026
350 of 353 checks passed
@steipete
steipete deleted the steipete/dedup-infra-crypto-0906 branch September 7, 2026 14:58
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
* refactor(crypto): share SHA-256 identifier helpers

Preserve raw digest slicing and logging label normalization in a Node-only normalization-core subpath. Keep browser exports and public logging contracts unchanged.

Proof: 453 old/new comparisons and browser-root compilation passed; independent review clean. Consumer and package gates continue in the PR.

* fix(build): resolve shared crypto source during type checks

NodeNext requires the exact TypeScript source mapping before package artifacts exist. A resolver probe fails without this mapping and resolves the canonical owner with it; independent review is clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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