Source: code-review of #30; nice-to-have, deferred at merge.
The append subcommand uses four APPENDABLE_<TYPE> arrays + a fifth PREPEND_SECTIONS array to express what can grow and how. That's five places to typo a section name — a "Open Asks" (capital A) would slip through validate-skill and only surface when a user tried to append.
Nothing cross-checks the whitelist against REQUIRED_SECTIONS_*. A bash associative array keyed by <type>:<section> with value append|prepend would be one source of truth and make decision → no appendables an empty-key invariant rather than a special if branch (see scripts/chronicle.sh:327).
Concrete proposal:
- Replace the five arrays with one
declare -A APPEND_RULES where keys are <type>:<section> and values are append or prepend.
- Add a startup-time assertion that every appendable name appears in the corresponding
REQUIRED_SECTIONS_* (catches case-typo regressions).
- Update
cmd_append's whitelist lookup to read the table.
Reference: Sandi Metz, "The Wrong Abstraction" — five parallel arrays is the duplication that signals one missing structure.
Files: scripts/chronicle.sh (lines ~30-60 for the arrays; ~310-330 for the lookup).
Risk: low — pure refactor, the test harness (33 cases) is the safety net.
Source: code-review of #30; nice-to-have, deferred at merge.
The append subcommand uses four
APPENDABLE_<TYPE>arrays + a fifthPREPEND_SECTIONSarray to express what can grow and how. That's five places to typo a section name — a"Open Asks"(capital A) would slip throughvalidate-skilland only surface when a user tried to append.Nothing cross-checks the whitelist against
REQUIRED_SECTIONS_*. A bash associative array keyed by<type>:<section>with valueappend|prependwould be one source of truth and makedecision → no appendablesan empty-key invariant rather than a specialifbranch (seescripts/chronicle.sh:327).Concrete proposal:
declare -A APPEND_RULESwhere keys are<type>:<section>and values areappendorprepend.REQUIRED_SECTIONS_*(catches case-typo regressions).cmd_append's whitelist lookup to read the table.Reference: Sandi Metz, "The Wrong Abstraction" — five parallel arrays is the duplication that signals one missing structure.
Files:
scripts/chronicle.sh(lines ~30-60 for the arrays; ~310-330 for the lookup).Risk: low — pure refactor, the test harness (33 cases) is the safety net.