Skip to content

feat(tot): Phase L-6 4-layer tests#96

Merged
k-yoshimi merged 3 commits into
developfrom
feature/tot-library-L6-tests
Apr 19, 2026
Merged

feat(tot): Phase L-6 4-layer tests#96
k-yoshimi merged 3 commits into
developfrom
feature/tot-library-L6-tests

Conversation

@k-yoshimi
Copy link
Copy Markdown
Owner

@k-yoshimi k-yoshimi commented Apr 19, 2026

Summary

Phase L-6 of the TOT module library work: 4-layer test suite mirroring eqlib / trlib L-6, adapted for the orchestrator (every parameter name carries an `:` namespace prefix because tot's parameter space is the union of eq / tr / fp / ti / wr / wrx).

  • Layer 1 equivalence (`python/totlib/tests/test_equivalence.py`): `Tot()` replay vs `test_run/baselines/tot_*/metrics.json` at tol=1e-10. Triple-skip-gated on libtotapi.so / totlib importability / `TOT_RUN_OK=1` (tot_init / tot_run / tot_get_state / tot_finalize are L-3/L-4/L-5 stubs returning TOT_ERR_NOT_IMPL today; the gate flips the test on once L-6 fan-out lands).
  • Layer 2 C ABI negative (`tot/tests/c_abi/test_negative.c` + `tot_api_check_all` Makefile target): pre-init NOT_IMPL, unknown-namespace / missing-prefix / empty-prefix / prefix-only rejection (TOT_ERR_INVALID), per-module unknown-bare reject for every prefix, double-finalize safety, post-finalize dispatcher invariance.
  • Layer 4 sweep (`python/totlib/tests/test_sweep.py`): 3x3 `eq:RR` x `eq:BB` grid with a fresh `with Tot()` per sample (re-init fix from trlib PR feat(trlib): plot API + TOML config runner (reference) #83 / eqlib L-6); verifies nrmax / nsmax stay invariant across cells. Same `TOT_RUN_OK` gating as Layer 1.
  • Fixtures (`python/totlib/tests/fixtures/{init,tot_demo2014_params,tot_ht6m_params}.py`): namespaced PARAMS (`eq:RR=8.5/0.65`, `tr:DT=0.0001`, `tr:KNAMEQ=eqdata-HT6M`, ...) replaying the standalone `tot_demo2014_short` and `tot_ht6m_short` namelists.
  • CI wiring: 5 new `totlib_*` rows in `test_run/test_definitions.conf` (c_abi / wrapper / ffi / equivalence / sweep).

No edits to totlib core (`totlib.py` / `state.py` / `_ffi.py` / `errors.py`).

Test plan

  • `PYTHONPATH=python python3 -m unittest discover python/totlib/tests -v` -> 47 tests, 24 skipped, 0 failed (pass-or-skip clean; Layer 1 + Layer 4 skipped because libtotapi.so is not built and TOT_RUN_OK is not set in this sandbox).
  • `bash -n test_run/run_tests.sh` -> rc=0 (no syntax regressions from the conf append).
  • `./test_run/run_tests.sh -l | grep totlib_` -> 5 rows visible.
  • On a build host: `make -C tot libtotapi.so` followed by `make -C tot tot_api_check_all` -> negative driver runs.
  • On a build host: once L-6 fan-out lands inside the .so, `TOT_RUN_OK=1 ./test_run/run_tests.sh totlib_equivalence totlib_sweep` -> Layer 1 + Layer 4 PASS.

Note

Low Risk
Low risk: changes are limited to new test/fixture code and build/test harness wiring, with no modifications to totlib runtime logic. Main risk is CI/build breakage if the new tot_api_check_all target or TOT_RUN_OK-gated tests are misconfigured.

Overview
Adds Phase L-6 test coverage for the tot orchestrator mirroring the per-module L-6 shape: Layer 1 equivalence (test_equivalence.py) that replays namespaced fixtures through Tot() and diffs TotState.to_dict() against test_run/baselines/*/metrics.json, and Layer 4 sweep (test_sweep.py) that runs a 3x3 eq:RR×eq:BB grid with a fresh Tot() per cell to smoke-test lifecycle stability.

Introduces namespaced parameter fixtures for tot_demo2014_short and tot_ht6m_short under totlib.tests.fixtures, plus a new Layer 2 C ABI negative driver (tot/tests/c_abi/test_negative.c) and a composite make -C tot tot_api_check_all target to run smoke/param/run_so/negative. Wires the new totlib_* jobs into test_run/test_definitions.conf, with Layer 1/4 gated behind TOT_RUN_OK=1 until tot_run/tot_get_state are implemented.

Reviewed by Cursor Bugbot for commit 76f040d. Bugbot is set up for automated code reviews on this repo. Configure here.

Add the 4-layer test suite for the tot orchestrator library, mirroring
the eqlib / trlib L-6 work. tot-specific twist: every parameter name
carries an <ns>: namespace prefix (eq:RR, tr:DT, fp:NSMAX, ...) because
the orchestrator parameter space is the union of the per-module
registries.

- python/totlib/tests/fixtures/{__init__,tot_demo2014_params,tot_ht6m_params}.py:
  namespaced PARAMS replaying the standalone tot_demo2014_short and
  tot_ht6m_short namelists through libtotapi.so (eq:RR=8.5/0.65,
  tr:DT=0.0001, etc.).

- python/totlib/tests/test_equivalence.py (Layer 1): diff a Tot()
  replay vs test_run/baselines/tot_*/metrics.json at tol=1e-10.
  Triple-skip-gated on libtotapi.so, totlib importability, and
  TOT_RUN_OK=1 (the L-3/L-4/L-5 stubs return TOT_ERR_NOT_IMPL).

- python/totlib/tests/test_sweep.py (Layer 4): 3x3 eq:RR x eq:BB
  grid with a fresh `with Tot()` per sample (re-init fix from trlib
  PR #83 / eqlib L-6); verifies nrmax / nsmax stay invariant across
  cells. Same TOT_RUN_OK gating.

- tot/tests/c_abi/test_negative.c (Layer 2): pre-init NOT_IMPL
  contract, unknown-namespace / missing-prefix / empty-prefix
  rejection (TOT_ERR_INVALID), per-module unknown-bare reject for
  every prefix, double-finalize safety, post-finalize dispatcher
  invariance.

- tot/Makefile: new tot_api_check_all umbrella target wraps
  tot_api_check + tot_api_check_so + test_negative for one-shot CI
  invocation. Mirrors eq_api_check_all in eq/Makefile.

- test_run/test_definitions.conf: append five totlib_* rows
  (c_abi / wrapper / ffi / equivalence / sweep) following the existing
  per-module L-6 row shape.

Verification:
- python3 -m unittest discover python/totlib/tests -v -> 47 tests, 24
  skipped (pass-or-skip clean; equivalence + sweep gated on so/RUN_OK).
- bash -n test_run/run_tests.sh -> rc=0.
- ./test_run/run_tests.sh -l | grep totlib_ -> 5 rows.

No edits to totlib core (totlib.py / state.py / _ffi.py / errors.py).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

Comment thread tot/tests/c_abi/test_negative.c Outdated
k-yoshimi added a commit that referenced this pull request Apr 19, 2026
2026-04-19 改訂. tr/ti/wr/wrx/fp の 5 章はそのまま保持し,
新たに第 8 章 eq モジュール (6 関数 C ABI と PSIB 0-origin の
解説含む), 第 9 章 tot モジュール (名前空間プレフィックス設計)
を追加. 完了モジュールを 5 → 7 に拡大.

- 第 8 章 (eq): 概要, ビルド, hello-world, set_param_str (KNAMEQ),
  PSIB 0-origin / run() mode=1 デフォルトの FAQ, 約 60 件の
  パラメータ表, EqState フィールド, F90 modernization (F-1..F-5)
  への言及, 変更履歴 (PR #54/#65/#70/#78/#80/#86/#92/#89#71/#79/#81/#87/#93)
- 第 9 章 (tot): 概要, ビルド, hello-world, namespace prefix
  ディスパッチ表, wr→wrx 別名, dict/set_param_str, 既知制約
  (init/run/get_state/finalize は L-3/L-4/L-5 でスタブ),
  変更履歴 (PR #43/#82/#85/#91/#94)
- 状況章を更新: モジュール完了マトリクスを 7 行化,
  eq F90 modernization (F-1..F-5) 完了マトリクス追加,
  MCP サーバ群 (tr/ti/wr/wrx/fp + tot 進行中, 6 個) 追加
- 残作業: trlib のみ実装の plot/TOML runner 横展開 (deferred),
  チュートリアル Notebook 集 (deferred)
- 付録 PR 一覧を 2026-04-19 (#96 まで) に最新化, eq/tot/MCP 追記
- 補足カタログに eq/tot の最短例 2 つを追加
- xelatex 2 回コンパイル成功, PDF 55 ページ (旧版から +拡張)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread tot/tests/c_abi/test_negative.c
@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 76f040d. Configure here.

@k-yoshimi k-yoshimi merged commit 45d9d6c into develop Apr 19, 2026
1 check passed
@k-yoshimi k-yoshimi deleted the feature/tot-library-L6-tests branch April 20, 2026 04:07
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.

1 participant