Skip to content

night: fold: per-root field mapping and a rating value map - #116

Draft
harmoniqs-amico-agent[bot] wants to merge 4 commits into
mainfrom
night/arjev-97-2026-10-28b
Draft

harmoniqs-amico-agent[bot] wants to merge 4 commits into
mainfrom
night/arjev-97-2026-10-28b

Conversation

@harmoniqs-amico-agent

Copy link
Copy Markdown

Closes #97

Night-runner draft (notturno, amicissimo#531): implemented headlessly in a Modal sandbox, gates echo gates-deferred-to-CI green. Ready for review — never auto-merged by this slice.

harmoniqs-amico-agent Bot and others added 4 commits October 28, 2026 13:12
…ading — #97

Add RootConfig dataclass (fields + rating_values) and extend load_config to
parse [[vault.root_configs]] array of tables from TOML. Each entry carries a
path key; absent entries leave that root inheriting the global field mapping.

Provides the config surface for per-root field mapping: a root may declare its
own field slots and a value map (e.g. 'high' → 'core') without migrating notes.
#97

_effective_fields() merges per-root field overrides over the global mapping;
_rating_values() returns the root's value map or empty dict. fold_roots passes
these to _build_paper on a per-root basis.

_build_paper is rewritten to:
- dispatch on same_field (rating and why map to the same frontmatter key, e.g.
  both → 'relevance'): canonical enum > rating_values remap > sentence → why
- separate-fields path: same ordering plus fallback to sentence-as-why when
  rating is not an enum value and why is absent
- back-compat path: the literal 'relevance' field (only when not already mapped)
  still applies for notes that predate the per-root scheme
- empty-string guard: blank rating still warns 'outside enum' (not 'sentence')

Rankings are bit-identical for single-root configs with no root_configs entry.
inspect: _fold_lines() now emits one 'fold root-mapping: <path> (...)' line per
root with a custom mapping when cfg carries root_configs. Roots that inherit the
global mapping produce no extra line, so existing single-root output is unchanged.
The line shape matches the stable fold [a-z-]+: .+ contract (line-shape test
continues to pass).

tests/test_per_root_mapping.py: 15 tests covering all four ACs:
- AC1: root without per-root config inherits global; two-root fixture with differing
  schemas reads the right fields from each root
- AC2: rating value map enum remapping (high→core, medium→useful, low→marginal)
- AC3: sentence-valued rating field treated as why-line; no 'outside enum' warning
- AC4: single-root parity gate — fold results and ranking scores are bit-identical
- Config TOML loading roundtrip
- inspect per-root mapping state lines (present / absent)
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.

fold: per-root field mapping and a rating value map

1 participant