Skip to content

Engine fixes: convert blocks on sense-check errors, date-parsed stale-FX, unresolved FX left blank, ingest.read_large_rows - #27

Closed
moonlight-lupin wants to merge 1 commit into
mainfrom
portback/qip-engine-fixes-12oct2026
Closed

moonlight-lupin wants to merge 1 commit into
mainfrom
portback/qip-engine-fixes-12oct2026

Conversation

@moonlight-lupin

Copy link
Copy Markdown
Owner

Summary

Engine-safety fixes for data-convert plus an additive large-file reader in ingest. Bumps plugin.json 0.8.9 → 0.8.10 with a dated CHANGELOG entry.

1. convert_file refuses to write over source drift

Previously only contract errors blocked the write. A mapped source column that was missing or renamed (a sense-check error) still produced output, with that column written blank. Now any sense-check error also blocks: report["blocked"] = True, report["written"] = [], and a new report["blocked_by"] (["contract"], ["sense_check"] or both). The report is still produced, render_report states the blocking reason(s), and the CLI main returns 1 when blocked.

2. Date-keyed FX never invents a rate

With a pinned fx.rates table, a row dated before every pinned rate, or with a blank/unparseable date, used to be converted silently at the earliest or latest rate. That cell is now left blank and flagged fx_rate_unresolved (severity warning, with row and field) in issues. Rate selection parses dates (ISO, DD MMM YYYY, dd/mm/yyyy, Excel serial, via dataclean.parse_date) instead of comparing strings. New helpers: _to_date and _fx_resolve. _fx_rate is kept as a thin wrapper. _field / apply_map gain optional flags= / issues=, and convert_rows routes those flags into issues.

3. Stale-FX sense-check parses dates

The stale-FX check compared raw strings, so "30 Jun 2026" vs "2026-07-01" returned "not stale". Both dates are now parsed. A rates table is judged by its latest as_of. An unparseable date gives a new fx_date_unparsed warning instead of passing silently. The --as-of help text is clarified, and the self-test is extended.

4. ingest.read_large_rows(path, sheet=None, cache_dir=None)

An additive drop-in for read_any on big files. It returns (rows, note) in the same list-of-rows shape (header first; None/NaN/NaT become ""). .xlsx/.xlsm go through read_large. Any other file type falls back to read_any, so it never raises just because the file is not Excel. read_large itself stays Excel-only.

Docs

  • data-convert SKILL.md and conversion-spec.md: default flag, the stale rule, --as-of / run_dates_after on the call lines, blocking on sense-check errors, and unresolved FX left blank and flagged.
  • data-analyse / data-tidy SKILL.md and large-file-patterns.md: a "which reader" section covering read_large_rows vs read_large.

Backward compatibility

  • API: all additions are optional keyword arguments or new functions, and existing call signatures still work.
  • Two intentional behaviour changes:
    • A drifted source (sense-check error) is now blocked, and the CLI exits 1.
    • An unresolvable date-keyed FX row is left blank and flagged instead of being converted at a guessed rate.
  • A single pinned fx.rate still applies to every row, and fx_convert with no pinned rate still raises.

Tests

  • python -B -m pytest -q -p no:cacheprovider tests gives 120 passed (was 116; 4 new tests in tests/test_engine.py).
  • convert.py --self-test gives self-test: PASS. The other engine self-tests (analyse, reconcile, viz, workbook, dataclean) are green.
  • bin/data-lint gives OK — plugin + 6 skills source-clean, engines self-test green.

Release note

Per AGENTS.md, a version bump needs a tag and a GitHub release. After merge: git tag v0.8.10 and gh release create v0.8.10 with notes from the CHANGELOG section.

🤖 Generated with Claude Code

…, unresolved FX left blank, ingest.read_large_rows (v0.8.10)

- convert.py: convert_file refuses to write when sense_check has any error
  (blocked_by: contract / sense_check); render_report states why; CLI exits 1
- convert.py: new _to_date / _fx_resolve; date-keyed FX rows that predate
  every pinned rate or have blank/unparseable dates are left blank and flagged
  fx_rate_unresolved (was: silently used earliest/latest rate); _field /
  apply_map gain optional flags= / issues=
- convert.py: stale-FX sense-check parses both dates (was a raw string
  compare that broke on DD MMM YYYY), judges a rates table by its latest
  as_of, adds fx_date_unparsed warning; --as-of help clarified; self-test extended
- ingest.py: additive read_large_rows(path, sheet=None, cache_dir=None)
  drop-in returning (rows, note) in read_any shape; non-Excel falls back to read_any
- docs: data-convert SKILL.md + conversion-spec.md; data-analyse / data-tidy
  SKILL.md + large-file-patterns.md
- tests: 4 new engine tests (116 -> 120)
- plugin.json 0.8.9 -> 0.8.10 + CHANGELOG (tag/release to follow on merge)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moonlight-lupin moonlight-lupin changed the title Port back: convert blocks on sense-check errors, date-parsed stale-FX, unresolved FX left blank, ingest.read_large_rows Engine fixes: convert blocks on sense-check errors, date-parsed stale-FX, unresolved FX left blank, ingest.read_large_rows Oct 12, 2026
@moonlight-lupin
moonlight-lupin deleted the portback/qip-engine-fixes-12oct2026 branch October 12, 2026 16:13
@moonlight-lupin

Copy link
Copy Markdown
Owner Author

Superseded by the PR from branch fix/convert-fx-and-blocking (same commit) — the head branch was renamed, which closed this one.

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