Skip to content

Document magic number constants #16

@Fuabioo

Description

@Fuabioo

Problem

Several constants in the codebase use specific values without explaining why those values were chosen.

Evidence

1. parser.go:13

const MaxScannerBuffer = 100 * 1024 * 1024

The comment says "10MB per line" but the actual buffer is 100MB. Why 100MB? What scenarios require this much?

2. show.go:70

const FileSizeWarningThreshold = 5 * 1024 * 1024

Why specifically 5MB? Is this based on benchmarks, Claude's behavior, or user experience research?

3. conversation.go:303

return (len(text) + 3) / 4  // ~4 chars/token

The "4 characters per token" heuristic - is there a source for this? Does it apply to Claude's tokenizer specifically?

Impact

Without documentation, future maintainers might:

  • Change values without understanding the implications
  • Waste time researching why these values were chosen
  • Make incorrect assumptions about system requirements

Suggested Fix

Add comments explaining the reasoning behind each constant:

// MaxScannerBuffer is 100MB to handle conversation files with very long
// tool outputs or base64-encoded images. Based on observed max line lengths
// in production Claude Code sessions. See [link/issue] for discussion.
const MaxScannerBuffer = 100 * 1024 * 1024

Files:

  • internal/jsonl/parser.go:13
  • internal/cli/show.go:70
  • internal/display/conversation.go:303

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions