Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds architecture documentation for the new Flow diagram for Pass 2 domain/range policy enforcementflowchart TD
A[_extract_chunk] --> B[_normalize_scalars]
B --> C[_apply_domain_range_policy]
C --> D{domain_range_policy}
D -->|off| E[Continue existing validation]
D -->|warn| F[Keep remaining violations and tag domain_range_violation]
D -->|strict| G[validate_extraction]
G -->|Violations remain| H[Single LLM retry]
H --> I[_partial_recover drops violating edges]
I --> J[Clean up hallucinated anchor nodes]
G -->|No violations| K[Continue extraction]
F --> L[Assemble output]
E --> L
J --> L
K --> L
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/architecture.md" line_range="344" />
<code_context>
+**Optional domain/range check (`pass2.domain_range_policy`).** Historically Pass 2 validated only edge type, `from`/`to` node IDs and confidence; a property's `domain`/`range` were prompt hints. The `pass2.domain_range_policy` key (`off` | `warn` | `strict`, default `warn`, exposed as `config.PASS2_DOMAIN_RANGE_POLICY`) adds an inheritance-aware check: endpoint types come from the response's nodes plus `prior_nodes`, and a subclass (walking each concept's `parent` chain) satisfies a domain or range. Edges whose property or endpoint type is unknown are left to the existing checks. The key is read but deliberately not surfaced in either `mykg_config.yaml` (same precedent as `llm.temperature_unsupported_prefixes`); opt in by adding it under a profile's `pass2:` block. An invalid value logs a warning and falls back to `warn`.
</code_context>
<issue_to_address>
**issue:** The documentation claims that `pass2.domain_range_policy` is read and exposed as `config.PASS2_DOMAIN_RANGE_POLICY`, but the repository has no such configuration constant or policy implementation, so adding the documented key currently has no effect.
**Triggers:** When this documentation is merged without the companion implementation being available in the same released codebase.
**Suggested fix:** Merge the implementation that reads and applies the setting before documenting it, or describe the key as unreleased and point to the required implementation version.
</issue_to_address>
### Comment 2
<location path="docs/architecture.md" line_range="349" />
<code_context>
+`_apply_domain_range_policy` runs in `_extract_chunk` after `_normalize_scalars`, on both the first attempt and the retry:
+
+- **`off`** — no-op.
+- **`warn`** (default) — an edge whose endpoint types match `(range, domain)` exactly is swapped (logged). Remaining violators are kept and tagged `domain_range_violation: true`, which reaches `edge_metadata.json` / `edges.jsonl` via the assembler's deepcopy of the first occurrence.
+- **`strict`** — same swap, then `validate_extraction` reports remaining violations as errors, triggering the existing single LLM retry with those errors as feedback. If the retry still violates, `_partial_recover` drops the violating edges *before* its hallucinated-anchor pass, so their anchor nodes are cleaned up too. Both pieces are required: `validate_extraction` only reports; `_partial_recover` is the only place that enforces.
+
</code_context>
<issue_to_address>
**issue (broader_impact):** A domain/range violation flag from a later occurrence of a duplicate edge is discarded when the assembler's first occurrence is clean, because edge deduplication deep-copies only the first occurrence and does not merge this top-level flag; the violation therefore does not reliably reach `edge_metadata.json` or `edges.jsonl`.
**Triggers:** When the same `(type, from, to)` edge is extracted in multiple files or chunks and the first occurrence does not violate domain/range while a later occurrence does.
**Suggested fix:** Merge `domain_range_violation` across all edge occurrences with an OR operation, or store it in a field that the deduplication merge logic explicitly preserves.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: docs/architecture.md:344, docs/architecture.md:349
|
|
||
| After each LLM call, the pipeline validates the response: edges whose type is not in the schema are rejected, as are edges that reference node IDs not present in the same extraction. Any node that exists solely to anchor a rejected edge is also dropped. Missing attributes are backfilled with a null value and zero confidence — they are never silently omitted. | ||
|
|
||
| **Optional domain/range check (`pass2.domain_range_policy`).** Historically Pass 2 validated only edge type, `from`/`to` node IDs and confidence; a property's `domain`/`range` were prompt hints. The `pass2.domain_range_policy` key (`off` | `warn` | `strict`, default `warn`, exposed as `config.PASS2_DOMAIN_RANGE_POLICY`) adds an inheritance-aware check: endpoint types come from the response's nodes plus `prior_nodes`, and a subclass (walking each concept's `parent` chain) satisfies a domain or range. Edges whose property or endpoint type is unknown are left to the existing checks. The key is read but deliberately not surfaced in either `mykg_config.yaml` (same precedent as `llm.temperature_unsupported_prefixes`); opt in by adding it under a profile's `pass2:` block. An invalid value logs a warning and falls back to `warn`. |
There was a problem hiding this comment.
issue: The documentation claims that pass2.domain_range_policy is read and exposed as config.PASS2_DOMAIN_RANGE_POLICY, but the repository has no such configuration constant or policy implementation, so adding the documented key currently has no effect.
Triggers: When this documentation is merged without the companion implementation being available in the same released codebase.
Suggested fix: Merge the implementation that reads and applies the setting before documenting it, or describe the key as unreleased and point to the required implementation version.
| `_apply_domain_range_policy` runs in `_extract_chunk` after `_normalize_scalars`, on both the first attempt and the retry: | ||
|
|
||
| - **`off`** — no-op. | ||
| - **`warn`** (default) — an edge whose endpoint types match `(range, domain)` exactly is swapped (logged). Remaining violators are kept and tagged `domain_range_violation: true`, which reaches `edge_metadata.json` / `edges.jsonl` via the assembler's deepcopy of the first occurrence. |
There was a problem hiding this comment.
issue (broader_impact): A domain/range violation flag from a later occurrence of a duplicate edge is discarded when the assembler's first occurrence is clean, because edge deduplication deep-copies only the first occurrence and does not merge this top-level flag; the violation therefore does not reliably reach edge_metadata.json or edges.jsonl.
Triggers: When the same (type, from, to) edge is extracted in multiple files or chunks and the first occurrence does not violate domain/range while a later occurrence does.
Suggested fix: Merge domain_range_violation across all edge occurrences with an OR operation, or store it in a field that the deduplication merge logic explicitly preserves.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Abandoned: domain/range policy feature dropped. |
Documents the new
pass2.domain_range_policykey (off | warn | strict, default warn) in docs/architecture.md alongside Pass 2 validation. Docs-only; companion to the implementation PR. (CLAUDE.md D60 is gitignored, so it was updated locally only.)🤖 Generated with Claude Code
Summary by Sourcery
Documentation: