cmake: forward SEQUANT_ASSERT_BEHAVIOR to TiledArray and BTAS built from source - #616
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Moderate assertion-mapping and override-handling issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Aligns SeQuant assertion defaults with source-built TiledArray and BTAS, while updating configuration documentation.
Changes:
- Updates assertion defaults and dependency forwarding.
- Preserves explicit dependency overrides.
- Updates installation and contributor guidance.
File summaries
| File | Summary |
|---|---|
doc/user/getting_started/installing.rst |
Documents assertion configuration behavior. |
CMakeLists.txt |
Updates assertion defaults. |
cmake/modules/FindOrFetchTiledArray.cmake |
Adds forwarding; moderate findings remain regarding IGNORE mapping and explicit policy overrides. |
cmake/modules/FindOrFetchBTAS.cmake |
Adds BTAS forwarding; a moderate finding remains regarding IGNORE mapping. |
AGENTS.md |
Updates assertion guidance. |
Review details
Suppressed comments (1)
cmake/modules/FindOrFetchTiledArray.cmake:25
- When a parent project or user explicitly sets
TA_ASSERT_POLICY, this block still derives BTAS fromSEQUANT_ASSERT_BEHAVIOR. For example,TA_ASSERT_POLICY=TA_ASSERT_IGNOREwithSEQUANT_ASSERT_BEHAVIOR=THROWleaves TA assertions disabled but makes BTAS assertions throw, so the documented override and TA/BTAS alignment are broken. Derive this value fromTA_ASSERT_POLICYhere, while retaining the independentBTAS_ASSERT_THROWSoverride guard.
if (SEQUANT_ASSERT_BEHAVIOR STREQUAL THROW)
set(BTAS_ASSERT_THROWS ON CACHE BOOL "Whether BTAS_ASSERT should throw")
else ()
set(BTAS_ASSERT_THROWS OFF CACHE BOOL "Whether BTAS_ASSERT should throw")
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a43593d to
37617c3
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate issues remain in assertion-policy forwarding and override handling.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (5)
cmake/modules/FindOrFetchBTAS.cmake:48
- If only the documented deprecated override
BTAS_ASSERT_THROWSis set, this condition turns following off but the message interpolates onlyBTAS_ASSERT_POLICY, which may be empty. Report both variables (or the variable that triggered the override) so the status message explains why following was disabled.
message(STATUS "BTAS's assertion behavior was set explicitly (BTAS_ASSERT_POLICY=${BTAS_ASSERT_POLICY}): SEQUANT_BTAS_ASSERT_POLICY_FOLLOWS_SEQUANT turned OFF, it will no longer follow SeQuant's")
cmake/modules/FindOrFetchTiledArray.cmake:44
- The phrase “one an overridden ... points at” is ungrammatical; rephrase it so the source-selection caveat is clear.
# forwarded as well, for a BTAS older than that (e.g. one an overridden
# TA_TRACKED_BTAS_TAG or FETCHCONTENT_SOURCE_DIR_BTAS points at).
cmake/modules/FindOrFetchTiledArray.cmake:27
FetchContent_MakeAvailable(TiledArray)below is allowed to satisfyFIND_PACKAGE_ARGSfrom an installed TiledArray, but these forwarding assignments run before that choice and are unconditional. In that case no source dependency consumes the values, while theFORCEd TA/BTAS cache entries still alter the parent project and the later..._SEENstate. Restrict the forwarding and acknowledgement to the FetchContent source-build path so installed targets retain their own configured policy.
set(TA_ASSERT_POLICY TA_ASSERT_${SEQUANT_ASSERT_BEHAVIOR} CACHE STRING "Controls the behavior of TA_ASSERT" FORCE)
cmake/modules/FindOrFetchTiledArray.cmake:62
- If only the documented deprecated override
BTAS_ASSERT_THROWSis set, this condition turns following off but the message interpolates onlyBTAS_ASSERT_POLICY, which may be empty. Report both variables (or the variable that triggered the override) so the status message explains why following was disabled.
message(STATUS "BTAS's assertion behavior was set explicitly (BTAS_ASSERT_POLICY=${BTAS_ASSERT_POLICY}): SEQUANT_BTAS_ASSERT_POLICY_FOLLOWS_SEQUANT turned OFF, it will no longer follow SeQuant's")
doc/user/getting_started/installing.rst:116
- The sentence uses
therewhere the definite articletheis required.
N.B. a BTAS older than ``BTAS_ASSERT_POLICY`` (ValeevGroup/BTAS#188) has neither an abort nor an ignore mode -- there
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Lite
|
Re the five suppressed comments of the last Copilot round: the two status-message ones and the shim-vs-policy one are resolved by dropping the BTAS_ASSERT_THROWS shim (32967a6); the two wording nits are gone with the rewritten docs; the installed-TiledArray one is addressed by probing find_package(TiledArray CONFIG QUIET) the way FetchContent's FIND_PACKAGE_ARGS will and skipping the forwarding (and the _SEEN marker) when it succeeds. PR body has the updated verification tables. |
There was a problem hiding this comment.
🔵 Needs a closer look
The TiledArray discovery logic must preserve parent-selected FetchContent sources.
Review details
Suppressed comments (1)
cmake/modules/FindOrFetchTiledArray.cmake:32
- This pre-probe can bypass a parent project's FetchContent declaration. A parent may declare
TiledArraywith a customSOURCE_DIR,GIT_TAG, orFIND_PACKAGE_ARGSwithout settingFETCHCONTENT_SOURCE_DIR_TILEDARRAY; if an installed package is found here,FetchContent_MakeAvailablelater sees the target and never consumes that declaration. Please inspect existing FetchContent properties/declarations before probing, or only probe when this module owns the declaration, so a parent-selected source cannot be silently replaced by an installed TiledArray.
if (NOT DEFINED FETCHCONTENT_SOURCE_DIR_TILEDARRAY AND NOT FETCHCONTENT_TRY_FIND_PACKAGE_MODE STREQUAL NEVER)
find_package(TiledArray CONFIG QUIET COMPONENTS tiledarray)
if (TiledArray_FOUND)
set(_sequant_ta_from_source FALSE)
endif()
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Re the suppressed comment on the find_package pre-probe in FindOrFetchTiledArray.cmake: agreed, a probe ahead of FetchContent_MakeAvailable could hijack a parent project's own TiledArray declaration. c303f2d drops the probe and decides afterwards instead: TA_ASSERT_POLICY is forwarded unconditionally, and once FetchContent_MakeAvailable has run, tiledarray_SOURCE_DIR (set only when TiledArray was populated from source) selects between recording the acknowledged value and undoing the forwarding (TA_ASSERT_POLICY and the FOLLOWS option restored to their pre-forwarding cache state, marker dropped) when an installed TiledArray was used. Source-path verification (trees A/B in the description) re-run and unchanged; there is no installed TiledArray on this machine, so the restore branch is verified by reading, not by a configure. |
There was a problem hiding this comment.
🔵 Needs a closer look
Two moderate cache-handling issues remain in the TiledArray integration.
Review details
Suppressed comments (2)
cmake/modules/FindOrFetchTiledArray.cmake:46
- On a build directory configured with the previous SeQuant,
TA_ASSERT_POLICYis already cached by TiledArray, butSEQUANT_TA_ASSERT_POLICY_SEENdoes not exist. The first configure after this change therefore takes this old dependency default as an explicit override and forcesSEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANT=OFF; for example, an existing RelWithDebInfo cache can remainTA_ASSERT_THROWinstead of adopting the new SeQuant defaultTA_ASSERT_ABORT. Please add a migration path, or document a required cache reset/explicit policy, so upgrades do not silently retain the old mismatched default.
if (DEFINED TA_ASSERT_POLICY AND NOT (DEFINED SEQUANT_TA_ASSERT_POLICY_SEEN AND TA_ASSERT_POLICY STREQUAL SEQUANT_TA_ASSERT_POLICY_SEEN))
# explicit user value (on the first configure, or changed since SeQuant last saw it): honor it, stop following
set(SEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANT OFF CACHE BOOL "${_sequant_ta_follow_doc}" FORCE)
message(STATUS "TA_ASSERT_POLICY=${TA_ASSERT_POLICY} was set explicitly: SEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANT turned OFF, TA_ASSERT_POLICY will no longer follow SEQUANT_ASSERT_BEHAVIOR")
cmake/modules/FindOrFetchTiledArray.cmake:88
- When TiledArray is satisfied by an installed package, this branch restores the prior follow option only if it existed. On a fresh installed-package configure,
option()above has already createdSEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANTin the cache, but_sequant_ta_follows_beforeis undefined, so the source-only option is left behind even though it has no effect for the installed target (and can leak into a later source reconfiguration). Unset it in theelsebranch so the installed path leaves the cache unchanged.
if (DEFINED _sequant_ta_follows_before)
set(SEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANT "${_sequant_ta_follows_before}" CACHE BOOL "Derive TA_ASSERT_POLICY from SEQUANT_ASSERT_BEHAVIOR when TiledArray is built from source; OFF leaves TA_ASSERT_POLICY to the user (or to TiledArray's default)" FORCE)
endif()
unset(SEQUANT_TA_ASSERT_POLICY_SEEN CACHE)
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Re the two suppressed comments of the last round (61a2f6e): (1) upgrade of an existing build directory: the cached pre-forwarding default is indeed taken as an explicit value on the first reconfigure (CMake cannot tell them apart, and keeping the cached value is the conservative choice); the status message now says so and names the fix, a single reconfigure with -DSEQUANT_TA_ASSERT_POLICY_FOLLOWS_SEQUANT=ON (same for BTAS), and installing.rst documents it. Simulated by stripping the marker from a configured cache and setting TA_ASSERT_POLICY=TA_ASSERT_THROW: the reconfigure reports it and turns following OFF (TA stays THROW), and the reconfigure with the option ON adopts TA_ASSERT_ABORT. (2) installed-TiledArray path: the FOLLOWS option that option() created is now unset in that branch, so the cache is left as it was. |
There was a problem hiding this comment.
🔵 Needs a closer look
Address stale-cache handoff issues when switching between direct-BTAS and TiledArray modes.
Review details
Suppressed comments (2)
cmake/modules/FindOrFetchBTAS.cmake:31
- The reverse transition has the same stale-cache failure: after a TiledArray build,
BTAS_ASSERT_POLICYremains cached but this module has noSEQUANT_BTAS_ASSERT_POLICY_SEENmarker because TiledArray recordsTA_BTAS_ASSERT_POLICY_SEEN. Switching toSEQUANT_TILEDARRAY=OFFtherefore classifies TiledArray's derived value as an explicit BTAS override, turns this follows option OFF, and subsequent changes toSEQUANT_ASSERT_BEHAVIORno longer update direct BTAS. Please recognize the TiledArray-derived marker or reset the value when taking ownership here, without clobbering a real user override.
# SEQUANT_BTAS_ASSERT_POLICY_FOLLOWS_SEQUANT is the opt-out: while ON,
# BTAS_ASSERT_POLICY is (re)derived from SEQUANT_ASSERT_BEHAVIOR on every
# configure; an explicit BTAS_ASSERT_POLICY that differs from the value SeQuant
# last acknowledged (recorded in SEQUANT_BTAS_ASSERT_POLICY_SEEN) is honored
# and turns the option OFF. Turning it back ON resumes following.
cmake/modules/FindOrFetchTiledArray.cmake:16
- When an existing build directory is reconfigured from the direct-BTAS mode to
SEQUANT_TILEDARRAY=ON, the previous direct path leavesBTAS_ASSERT_POLICYandSEQUANT_BTAS_ASSERT_POLICY_SEENin the cache. TiledArray uses its separateTA_BTAS_ASSERT_POLICY_SEEN, so it treats that inherited policy as a new explicit override, disablesTA_BTAS_ASSERT_POLICY_FOLLOWS_TA, and a later change toSEQUANT_ASSERT_BEHAVIORcan leave TA and BTAS on different policies. Please hand off or clear SeQuant-derived BTAS state when entering this path, while preserving an actual user override.
# BTAS is not handled here: the tracked TiledArray builds BTAS itself and
# forwards the effective TA_ASSERT_POLICY to it as BTAS_ASSERT_POLICY
# (ValeevGroup/tiledarray#587, with its own TA_BTAS_ASSERT_POLICY_FOLLOWS_TA
# opt-out), so an explicit or forwarded TA_ASSERT_POLICY reaches BTAS too.
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Re the two suppressed comments on switching SEQUANT_TILEDARRAY in an existing build directory (6a23c0c): each BTAS-building path now adopts the other's acknowledged value as its own marker when the cached BTAS_ASSERT_POLICY equals it, and drops the foreign marker, so following continues across the switch; a real override differs from the marker and is honored as before. Verified configure-only in one tree: TA on (BTAS derived ABORT) -> TA off (adopted, SEQUANT_ASSERT_BEHAVIOR=IGNORE then moves BTAS to IGNORE) -> TA on with THROW (TiledArray adopts, TA and BTAS both THROW; ABORT next) -> TA off with an explicit BTAS_ASSERT_POLICY=BTAS_ASSERT_THROW (honored, following OFF) -> IGNORE (BTAS stays THROW). |
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate issues remain in cross-configuration policy provenance handling.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
|
27ccc22 replaces all of the forwarding machinery (FOLLOWS options, acknowledgment markers, mode-switch handoff, installed-package restore) with the plain cached-option idiom: seed TA_ASSERT_POLICY / BTAS_ASSERT_POLICY from SEQUANT_ASSERT_BEHAVIOR only if not in the cache yet, no FORCE. An explicit -D wins and a later change of SEQUANT_ASSERT_BEHAVIOR does not re-seed, like any cached option; CMake cannot distinguish an explicit -D from a stale cache entry, so the removed machinery could only approximate that, and every approximation had a corner case. Description rewritten accordingly; the same reduction of TiledArray's BTAS forwarding follows in a separate TiledArray PR. |
a4492e0 to
a8c6f26
Compare
…_ASSERT_POLICY seeded from TA_ASSERT_POLICY, tiledarray#588)
… seeds TA/BTAS - SEQUANT_ASSERT_BEHAVIOR defaults to ABORT for every build type except Release and MinSizeRel (IGNORE), the partition TA_ASSERT_POLICY uses. - On the first configure of a build directory FindOrFetchTiledArray seeds TA_ASSERT_POLICY from SEQUANT_ASSERT_BEHAVIOR if it is not in the cache yet (THROW/ABORT/IGNORE map one-to-one); TiledArray seeds BTAS_ASSERT_POLICY of the BTAS it builds the same way. FindOrFetchBTAS seeds BTAS_ASSERT_POLICY when SeQuant builds BTAS itself. - This is the plain cached-option idiom: an explicit -D from the user or a parent project is already in the cache and wins, and a later change of SEQUANT_ASSERT_BEHAVIOR does not re-seed (set the option explicitly, or use a fresh build directory). CMake cannot distinguish an explicit -D from a stale cache entry, so nothing smarter can be exact. - installing.rst and AGENTS.md document the above.
a8c6f26 to
5d3402f
Compare
Problem
SEQUANT_ASSERT_BEHAVIORdid not reach the dependencies SeQuant builds from source, so TiledArray and BTAS picked their own defaults (BTAS: throw wheneverBUILD_TESTING=ON, regardless ofNDEBUG) and the three libraries could disagree on what a tripped assertion does. Also, SeQuant's own default wasTHROWfor every build type, unlikeassert()and unlike TiledArray.Change (three commits: BTAS pin, TiledArray pin, feature)
SEQUANT_ASSERT_BEHAVIORdefaults toABORTexcept forRelease/MinSizeRel(IGNORE), the partitionTA_ASSERT_POLICYuses.FindOrFetchTiledArray.cmakeseedsTA_ASSERT_POLICYfromSEQUANT_ASSERT_BEHAVIORif it is not in the cache yet (THROW/ABORT/IGNOREmap one-to-one); TiledArray seedsBTAS_ASSERT_POLICYof the BTAS it builds the same way (cmake: seed BTAS_ASSERT_POLICY once from TA_ASSERT_POLICY tiledarray#588).FindOrFetchBTAS.cmakeseedsBTAS_ASSERT_POLICYwhen SeQuant builds BTAS itself (SEQUANT_TILEDARRAY=OFF).-DTA_ASSERT_POLICY=.../-DBTAS_ASSERT_POLICY=...(from the user or a parent project) is already in the cache and wins; a later change ofSEQUANT_ASSERT_BEHAVIORdoes not re-seed, exactly as a change ofCMAKE_BUILD_TYPEdoes not re-default it (set the option explicitly, or use a fresh build directory). CMake cannot distinguish an explicit-Dfrom a stale cache entry, so anything smarter (re-deriving on reconfigure, opt-out options, acknowledgment markers) can only approximate that and has corner cases; the review rounds on this PR explored that path and it was dropped in favor of seeding once.52aadfe54(BTAS_ASSERT_POLICY: real THROW / ABORT / IGNORE modes BTAS#188:BTAS_ASSERT_POLICYwith THROW/ABORT/IGNORE, none NDEBUG-dependent); TiledArray1654b57b7(tiledarray#588:BTAS_ASSERT_POLICYseeded once fromTA_ASSERT_POLICY). A BTAS older than Improve missing space instance error #188 ignoresBTAS_ASSERT_POLICYand only knows the booleanBTAS_ASSERT_THROWS, which SeQuant does not touch.installing.rstandAGENTS.mddescribe the above in one paragraph each.Verification (configure-only, TiledArray + BTAS from source, RelWithDebInfo,
BUILD_TESTING=ON)-DSEQUANT_ASSERT_BEHAVIORTA_ASSERT_POLICYBTAS_ASSERT_POLICYSEQUANT_ASSERT_BEHAVIOR=IGNORETA_ASSERT_POLICY=TA_ASSERT_THROWSEQUANT_ASSERT_BEHAVIOR=IGNORETA_ASSERT_POLICY=TA_ASSERT_IGNOREBTAS_ASSERT_POLICY=BTAS_ASSERT_IGNORESEQUANT_ASSERT_BEHAVIOR=IGNOREBTAS_ASSERT_POLICY=BTAS_ASSERT_IGNORESEQUANT_ASSERT_BEHAVIOR=THROWThe "TA on" rows were measured against TiledArray
02d03c42c(tiledarray#587, whose BTAS forwarding still re-derived on reconfigure); with the pinned tiledarray#588 BTAS is seeded once and its column behaves likeTA_ASSERT_POLICY's (row 3 would keep ABORT). No SeQuant-owned marker or option entries remain in any cache.