Skip to content

spec(bridge): #258 — executable own-bridge contract (Bridge.md + behavior matrix) - #297

Merged
PhysShell merged 2 commits into
mainfrom
claude/own258-bridge-contract
Jul 18, 2026
Merged

spec(bridge): #258 — executable own-bridge contract (Bridge.md + behavior matrix)#297
PhysShell merged 2 commits into
mainfrom
claude/own258-bridge-contract

Conversation

@PhysShell

Copy link
Copy Markdown
Owner

Что и зачем

P-022 step 6a (#258): нормативный контракт всего verdict-determining поведения OwnIR bridge (ownlang/ownir.py, 3273 строки) до начала реализации Rust own-bridge (#259). Новый spec/Bridge.md (правила BR-B/D/L/M/P/V по пяти секциям issue: validation с «двумя дверями», fact lowering — единая routing table + twin-rule to_own/to_module, handle identity, kill-on-rebind, четырёхусловный branch hoist, untrack/kill-sites, call lowering; MOS-оркестрация вокруг существующего spec/Inference.md с картой функций→INF-правил; подготовка входов DI/effects/protocols; verdict mapping — закрытый skip-list, map-or-raise, матрица сообщений как parity-поверхность, анкеры, severity/suppression, dedup, ordering, rendering) + план трёх слоёв parity-фикстур с regeneration и zero-Python steady state. spec/BridgeBehaviorMatrix.md — ledger полноты: все check-families tests/test_ownir.py (ни одно не пропущено) промаплены на правила, источники и требуемый Rust-слой. Ambiguities — не TODO, а issues: #294, #295, #296. Guardrails #258 соблюдены: production-код не менялся, schema не менялась, новых диагностик нет.

Тип изменения

  • feat — новая возможность
  • fix — исправление бага
  • docs — документация
  • refactor / chore / test / ci — без изменения поведения

Как проверено

  • python tests/run_tests.py (зелёный — изменения только в spec/)
  • ruff check . и mypy
  • выборочная сверка line-референсов матрицы с tests/test_ownir.py
  • полные прочтения ownlang/ownir.py (все 3273 строки) и inventory всех checks += 1 семейств test_ownir.py

Связанные issue

Closes #258. Refs #250, #251, #259, #294, #295, #296.

Чеклист

  • изменение покрыто тестом/селфтестом (или объяснено, почему нет) — spec-only; conformance-мэппинг фиксирует существующие suites, «spec без теста = red build» правило вписано в оба файла
  • README/docs обновлены при необходимости (spec/README.md таблица)
  • коммиты в conventional-commit стиле

Draft — review gate: по acceptance #258 независимое review спеки должно пройти до старта #259. Ключевые точки для review: BR-V2 (закрытый skip-list), BR-V4 (сообщения как нормативная поверхность), BR-L7 (hoist-условия), решения OD-1..OD-3 (#294) — они определяют, какую «дверь» реализует Rust.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MdYFKUaygHz1T9H1qJ7BqK


Generated by Claude Code

…behavior matrix)

The normative migration contract for the Rust own-bridge crate (P-022 step
6a): everything in ownlang/ownir.py that determines verdicts beyond the JSON
schema, written down as rules and inventoried against the test suite.

spec/Bridge.md — rules BR-*:
* BR-B1/B2  bridge/analysis ownership boundary: prepare-and-map only, no
            verdict repair, explicit re-anchor exceptions.
* BR-D1-D4  validation: the strict door's ordered checklist; the tolerant
            direct-check_facts door (skip-not-coerce); the deliberate `sig`
            asymmetry; document order is semantic.
* BR-L1-L11 fact lowering: the single routing table (with the to_own/
            to_module twin rule), handle identity from global counters,
            identity fallbacks, subscriber regions, per-function lowering
            order + synthesized return types, localmap + kill-on-rebind,
            the four-condition cross-branch hoist + safety walk, optimistic
            untrack vs top-level kill sites, call lowering (channel routing /
            direct Call / fresh mint), vocabulary enforcement, line handling.
* BR-M1-M3  MOS orchestration around spec/Inference.md (which stays the
            normative MOS layer), plus a function-to-INF-rule map for the port.
* BR-P1-P3  DI / effects / protocols input preparation.
* BR-V1-V9  verdict mapping: the pipeline order, the closed OWN033/034/035/
            040/041 skip list, map-or-raise (IR5) through structured subjects,
            the message-synthesis matrix as a parity surface, anchor policy,
            severity/suppression, the dedup key, stable ordering, rendering.
* §6        the three parity-fixture layers for #259 (validation / normalized
            lowered representation / normalized diagnostics) with regeneration
            and zero-Python steady-state expectations; layer 2 has no Python
            emitter yet and is #259's first deliverable.

spec/BridgeBehaviorMatrix.md — the completeness ledger: every checks-block
family in tests/test_ownir.py (all 200+, none omitted) mapped to the BR/IR/INF
rule it pins, its Python source, and its Rust fixture layer; suites beyond
test_ownir.py enumerated.

Ambiguities are issues, not TODOs: #294 (tolerant-door scope, unknown-kind
fallback, line coercion), #295 (positional identity fallbacks, evidence-blind
dedup, anchorless SARIF URIs), #296 (generated matrix cross-check). Guardrails
respected: no production code changed, no schema redesign, no new diagnostics.

Closes the deliverable of #258; independent review gates #259.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01MdYFKUaygHz1T9H1qJ7BqK
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 30d93b42-ee70-4ed6-a242-f72eb1cb2af9

📥 Commits

Reviewing files that changed from the base of the PR and between a7d8499 and 2b8e82f.

📒 Files selected for processing (3)
  • spec/Bridge.md
  • spec/BridgeBehaviorMatrix.md
  • spec/README.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/own258-bridge-contract

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.

…olerances

Two normative wording fixes from #297 review:

* BR-B1 was internally inconsistent: "nothing that changes which sites are
  found" contradicted BR-L1's routing, which legitimately admits, suppresses,
  and redirects sites (unresolved skip, self-subscribe drop, released-capture
  mitigation, returned_fresh provenance, token-vs-region path choice). Restated:
  the bridge does not independently solve for violations after routing; its
  only authority to admit/suppress/redirect is the CLOSED routing behavior of
  BR-L1 (+ the lowering-time admission rules BR-L6-L9) and the advisory side
  paths of BR-V1 — over admitted inputs the analyses own every verdict.

* BR-D2's "skipped, never coerced" overclaimed: the same sentence then
  described DI field coercions. Restated as three distinct tolerances —
  malformed entries skipped whole; accepted entries subject to the existing
  field-specific coercions; line degrading via _as_int only on the paths that
  use it (OD-3) — so the tolerant door's contract matches what #294 is
  actually deciding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01MdYFKUaygHz1T9H1qJ7BqK
PhysShell pushed a commit that referenced this pull request Jul 18, 2026
… main yet

Codex review on #298 correctly flagged that spec/Bridge.md and
spec/BridgeBehaviorMatrix.md are referenced as delivered but do not exist in
this checkout — they live on PR #297 (the #258 deliverable, in independent
review). Reworded the 6a status in both places to say the specs land with
PR #297 and #259 starts only after that review gate, so the checklist stays
truthful regardless of which PR merges first.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01MdYFKUaygHz1T9H1qJ7BqK
@PhysShell
PhysShell marked this pull request as ready for review July 18, 2026 17:31

Copy link
Copy Markdown
Owner Author

Independent review verdict (recorded per #258 acceptance): APPROVED, no blocking findings — head 2b8e82f.

Verified against the implementation:

  • BR-B1 consistent after the fix: the bridge's only admit/suppress/redirect authority is the closed routing (BR-L1, BR-L6–L9) + advisory side paths (BR-V1); analyses own all verdicts over admitted inputs.
  • BR-D2 now states the three distinct tolerances (skip-whole malformed entries; field-specific coercions on accepted entries; _as_int only on the paths that use it), matching the code.
  • BR-L7 confirmed: exactly the four hoist gates (depth ≥ 1 acquire/fresh result; shallowest reference at depth 0; while-body exclusion; definite-assignment safety walk incl. early returns), first-acquire line + pool kind preserved.
  • BR-V2 confirmed: the skip list is exactly OWN033/OWN034/OWN035/OWN040/OWN041.
  • BR-V4 confirmed: message branches for flow-locals, captures, DI-sourced captures, timer/disposable/subscribe/pool and plain subscriptions match, incl. the lambda note and source-dependent severity.
  • OD-1–3 (Bridge contract OD-1/2/3: pin the tolerant door — direct check_facts() diverges from load() (unknown kind fallback, line coercion) #294) confirmed as real divergences: strict load() rejects unknown kinds; the direct lowering path falls back via _RESOURCES.get(..., subscription); line passes through _as_int on some paths and strict int(...) on others.

Non-blocking wording nit (not worth a commit, noted for the record): BR-L7's safety condition says early exit "before the post-merge release"; the implementation also hoists the use-only case so the leak is correctly reported — "post-merge reference/discharge" would be the fully literal phrasing. The behavior matrix already lists the use-only case.

Gate for #259 is satisfied once this merges; #259's first deliverable stays strictly the Layer 2 normalized-lowered-representation emitter + committed goldens + regeneration path.


Generated by Claude Code

@PhysShell
PhysShell merged commit 8855f7e into main Jul 18, 2026
39 checks passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b8e82f29b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread spec/Bridge.md
Comment on lines +304 to +305
2-step; effect re-run→mint; protocol opened→barrier). Steps with unknown lines
(`< 1`) are omitted; a slice shorter than 2 steps is dropped.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve one-step evidence flows

For DI paths where only one service in the path has a real registration line, the current Python bridge still keeps and renders a one-location codeFlows entry: _di_findings stores flow=di_path_steps(...), and ownlang.evidence.code_flow returns a flow for any non-empty surviving step list. This rule would make the Rust port drop those one-step flows, so SARIF parity diverges whenever later DI path hops lack locations.

Useful? React with 👍 / 👎.

Comment thread spec/Bridge.md
Comment on lines +192 to +194
a matching `sig`, else the name-merge; (b) otherwise a **direct `Call`** is
emitted only when the callee has a summary or is a sink extern — an
unresolvable callee (BCL/extension method) is dropped: no effect, no claim,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document raw-name direct-call resolution

For a unique first-party callee emitted as global::C.M, _mos_lookup can resolve the canonical C.M summary, but _lower_flow only emits the direct Call when mos.get(callee) exists under the raw call name; otherwise the call is dropped unless it went through overload/may channel routing or fresh-result minting. As written, a port could treat any canonical summary as directly resolvable and apply consume/borrow effects that Python currently misses, changing OWN001/OWN002 results for global-qualified unique calls.

Useful? React with 👍 / 👎.

PhysShell pushed a commit that referenced this pull request Jul 19, 2026
The normative documents described the pre-slice-3 world. Recorded now:

* spec/Bridge.md §6 Layer 2: #299 (Python emitter + fixture foundation),
  #300 (typed own-lowered surface/emitter, presence-aware metadata,
  per-document version gate), #301 (own-bridge constructs Layer 2 from
  facts and reproduces all 26 shared goldens byte-exact; golden is
  expected output only); tolerant_unknown_kind stays Python-only under
  #294 (the Rust bridge fails loud on an unknown kind instead of adopting
  the tolerant fallback); Layer 1, Layer 3, analysis wiring and #259 as a
  whole remain open.
* spec/BridgeBehaviorMatrix.md: the Layer 2 summary paragraph updated to
  the same completed state.
* tests/test_lowered_fixtures.py docstring: future tense ("will replay",
  "until the Rust emitter exists") moved to the present.
* BR-L7 wording nit folded in (recorded on #297): condition (4) guards the
  post-merge reference/discharge, not only a release — the use-only hoist
  fixture is in the gate too.

Docs-only; no Rust code, facts, manifest or golden changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdYFKUaygHz1T9H1qJ7BqK
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.

P-022 step 6a: formalize OwnIR bridge semantics before the Rust port

2 participants