Skip to content

fix(daemon): restore claim slow-log payload observability without gzip#4322

Open
Hzzzzzx wants to merge 1 commit into
multica-ai:mainfrom
Hzzzzzx:agent/cc/99399fc8
Open

fix(daemon): restore claim slow-log payload observability without gzip#4322
Hzzzzzx wants to merge 1 commit into
multica-ai:mainfrom
Hzzzzzx:agent/cc/99399fc8

Conversation

@Hzzzzzx

@Hzzzzzx Hzzzzzx commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

#4307 reverted "gzip daemon claim responses" (#4259). That revert was the right call for the gzip middleware, but it also removed — as collateral — the claim slow-log observability fields, leaving the /api/daemon/tasks/claim response-size signal blind in prod.

This PR restores only the observability half, with the gzip middleware deliberately left out.

Changes

  • handler.go — re-add writeMeasuredJSON: same output as writeJSON but returns the encoded body size. It measures the uncompressed JSON length and is unrelated to transport compression.
  • daemon.go (ClaimTaskByRuntime / logClaimEndpointSlow) — restore payload_bytes, agent_skill_count, builtin_skill_count, skill_payload_bytes on the slow-claim log, captured at the response-build sites.

Explicitly NOT included

  • daemonJSONCompressor / chimw.Compress gzip middleware — the part #4307 actually targeted.
  • ❌ No changes to router.go, no middleware, no route wiring.
  • ❌ No structural refactor.

So this is a pure logging/diagnostics restore with no wire-behavior change.

Tests

  • New TestWriteMeasuredJSONByteIdenticalToWriteJSON — table-driven, asserts writeMeasuredJSON and writeJSON emit byte-identical response bodies (and matching length / status / Content-Type) across many inputs: HTML-escapable chars, unicode, nested structures, and a large claim payload with skills. This locks the "no wire change" invariant so it is provable and regression-guarded.
  • Restored TestLogClaimEndpointSlowIncludesPayloadFields — asserts the four fields reach the log line.

Verification

  • gofmt -l — clean
  • go vet ./internal/handler/ — clean
  • go test ./internal/handler/ — ok (full package, ~7s)
  • go build ./... — ok

🤖 Generated with Claude Code

multica-ai#4307 reverted "gzip daemon claim responses" (multica-ai#4259) and, as collateral,
removed the claim slow-log observability fields, leaving the claim
response-size signal blind. Restore only the observability half:

- re-add writeMeasuredJSON (measures uncompressed JSON length; unrelated
  to transport compression)
- re-add payload_bytes / agent_skill_count / builtin_skill_count /
  skill_payload_bytes to logClaimEndpointSlow and capture them in
  ClaimTaskByRuntime

The gzip middleware (daemonJSONCompressor in router.go) — the part the
revert actually targeted — is intentionally NOT restored. No router,
middleware, or wire-behavior change.

Tests:
- new table-driven TestWriteMeasuredJSONByteIdenticalToWriteJSON asserts
  writeMeasuredJSON and writeJSON emit byte-identical responses across
  many inputs (HTML-escapable, unicode, nested, large claim+skills),
  locking the "no wire-behavior change" invariant
- restore TestLogClaimEndpointSlowIncludesPayloadFields

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@HzZzZzZzZz is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants