Goal
Centralize the remaining Base-owned finished-history projection/iteration and table-width policy in a small shared adapter, reusing the existing base-cli record parser and renderer. Keep history filtering and last-failure selection in their owning commands.
Background
Repository-wide duplication review against f9c18f3294873cbbcda9acc7af7f1bc6b17eed45 (2026-09-17).
History and logs both read the same finished-record JSONL, validate/project common fields and compute timestamps. Their timestamp function bodies are AST-identical; their full-width table calculations are also AST-identical. The JSONL reader loops are nearly identical. Both already consume base_cli parsing helpers, so introducing another low-level schema parser would be the wrong fix.
Verified source locations:
Closed #1169 removed earlier optional-value/display helpers; #1709 adopted the shared renderer. This issue targets the remaining reader/projection/timestamp/width code visible in current main.
This is a maintainability refactor. Similarity alone is not evidence of a production failure; any demonstrated differences are called out above.
Scope
Centralize the remaining Base-owned finished-history projection/iteration and table-width policy in a small shared adapter, reusing the existing base-cli record parser and renderer. Keep history filtering and last-failure selection in their owning commands.
Acceptance Criteria
- One implementation supplies common field/timestamp conversion and JSONL iteration; preserve malformed-line logging behavior.
- One table-width calculation serves both commands.
- Keep scope filtering, failure detection, timestamp fallback/sort order, UTC/local labels, redaction and output schemas unchanged.
- Preserve any intentional reader-specific diagnostic text through explicit caller context.
Validation
Run all base_history and base_logs tests. Characterize malformed records, absent timestamps, nonzero exits versus error status, internal scope, long table cells and redacted output before refactoring. Both suites passed as part of the 607-test audit baseline.
Run focused checks first, then the repository-required broader checks for the actual implementation. Preserve public command contracts and review .ai-context/ impact in the PR.
Non-Goals
No duplicate renderer or replacement for the released base-cli history schema; no changes to persisted run ownership or public format defaults.
Project Fields
- Status: Ready
- Priority: P2
- Area: CLI
- Initiative: Contract Hardening
- Size: M
- Milestone: Unscheduled; no release commitment is implied by this audit.
Agent Assignment
Implementation-ready scoped follow-up, assigned to codeforester. Follow AGENTS.md and docs/github-workflow.md: start through basectl gh issue start, use the canonical issue worktree, characterize current behavior before extraction, and open an issue-linked PR. Keep each refactor independently reviewable.
Goal
Centralize the remaining Base-owned finished-history projection/iteration and table-width policy in a small shared adapter, reusing the existing base-cli record parser and renderer. Keep history filtering and last-failure selection in their owning commands.
Background
Repository-wide duplication review against
f9c18f3294873cbbcda9acc7af7f1bc6b17eed45(2026-09-17).History and logs both read the same finished-record JSONL, validate/project common fields and compute timestamps. Their timestamp function bodies are AST-identical; their full-width table calculations are also AST-identical. The JSONL reader loops are nearly identical. Both already consume
base_cliparsing helpers, so introducing another low-level schema parser would be the wrong fix.Verified source locations:
cli/python/base_history/engine.py:288-337cli/python/base_logs/engine.py:322-379cli/python/base_history/engine.py:398-410cli/python/base_logs/engine.py:696-708Closed #1169 removed earlier optional-value/display helpers; #1709 adopted the shared renderer. This issue targets the remaining reader/projection/timestamp/width code visible in current main.
This is a maintainability refactor. Similarity alone is not evidence of a production failure; any demonstrated differences are called out above.
Scope
Centralize the remaining Base-owned finished-history projection/iteration and table-width policy in a small shared adapter, reusing the existing base-cli record parser and renderer. Keep history filtering and last-failure selection in their owning commands.
Acceptance Criteria
Validation
Run all base_history and base_logs tests. Characterize malformed records, absent timestamps, nonzero exits versus error status, internal scope, long table cells and redacted output before refactoring. Both suites passed as part of the 607-test audit baseline.
Run focused checks first, then the repository-required broader checks for the actual implementation. Preserve public command contracts and review
.ai-context/impact in the PR.Non-Goals
No duplicate renderer or replacement for the released base-cli history schema; no changes to persisted run ownership or public format defaults.
Project Fields
Agent Assignment
Implementation-ready scoped follow-up, assigned to
codeforester. FollowAGENTS.mdanddocs/github-workflow.md: start throughbasectl gh issue start, use the canonical issue worktree, characterize current behavior before extraction, and open an issue-linked PR. Keep each refactor independently reviewable.