Skip to content

Commit dcaa043

Browse files
pamburusclaude
andauthored
feat(config): add prettify-field-keys option (#1315)
Add config file option to control whether underscores in field keys are replaced with hyphens in formatted output. Configuration: - Set `prettify-field-keys = false` to preserve original underscores - Set `prettify-field-keys = true` for hyphen replacement (default) - Config-only option (no CLI flags) Behavior: - Default (`true`) preserves current behavior for backward compatibility - When disabled, field keys like `request_id` display as `request_id` - When enabled, field keys like `request_id` display as `request-id` - Applies to all key segments including nested/flattened keys - `--raw-fields` flag takes precedence when active Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent c023779 commit dcaa043

File tree

18 files changed

+857
-16
lines changed

18 files changed

+857
-16
lines changed

.specify/memory/constitution.md

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
<!--
1+
<!--
22
Sync Impact Report:
3-
- Version: 1.1.0 → 1.2.0
4-
- Added: Principle VII - Test Data Management
5-
- Rationale: MINOR version bump - new principle added to governance
6-
- Templates requiring updates: ✅ All templates reviewed and compatible
7-
- Date: 2025-01-07
3+
- Version: 1.4.2 → 1.4.3
4+
- Modified Sections:
5+
- Development Workflow & Quality Gates (Version Check): Added git fetch -t requirement
6+
- Rationale: PATCH version bump - workflow clarification to fetch latest tags
7+
- Templates requiring updates:
8+
- ✅ plan-template.md: Compatible - no structural changes needed
9+
- ✅ spec-template.md: Compatible - no structural changes needed
10+
- ✅ tasks-template.md: Compatible - workflow guidance orthogonal to task structure
11+
- Modified Requirements:
12+
- Step 2 of version check now includes git fetch -t to ensure latest tags
13+
- Date: 2026-02-04
814
-->
915

1016
# hl (High-performance Log viewer) Constitution
@@ -32,6 +38,29 @@ Comprehensive error handling with graceful degradation. All input validated; mal
3238
<!-- TDD mandatory; no exceptions for performance-critical code -->
3339
Unit tests for algorithms and parsers. Integration tests for end-to-end CLI workflows. Property-based tests for streaming behavior. Performance benchmarks tracked and enforced. All tests must pass before merging. Coverage must not decrease: patches must maintain or improve the project's average code coverage.
3440

41+
**Schema Validation Requirements:**
42+
When modifying configuration file structure (`src/settings.rs`, `etc/defaults/config.toml`) or theme configuration files, the corresponding JSON schema files (`schema/json/config.schema.json`, `schema/json/theme.schema.*.json`) MUST be updated to reflect the changes.
43+
44+
**Schema Build Workflow:**
45+
After updating schema files, the following workflow MUST be followed:
46+
1. Run `cargo build` to automatically update embedded schema references
47+
2. Only after build completes successfully, run `just ci` for validation
48+
3. This order is mandatory because the build process updates schema references that CI validates
49+
50+
This ensures:
51+
- Configuration validation tooling remains accurate
52+
- IDE autocomplete and validation work correctly
53+
- Documentation stays synchronized with implementation
54+
- Embedded schema references are current before validation
55+
56+
**Coverage Validation Requirements:**
57+
After implementing any new feature, run `just uncovered` to identify changed lines lacking test coverage. If uncovered lines appear:
58+
- MUST add tests to cover them unless they require environmental interaction (file I/O, network, OS-specific behavior)
59+
- Document why coverage cannot be added if environmental interaction prevents testing
60+
- Aim to maintain or improve overall project coverage percentage
61+
62+
This ensures new features are properly tested and maintains the high-quality bar established by existing code.
63+
3564
### VI. Specification & Cross-Reference Integrity
3665
<!-- Maintain referential integrity across all documentation and code -->
3766
**Avoid renumbering identifiers whenever possible.** Prefer adding new requirements at the end of sections or using sub-identifiers (e.g., FR-030c, FR-030d) to insert requirements without disrupting existing numbering.
@@ -73,11 +102,83 @@ Tests MUST use external data files instead of inline multiline string literals f
73102
## Development Workflow & Quality Gates
74103

75104
**Code Review**: All PRs require at least one review. Performance-sensitive changes require benchmark verification.
105+
76106
**Testing Gates**: All tests must pass (`cargo test`). Benchmarks must not regress (`cargo bench`). Clippy warnings must be resolved.
107+
77108
**Documentation**: Features documented before or concurrent with implementation. Breaking changes documented in CHANGELOG.
109+
78110
**Performance**: New features benchmarked. Regressions >5% must be justified and documented.
111+
79112
**Backwards Compatibility**: Maintained across minor versions. Deprecation period required before removing features.
80113

114+
**Version Check Before Implementation**: Before starting feature implementation, ensure version is properly bumped:
115+
116+
1. Run `just version` to get current version (e.g., `0.36.0-alpha.5`)
117+
2. Run `git fetch -t && just previous-tag` to get latest tags and previous release tag (e.g., `v0.35.3`)
118+
3. Compare the major.minor versions:
119+
- Extract major.minor from current version (e.g., `0.36`)
120+
- Extract major.minor from previous tag, removing `v` prefix (e.g., `0.35`)
121+
4. If major.minor versions are the SAME:
122+
- Calculate next minor version: `major.(minor+1).0-alpha.1`
123+
- Run `cargo set-version <next-version>` (e.g., `cargo set-version 0.36.0-alpha.1`)
124+
5. If major.minor versions are DIFFERENT:
125+
- Run `just bump` to increment alpha version (e.g., `0.36.0-alpha.5``0.36.0-alpha.6`)
126+
127+
**Rationale**: This ensures each feature branch has a unique version identifier, preventing version conflicts and enabling proper release tracking.
128+
129+
**Commit Workflow**: When using speckit workflow commands, commits MUST follow this discipline:
130+
131+
1. **Pre-commit Validation**: Before ANY commit, run `just ci` which executes:
132+
- `check`: Cargo check for compilation errors
133+
- `test`: Full test suite execution
134+
- `lint`: Clippy warnings resolution
135+
- `audit`: Security vulnerability checks
136+
- `fmt-check`: Code formatting verification
137+
- `check-schema`: JSON schema validation
138+
139+
ALL reported issues MUST be resolved before proceeding with the commit.
140+
141+
2. **Conventional Commits**: After completing each speckit step, create a commit using conventional commit format:
142+
- After `/speckit.specify`: `docs(spec): add [feature-name] specification`
143+
- After `/speckit.clarify`: `docs(spec): clarify [aspect] in [feature-name]`
144+
- After `/speckit.tasks`: `docs(tasks): generate task breakdown for [feature-name]`
145+
- After `/speckit.implement`: `feat([scope]): [user-visible change]` or `fix([scope]): [user-visible fix]`
146+
147+
3. **Commit Message Content Guidelines**:
148+
Commit messages are used to automatically generate release notes and MUST focus on user-visible behavior:
149+
150+
**DO write about**:
151+
- New features users can access
152+
- Bug fixes that affect user experience
153+
- Configuration options added or changed
154+
- Command-line flags or arguments modified
155+
- Output format changes
156+
- Performance improvements users will notice
157+
- Breaking changes requiring user action
158+
159+
**DO NOT write about**:
160+
- Implementation details (functions, structs, modules)
161+
- Source code references (file names, line numbers)
162+
- Test statistics ("1464 tests passing")
163+
- CI validation status ("Full CI validation passed")
164+
- Internal refactoring unless it affects users
165+
- Code quality metrics
166+
167+
**Exception**: Internal changes with no user-visible impact may include brief technical context, but still avoid source code specifics. Focus on "what changed" in system behavior, not "how it was implemented."
168+
169+
**Examples**:
170+
- ✅ Good: `feat(config): add prettify-field-keys option to control key prettification`
171+
- ✅ Good: `fix(parser): handle timestamps with microsecond precision correctly`
172+
- ❌ Bad: `feat(formatting): implement prettify_field_keys in RecordFormatter struct`
173+
- ❌ Bad: `fix: update formatting.rs line 1211 to check prettify flag. All 1464 tests pass`
174+
175+
4. **Rationale**: This workflow ensures:
176+
- Clean, atomic commits representing logical completion points
177+
- All code passing quality gates before entering version control
178+
- Clear commit history enabling easy navigation and rollback
179+
- Prevention of broken commits that fail CI pipelines
180+
- Release notes are immediately useful to end users
181+
81182
## Governance
82183

83184
This constitution supersedes all other practices and informal conventions. All PRs and code reviews must verify compliance with these principles. Complexity introduced must be justified against the principles and documented.
@@ -90,4 +191,4 @@ This constitution supersedes all other practices and informal conventions. All P
90191
3. Documentation of rationale
91192
4. Migration plan for any breaking changes
92193

93-
**Version**: 1.2.0 | **Ratified**: 2025-11-02 | **Last Amended**: 2025-01-07
194+
**Version**: 1.4.3 | **Ratified**: 2025-11-02 | **Last Amended**: 2026-02-04

CLAUDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# hl Development Guidelines
2+
3+
Auto-generated from all feature plans. Last updated: 2026-02-04
4+
5+
## Active Technologies
6+
7+
- Rust (stable, edition 2024) + serde (config deserialization), clap (CLI argument parsing) (009-key-prettification)
8+
9+
## Project Structure
10+
11+
```text
12+
src/
13+
tests/
14+
```
15+
16+
## Commands
17+
18+
- cargo test
19+
- cargo clippy
20+
21+
## Code Style
22+
23+
Rust (stable, edition 2024): Follow standard conventions
24+
25+
## Recent Changes
26+
27+
- 009-key-prettification: Added Rust (stable, edition 2024) + serde (config deserialization), clap (CLI argument parsing)
28+
29+
<!-- MANUAL ADDITIONS START -->
30+
<!-- MANUAL ADDITIONS END -->

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ members = [
2323
]
2424

2525
[workspace.package]
26-
version = "0.36.0-alpha.5"
26+
version = "0.36.0-alpha.6"
2727
edition = "2024"
2828
repository = "https://github.com/pamburus/hl"
2929
license = "MIT"

etc/defaults/config-ecs.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#:schema https://raw.githubusercontent.com/pamburus/hl/v0.35.3/schema/json/config.schema.json
1+
#:schema ../../schema/json/config.schema.json
22

33
# Settings for fields processing.
44
[fields]

etc/defaults/config-k8s.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#:schema https://raw.githubusercontent.com/pamburus/hl/v0.35.3/schema/json/config.schema.json
1+
#:schema ../../schema/json/config.schema.json
22

33
# Configuration of the predefined set of fields.
44
[fields.predefined]

etc/defaults/config.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#:schema https://raw.githubusercontent.com/pamburus/hl/v0.35.3/schema/json/config.schema.json
1+
#:schema ../../schema/json/config.schema.json
22

33
#
44
# Time format, see https://man7.org/linux/man-pages/man1/date.1.html for details.
@@ -127,6 +127,9 @@ names = []
127127
#
128128
# Flatten nested fields by joining them with a dot. Options: ["always", "never"].
129129
flatten = "always"
130+
#
131+
# Prettify field keys by replacing underscores with hyphens. Options: [true, false].
132+
prettify-field-keys = true
130133

131134
# Message format [auto-quoted, always-quoted, always-double-quoted, delimited, raw]:
132135
# * "auto-quoted" • Automatically enables or disables message quotation to improve clarity or avoid ambiguities.

schema/json/config.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@
321321
"$ref": "#/definitions/display-variant"
322322
}
323323
}
324+
},
325+
"prettify-field-keys": {
326+
"type": "boolean"
324327
}
325328
}
326329
},
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Specification Quality Checklist: Key Prettification Config Option
2+
3+
**Purpose**: Validate specification completeness and quality before proceeding to planning
4+
**Created**: 2026-02-04
5+
**Feature**: [spec.md](../spec.md)
6+
7+
## Content Quality
8+
9+
- [x] No implementation details (languages, frameworks, APIs)
10+
- [x] Focused on user value and business needs
11+
- [x] Written for non-technical stakeholders
12+
- [x] All mandatory sections completed
13+
14+
## Requirement Completeness
15+
16+
- [x] No [NEEDS CLARIFICATION] markers remain
17+
- [x] Requirements are testable and unambiguous
18+
- [x] Success criteria are measurable
19+
- [x] Success criteria are technology-agnostic (no implementation details)
20+
- [x] All acceptance scenarios are defined
21+
- [x] Edge cases are identified
22+
- [x] Scope is clearly bounded
23+
- [x] Dependencies and assumptions identified
24+
25+
## Feature Readiness
26+
27+
- [x] All functional requirements have clear acceptance criteria
28+
- [x] User scenarios cover primary flows
29+
- [x] Feature meets measurable outcomes defined in Success Criteria
30+
- [x] No implementation details leak into specification
31+
32+
## Notes
33+
34+
- All items pass validation.
35+
- The spec is ready for `/speckit.clarify` or `/speckit.plan`.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Data Model: Key Prettification Config Option
2+
3+
## Modified Entities
4+
5+
### Formatting (settings.rs)
6+
7+
Config-level representation of formatting preferences.
8+
9+
| Field | Type | Default | Notes |
10+
|-------|------|---------|-------|
11+
| flatten | `Option<FlattenOption>` | `None` | Existing |
12+
| expansion | `ExpansionOptions` | `default()` | Existing |
13+
| message | `MessageFormatting` | `default()` | Existing |
14+
| punctuation | `Punctuation` | `default()` | Existing |
15+
| **prettify_field_keys** | **`Option<bool>`** | **`None`** | **New. `None` = use default (`true`). Deserialized from TOML as `prettify-field-keys`.** |
16+
17+
### RecordFormatter (formatting.rs)
18+
19+
Immutable formatter used during record processing.
20+
21+
| Field | Type | Notes |
22+
|-------|------|-------|
23+
| ... | ... | Existing fields unchanged |
24+
| **prettify_field_keys** | **`bool`** | **New. Set to `!raw_fields && cfg.prettify_field_keys.unwrap_or(true)` during `build()`.** |
25+
26+
## Modified Functions
27+
28+
### KeyPrefix::push()
29+
30+
| Parameter | Type | Notes |
31+
|-----------|------|-------|
32+
| key | `&str` | Existing |
33+
| **prettify** | **`bool`** | **New. When true, applies `key_prettify`; when false, copies key bytes verbatim.** |
34+
35+
## Config File (TOML)
36+
37+
```toml
38+
[formatting]
39+
prettify-field-keys = true # New field, default true
40+
```
41+
42+
## State Transitions
43+
44+
N/A — This is a stateless boolean flag. No lifecycle transitions.
45+
46+
## Validation Rules
47+
48+
- `prettify-field-keys` in TOML must be a boolean (`true` or `false`)
49+
- Invalid values cause a deserialization error (handled by serde)

0 commit comments

Comments
 (0)