Skip to content

feat(config): operator config via .arghda/config.toml#8

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/modest-hawking-3fd6it
Jun 20, 2026
Merged

feat(config): operator config via .arghda/config.toml#8
hyperpolymath merged 1 commit into
mainfrom
claude/modest-hawking-3fd6it

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Persists the operator-configurable headline pattern (and any future lint knobs) in .arghda/config.toml — the per-workspace surface the spec's open question calls for (docs/arghda-spec.adoc lines 200–202). Until now the pattern was only a CLI flag.

Design

  • src/config.rs — a serde/toml schema deserialised from .arghda/config.toml, overlaid on RuleConfig::default():
    [lint]
    headline_pattern = "^[a-z][A-Za-z0-9-]*$"
    deny_unknown_fields so a typo (headline_patten) errors rather than being silently ignored; a missing file yields defaults.
  • scan / dag gain --config <file>; discovery defaults to <PATH>/.arghda/config.toml.
  • Precedence (low → high): built-in default < config.toml < CLI --headline-pattern. An explicit --config pointing at a missing file is an error; the default-location lookup is silently optional.
  • Reuses the existing RuleConfig / rules_with_config (from feat(lint): unpinned-headline rule (Smoke-pin coverage) #6) — no change to the rule itself, just where its pattern comes from.

Verification

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo build, cargo test all green (lib suite 41 → 47; 6 new config unit tests: parse / precedence / unknown-key-rejection / malformed-TOML / discovery).
  • Live end-to-end: empty config → default pattern flags all headlines; [lint] headline_pattern = "^thm-.*$" narrows to just thm-key; --headline-pattern '^foo-.*$' overrides the config file; --config <missing> errors cleanly.

Adds the toml dependency.

Second of three sequenced engine-polish PRs (3 → 2 → 1): unused-import (#7, merged), .arghda/config.toml (this), then the DAG headlines field.

🤖 Generated with Claude Code

https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs


Generated by Claude Code

Persists the operator-configurable headline pattern (and any future lint
knobs) in `.arghda/config.toml`, the surface the spec's open question calls
for — previously it was only a CLI flag.

- New `src/config.rs`: a serde/toml `[lint] headline_pattern` schema overlaid
  on `RuleConfig::default()`. `deny_unknown_fields` so a typo errors rather
  than being silently ignored; a missing file yields defaults.
- `scan` / `dag` gain `--config <file>`; discovery defaults to
  `<PATH>/.arghda/config.toml`. Precedence (low→high): built-in default <
  config.toml < CLI `--headline-pattern`. An explicit `--config` that does
  not exist is an error; the default location is silently optional.
- Reuses the existing `RuleConfig` / `rules_with_config` (from #6); no change
  to the rule itself.

Adds the `toml` dependency. 6 config unit tests (parse/precedence/unknown-key/
malformed/discovery); lib suite 41 → 47. Live-verified end to end: empty
config → default pattern flags all headlines; `^thm-` config narrows to one;
`--headline-pattern` overrides config; missing `--config` errors cleanly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs
@hyperpolymath hyperpolymath marked this pull request as ready for review June 20, 2026 01:47
@hyperpolymath hyperpolymath merged commit 83e5684 into main Jun 20, 2026
1 check passed
@hyperpolymath hyperpolymath deleted the claude/modest-hawking-3fd6it branch June 20, 2026 01:48
hyperpolymath added a commit that referenced this pull request Jun 20, 2026
## Summary

Completes the v0 DAG schema: each `dag` node now carries the per-node
**`headlines`** array the spec defines (`docs/arghda-spec.adoc` lines
128–135) but the builder previously omitted — the sorted, deduped list
of top-level headline theorem names the module declares.

## Design

- **Reuses the `unpinned-headline` extractor** — no duplicate parsing.
`headline_decls` becomes `pub`, and `dag::build` runs it per node with
the configured headline `Regex`.
- **`build_dag` gains a `headline_pattern: &str` parameter.** `dag`
threads the *resolved* pattern through (built-in default <
`.arghda/config.toml` < CLI `--headline-pattern`, via the #8 config
plumbing), so the DAG honours the same operator configuration as the
lint.
- Column-0-only extraction means indented `private` helpers are not
surfaced (same export-only filter as the rule).

## Verification

- `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`,
`cargo build`, `cargo test` all green (7 groups).
- New `tests/fixtures/headlines/` + `dag_populates_node_headlines`:
asserts `Thm → ["thm-one","thm-two"]`, that the indented `private
helper` is excluded, and the import-only `All` entry surfaces `[]`.
- **Live:** `arghda dag tests/fixtures/headlines` emits `"headlines":
["thm-one","thm-two"]` on the `Thm` node and `[]` on `All`.

Last of three sequenced engine-polish PRs (3 → 2 → 1): `unused-import`
(#7), `.arghda/config.toml` (#8), **DAG `headlines`** (this). With
these, the v0 Agda lint set and DAG schema in `arghda-spec.adoc` are
complete.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs

---
_Generated by [Claude
Code](https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs)_
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