Skip to content

fix(multilevel): seal contextual text trust boundaries - #1088

Merged
seonghobae merged 4 commits into
mainfrom
fix/multilevel-text-callback-safety-1087
Aug 24, 2026
Merged

fix(multilevel): seal contextual text trust boundaries#1088
seonghobae merged 4 commits into
mainfrom
fix/multilevel-text-callback-safety-1087

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Closes #1087.

Summary

Harden the shared multilevel/longitudinal text validation boundary without changing any psychometric arithmetic.

  • require exact built-in str for contextual schema versions before equality checks;
  • require exact built-in str for descriptive identifiers before trimming, regex, or UTF-8 work;
  • require exact built-in str for SHA-256 provenance fingerprints before regex matching;
  • add public hostile-subclass regressions through build_context_membership() and build_temporal_occasion() plus the shared schema helper;
  • preserve ordinary built-in identifier/fingerprint behavior and deterministic package-owned seals.

RED → GREEN lineage

  • RED: 12ad7d800a4cbb3838dc315059f2e556b0e58bc6 adds regressions against protected main@04d0bc21a2a20693bcf16108cd76d394fe844d23. On that baseline, identifier admission reaches the hostile .strip() callback, schema admission reaches hostile inequality, and a valid-looking str subclass fingerprint is accepted instead of failing closed.
  • GREEN: ac26b3a6564b4ad1e72e7ad482e8b16bd5fbbddd establishes exact built-in string admission before those operations.
  • Release record: 090851d9eaa6062b3cfab9b5a3c8d13c777f47d0 adds 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.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review or push new commits to the PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 532e4a28-b97f-4935-b320-1c6224f87ac1

📥 Commits

Reviewing files that changed from the base of the PR and between 04d0bc2 and a23097e.

📒 Files selected for processing (3)
  • docs/changelog.d/1087-multilevel-text-callback-safety.md
  • python/fast_mlsirm/multilevel/_validation.py
  • tests/test_multilevel_text_callback_safety.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@opencode-agent review @cwl-noema-review review

Please evaluate exact head 090851d9eaa6062b3cfab9b5a3c8d13c777f47d0; predecessor-head evidence does not transfer.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Review exact head 090851d9eaa6062b3cfab9b5a3c8d13c777f47d0 while the PR remains Draft; focus on the exact-type admission boundary, stable error contracts, and whether the public hostile-subclass regressions cover the root cause.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
🧩 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 | sort

Length 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' \
  tests

Length 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' \
  tests

Length of output: 64060


@seonghobae Reviewed exact head 090851d9eaa6062b3cfab9b5a3c8d13c777f47d0.

No findings in the requested scope.

  • schema_version() checks type(value) is str before equality.
  • descriptive_identifier() checks the exact type before .strip(), regex matching, and UTF-8 encoding.
  • fingerprint() checks the exact type before regex matching.
  • The rejection paths retain their existing structured error codes, paths, and messages.
  • build_context_membership() reaches the identifier boundary directly.
  • build_temporal_occasion() reaches the fingerprint boundary directly.
  • The new regressions cover hostile identifier, fingerprint, and schema-version subclasses. They also verify that no hostile callback runs.
  • Built-in identifier and fingerprint input retains the normal public-builder behavior.

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.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head review (a23097e):

  • Fixed the actionable local findings: removed the unused Iterable import and documented the hostile callback helper, restoring Ruff and 100% docstring coverage for the changed validation/test surface.
  • Focused multilevel contract tests: 26 passed. git diff --check passed. The two raw binding tests remain dependent on the compiled Rust extension and were not treated as Python source failures in this checkout.
  • The trust-boundary behavior is now validated at the current head. Keep this PR Draft until its normal Rust/package/security/review gates are complete; no Draft-to-ready bypass was applied.

@seonghobae

Copy link
Copy Markdown
Contributor Author

@opencode-agent review @cwl-noema-review review

@seonghobae

Copy link
Copy Markdown
Contributor Author

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.

@seonghobae
seonghobae marked this pull request as ready for review August 21, 2026 02:17
@seonghobae
seonghobae enabled auto-merge (squash) August 21, 2026 02:17

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@opencode-agent opencode-agent Bot added priority: medium Normal-priority or P2 work status: needs-review Open pull request requiring current-head review or checks type: bug Defect or incorrect behavior labels Aug 22, 2026
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae merged commit 0069ffa into main Aug 24, 2026
38 checks passed
@seonghobae
seonghobae deleted the fix/multilevel-text-callback-safety-1087 branch August 24, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium Normal-priority or P2 work status: needs-review Open pull request requiring current-head review or checks type: bug Defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(multilevel): seal contextual text trust boundaries before callbacks

1 participant