Skip to content

docs(tr): Phase L implementation plans (L-0..L-7)#9

Merged
k-yoshimi merged 4 commits into
developfrom
docs/tr-library-plans-final
Apr 18, 2026
Merged

docs(tr): Phase L implementation plans (L-0..L-7)#9
k-yoshimi merged 4 commits into
developfrom
docs/tr-library-plans-final

Conversation

@k-yoshimi
Copy link
Copy Markdown
Owner

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

Phase L plans for tr module library-ization, per the design spec merged in PR #3 (docs/superpowers/specs/2026-04-17-tr-library-design.md). 8 sub-phases (L-0 baseline, L-1 graphics split, L-2 C ABI foundation, L-3 param registry, L-4 shared-lib build, L-5 Python wrapper, L-6 4-layer tests, L-7 docs). Tests mandatory; existing tr2 binary preserved; libtrapi.so added as new target.


Note

Low Risk
Documentation-only change adding implementation plans; no runtime/code paths are modified, so risk is limited to potential confusion if plans become outdated.

Overview
Adds a new set of Phase L implementation plan documents (docs/superpowers/plans/2026-04-18-tr-library-L0..L7-*.md) that lay out the step-by-step roadmap for TR “library-ization”.

The plans cover: baseline confirmation, a Makefile-only split of tr sources into core/graphics/menu, scaffolding a C ABI (tr_init/tr_run/...) and state struct, building libtrapi.so via PIC rebuilds of dependent libs, a stdlib-only Python ctypes wrapper, integrating a 4-layer test strategy into run_tests.sh, and final user-facing docs/examples—explicitly aiming to keep the existing tr2 binary behavior unchanged throughout.

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

@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

8 sub-phases per the canonical Phase L design at
docs/superpowers/specs/2026-04-17-tr-library-design.md (PR #3).

Tests mandatory in every sub-phase (4-layer pattern: equivalence / C ABI /
Python wrapper / sweep smoke). Existing tr2 executable preserved; libtrapi.so
added as a new build target.
Comment thread docs/superpowers/plans/2026-04-18-tr-library-L3-param-registry.md
Comment thread docs/superpowers/plans/2026-04-18-tr-library-L3-param-registry.md Outdated
@k-yoshimi
Copy link
Copy Markdown
Owner Author

Pre-merge review (parent agent + code-reviewer agent)

PR を draft 化 します。merge 前に以下の修正が必要です。

Critical (compile-blocking)

  • L-3 Task 4 Step 2 tr_api_run 実装で CALL tr_loop を引数なしで呼び出している。実 tr/trloop.f90:16SUBROUTINE tr_loop(ierr)INTEGER,INTENT(OUT):: IERR。INTENT(OUT) は optional でない → コンパイルエラー。修正: CALL tr_loop(calc_ierr) + IF(calc_ierr /= 0) ierr = 3; RETURN

Important

  • L-1 SRCS 8 ファイル列挙だが trg2d.f90 / trg3d.f90 は実 Makefile では別変数 SRC2D / SRC3S(後者は SRC3D ではない)に存在し OBJ2D / OBJ3D 経由で libtr2.a にリンク(line 78)。L-1 SRCS_GRAPHICS に未含。L-4 SRCS_LIB に graphics を除く設計だが trg2d/trg3d 内で SRCS_CORE シンボルが使われると shared lib リンク fail のリスク。SRC2D/SRC3S の PIC 戦略を明示。
  • L-6 Task 6 Step 1 test_definitions.conftrlib_c_abi:python:... 追加するが、現 run_tests.sh:get_binary()eq/tr/fp/tx のみ知っている → python モジュールエントリは即 SKIP される。Step 2 で python 分岐を追加するが、Step 1 → Step 2 の順序で commit すると一時的に既存 dispatch が壊れる。atomic commit 推奨。
  • L-2/L-4 SRCS_LIB: 実 Makefile の SRCM=trcom0.f90 trcom1.f90 trcomm.f90 trbpsd.f90、加えて trbpsd-mod.f90tr/ に存在。プランは trbpsd-mod.f90 を SRCS グループに配置せず → モジュール出力先が不明、リンク時 missing symbol リスク。
  • L-6 conf entry の column 3 セマンティクス: 既存は INPUT_FILE、プラン拡張は shell command (make -C tr/tests/c_abi run_layer2)。run_single_test がどちらかをどう判別するか不明確。

修正方針

  • L-3 tr_api_runCALL tr_loopCALL tr_loop(calc_ierr) に修正、エラー伝播追加
  • L-1 graphics 分離方針に SRC2D / SRC3S を含める or 別途扱う旨を明記
  • L-6 test_definitions.conf 拡張と run_tests.sh 改修を 1 commit に統合
  • L-2 trbpsd-mod.f90 を SRCS_API or SRCM に配置確認

Note

PR #4 (tr Phase 1, USE ONLY 整備) と本 PR (tr Phase L plans) は独立。PR #4 は別途進行。

修正後 gh pr ready で draft 解除して再レビューします。

@k-yoshimi k-yoshimi marked this pull request as draft April 18, 2026 06:22
@k-yoshimi k-yoshimi marked this pull request as ready for review April 18, 2026 06:44
@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

…dispatch, L-3 tr_loop arg, L-2/L-4 SRCM note)
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!

2 issues from previous reviews remain unresolved.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit a376f95. Configure here.

@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

Comment thread docs/superpowers/plans/2026-04-18-tr-library-L5-python-wrapper.md Outdated
@k-yoshimi
Copy link
Copy Markdown
Owner Author

@cursor review

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3a68373. Configure here.

def test_tst2(self):
from python.trlib.tests.fixtures.tst2_params import apply
actual = run_case(apply, ntmax=10)
compare_with_baseline(actual, BASELINES / "tr_tst2")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong import path for test fixture modules

Medium Severity

The test templates use from python.trlib.tests.fixtures.iter01_params import apply (and similarly for m0904_params, tst2_params), but the same file adds REPO / "python" to sys.path at line 149, which makes trlib — not python.trlib — the correct top-level package. The python.trlib path only works accidentally when CWD happens to be the repo root. This is also inconsistent with from trlib import Trlib used in the same file. The imports need to be from trlib.tests.fixtures....

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3a68373. Configure here.

@k-yoshimi k-yoshimi merged commit 802695c into develop Apr 18, 2026
1 check passed
@k-yoshimi k-yoshimi deleted the docs/tr-library-plans-final branch April 18, 2026 15:42
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