Skip to content

feat(intake): surface context_loaders.entities core_claim (v0.4.2)#5

Merged
broomva merged 1 commit into
mainfrom
feat/entity-context-loader
May 29, 2026
Merged

feat(intake): surface context_loaders.entities core_claim (v0.4.2)#5
broomva merged 1 commit into
mainfrom
feat/entity-context-loader

Conversation

@broomva
Copy link
Copy Markdown
Owner

@broomva broomva commented May 29, 2026

Summary

Activates the previously-inert context_loaders.entities wire. _format_intake_context() rendered context_loaders.files but never context_loaders.entities — so KG entities a lens declared never reached the agent's working context. The field was validated (REQUIRED_CONTEXT_KEYS) and templated since v0.2.0 but never surfaced.

This is the load half of the persona substrate (workspace spec docs/specs/2026-05-28-persona-substrate-architecture.html, Phase 2 / BRO-1242): persona constraint entities now ride every turn, regardless of agent discipline. Closes the drift failure mode (agent suggesting AWS when the user is Railway-first, etc.).

What changed

  • _confined_entity_path() — resolves a workspace-relative entity path, confined to the workspace (rejects absolute paths, ../, and symlink escape via resolve() + is_relative_to()).
  • _entity_core_claim(path) — reads the entity's core_claim, collapsed to a single length-capped line. Never raises (oversized files skipped, non-mapping frontmatter rejected, any error → bare path).
  • _safe_inline() — sanitizes displayed provenance (strips control chars, newlines, brackets; collapses whitespace; caps length) so a crafted entry can't break the [...] wrapper or inject a standalone line.
  • Render block — new "Knowledge-graph constraints to honor (core_claim)" section; escaping paths skipped entirely; header omitted when all entries are invalid.
  • Backward-compatible: no-op when entities: [] (byte-identical to v0.4.1); the real hook always passes workspace.

Hybrid load path (spec §6)

The compact core_claim index rides every turn; kg loads full entity bodies on demand for depth.

Test plan

  • python3 -m pytest tests/test_role_x.py47 passing (38 prior + 9 new).
  • New coverage: happy-path render, missing-file fallback, empty-entities backward-compat, non-mapping frontmatter (no crash), multiline-claim collapse, ../ + absolute path confinement, newline + bracket + control-char sanitization.
  • Real-data dogfood (P11): on a deploy prompt, intake surfaces "Default deploy target is Railway; suggest AWS only on explicit ask…" from the actual research/entities/persona/ set.

P20 cross-review (codex / GPT-5, Strata A)

Cross-vendor adversarial review across 3 rounds: 6/10 FAIL → 6/10 FAIL → 7/10 (≥7 threshold met). Every concrete finding resolved:

  • R1: non-dict frontmatter AttributeError (broke the never-fail invariant); multiline-claim / oversize output corruption; path-read confinement. Fixed.
  • R2: display-path not sanitized (newline injection); escaping paths still rendered as bare provenance; #anchor dedup. Fixed (helper split + _safe_inline + skip-escapes + cleaned-path dedup).
  • R3: control-char / bracket display injection; absolute-path-inside-ws; changelog overclaim. Fixed (categorical absolute reject; bracket/control strip; accurate docs).

Notes

  • Companion PR B (workspace repo) activates this by populating roles/_meta.md entities: with the persona constraint entities + updates the spec doc. This engine PR is a no-op until then — safe to merge independently.
  • CI floor is Python 3.11+ (Path.is_relative_to), matching .github/workflows/test.yml.

🤖 Generated with Claude Code

Activate the previously-inert context_loaders.entities wire.
_format_intake_context rendered files but never entities — so KG entities a
lens declared never reached the agent's working context. Resolve each
workspace-relative entity path, parse its core_claim frontmatter, and emit a
one-liner under a new "Knowledge-graph constraints to honor" block.

This is the load half of the persona substrate (workspace spec
2026-05-28-persona-substrate-architecture.html, Phase 2 / BRO-1242): persona
constraint entities now ride every turn regardless of agent discipline.

- _entity_core_claim() helper; never raises (missing/malformed -> bare-path fallback)
- _format_intake_context(selection, workspace=None); backward-compatible
- 3 new tests; full suite 41 passing
- CHANGELOG [0.4.2], lens-schema + README docs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@broomva, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 49 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d76c1646-4535-43e0-8c2d-8ed0455f8257

📥 Commits

Reviewing files that changed from the base of the PR and between 1c6eb1f and f49f8f0.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • README.md
  • references/lens-schema.md
  • scripts/role-x.py
  • tests/test_role_x.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/entity-context-loader

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 and usage tips.

@broomva broomva merged commit 4bcf078 into main May 29, 2026
3 checks passed
@broomva broomva deleted the feat/entity-context-loader branch May 29, 2026 22:01
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