fix(multilevel): seal contextual text trust boundaries - #1088
Conversation
|
Warning Review limit reached
Next review available in: 5 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@opencode-agent review @cwl-noema-review review Please evaluate exact head |
|
@coderabbitai review Review exact head |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
target='090851d9eaa6062b3cfab9b5a3c8d13c777f47d0'
echo '== Checked-out commit =='
git rev-parse HEAD
git cat-file -t "$target"
git show -s --format='commit=%H%nparents=%P%nsubject=%s' "$target"
echo
echo '== Files changed at target =='
git diff-tree --no-commit-id --name-status -r "$target"
echo
echo '== Complete target diff =='
git show --format=fuller --find-renames --find-copies "$target" -- \
':!*.lock' ':!package-lock.json'
echo
echo '== Python file outline candidates =='
fd -e py . | sort | sed -n '1,240p'
echo
echo '== Validation and public-builder references =='
rg -n -C 4 --type py \
'build_context_membership\s*\(|build_temporal_occasion\s*\(|schema.*version|version.*schema|fingerprint|sha256|SHA-256|isinstance\s*\(.*str|type\s*\(.*\)\s+is\s+str|\.strip\s*\(|\.encode\s*\(|fullmatch\s*\(' \
. -g '!**/.git/**'Length of output: 201403 🏁 Script executed: #!/bin/bash
set -euo pipefail
red='12ad7d800a4cbb3838dc315059f2e556b0e58bc6'
green='ac26b3a6564b4ad1e72e7ad482e8b16bd5fbbddd'
head='090851d9eaa6062b3cfab9b5a3c8d13c777f47d0'
base='04d0bc21a2a20693bcf16108cd76d394fe844d23'
echo '== Commit identity and ancestry =='
git show -s --format='%H%nparents=%P%n%s' "$head"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
git merge-base --is-ancestor "$red" "$head" && echo 'red_is_ancestor=true'
git merge-base --is-ancestor "$green" "$head" && echo 'green_is_ancestor=true'
echo
echo '== Changed paths, baseline through exact head =='
git diff --name-status "$base" "$head"
echo
echo '== Changed paths by stated commit =='
for commit in "$red" "$green" "$head"; do
echo "-- $commit --"
git diff-tree --no-commit-id --name-status -r "$commit"
done
echo
echo '== Focused baseline-to-head diff =='
git diff --find-renames --find-copies --unified=80 "$base" "$head" -- \
'python/**' 'tests/**' 'changelog/**' 'changes/**' 'news/**' \
| sed -n '1,1600p'
echo
echo '== Contextual implementation and test candidates =='
rg -n -l --glob '*.py' \
'def build_context_membership\b|def build_temporal_occasion\b|contextual.*schema|temporal.*schema|membership.*schema' \
python tests | sortLength of output: 12122 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Contextual module outline =='
ast-grep outline python/fast_mlsirm/multilevel --items all --type class,function --view compact
echo
echo '== Shared validator, complete source =='
cat -n python/fast_mlsirm/multilevel/_validation.py
echo
echo '== Builder and constructor definitions =='
rg -n -C 18 --type py \
'^(def build_context_membership\b|def build_temporal_occasion\b|class ContextMembership\b|class TemporalOccasion\b|def __post_init__\b)' \
python/fast_mlsirm/multilevel/contracts.py
echo
echo '== Calls to modified helpers within multilevel package =='
rg -n -C 5 --type py \
'\b(schema_version|descriptive_identifier|fingerprint)\s*\(' \
python/fast_mlsirm/multilevel
echo
echo '== Exact regression test and changelog =='
cat -n tests/test_multilevel_text_callback_safety.py
printf '\n-- changelog --\n'
cat -n docs/changelog.d/1087-multilevel-text-callback-safety.md
echo
echo '== Test references to public builders and stable errors =='
rg -n -C 3 --type py \
'build_context_membership\s*\(|build_temporal_occasion\s*\(|invalid_(observation_id|occasion_revision_fingerprint|schema_version)|MultilevelContractError' \
testsLength of output: 1680 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Contextual module outline =='
ast-grep outline python/fast_mlsirm/multilevel --items all --type class,function --view signatures
echo
echo '== Shared validator, complete source =='
cat -n python/fast_mlsirm/multilevel/_validation.py
echo
echo '== Builder and constructor definitions =='
rg -n -C 18 --type py \
'^(def build_context_membership\b|def build_temporal_occasion\b|class ContextMembership\b|class TemporalOccasion\b|def __post_init__\b)' \
python/fast_mlsirm/multilevel/contracts.py
echo
echo '== Calls to modified helpers within multilevel package =='
rg -n -C 5 --type py \
'\b(schema_version|descriptive_identifier|fingerprint)\s*\(' \
python/fast_mlsirm/multilevel
echo
echo '== Exact regression test and changelog =='
cat -n tests/test_multilevel_text_callback_safety.py
printf '\n-- changelog --\n'
cat -n docs/changelog.d/1087-multilevel-text-callback-safety.md
echo
echo '== Test references to public builders and stable errors =='
rg -n -C 3 --type py \
'build_context_membership\s*\(|build_temporal_occasion\s*\(|invalid_(observation_id|occasion_revision_fingerprint|schema_version)|MultilevelContractError' \
testsLength of output: 64060
No findings in the requested scope.
I did not execute repository tests because the sandbox policy prohibits running repository code. Required CI should provide executable evidence for this exact head while the PR remains Draft.
|
|
Current-head review (a23097e):
|
|
@opencode-agent review @cwl-noema-review review |
|
Reviewed current HEAD a23097e after CodeGraph call-path analysis. Shared multilevel validation now admits only exact built-in schema, identifier, and fingerprint text, preventing caller-controlled string callbacks at membership and temporal provenance boundaries. Focused callback/type/contract tests: 29 passed; Ruff, interrogate (production 100%), compileall, and diff checks passed. Existing hosted Checks are green with OpenCode review queued; no source change is required. |
|
Caution Review failedAn error occurred during the review process. Please try again later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #1087.
Summary
Harden the shared multilevel/longitudinal text validation boundary without changing any psychometric arithmetic.
strfor contextual schema versions before equality checks;strfor descriptive identifiers before trimming, regex, or UTF-8 work;strfor SHA-256 provenance fingerprints before regex matching;build_context_membership()andbuild_temporal_occasion()plus the shared schema helper;RED → GREEN lineage
12ad7d800a4cbb3838dc315059f2e556b0e58bc6adds regressions against protectedmain@04d0bc21a2a20693bcf16108cd76d394fe844d23. On that baseline, identifier admission reaches the hostile.strip()callback, schema admission reaches hostile inequality, and a valid-lookingstrsubclass fingerprint is accepted instead of failing closed.ac26b3a6564b4ad1e72e7ad482e8b16bd5fbbdddestablishes exact built-in string admission before those operations.090851d9eaa6062b3cfab9b5a3c8d13c777f47d0adds the authoritative changelog fragment.Local network access to GitHub is unavailable in this runtime, so focused/full executable proof is delegated to repository CI on this exact head rather than claimed from an unavailable local clone.
Ownership boundary
Python validation/provenance only. Multilevel, multiple-membership, longitudinal likelihoods, estimators, state-transition arithmetic, uncertainty, recovery, and backend parity remain Rust-owned. This branch does not touch the active #565 numerical/contract feature files owned by #1005/#1014.
Keep Draft until exact-head required CI/security/package/coverage/review evidence is terminal and any findings are resolved. No self-approval or gate bypass.