Orchestrata Ultimate › Tests › Reference › knowledge_graph › context_pack
Tests reference — tests/knowledge_graph/context_pack
tests/knowledge_graph/context_pack — 6 test modules, 57 test functions. Source tree: tests/knowledge_graph/context_pack at commit 8a2cb42ad. Generated from the tests AST snapshot by scripts/gen-data-pages.py.
Prose pending.
Modules
| Module | Tests | Covers |
|---|---|---|
conftest.py |
0 | 0 |
test_cache.py |
6 | 4 |
test_frame.py |
12 | 3 |
test_packer.py |
9 | 6 |
test_relevance.py |
19 | 5 |
test_selector.py |
11 | 4 |
Module details
tests/knowledge_graph/context_pack/conftest.py
source · 0 tests · 135 lines
Shared fixtures for SPEC-106 context_pack tests.
tests/knowledge_graph/context_pack/test_cache.py
source · 6 tests · 62 lines
Tests for
knowledge_graph.context_pack.cache.
Covers: knowledge_graph.context_injector, knowledge_graph.context_pack.cache, knowledge_graph.context_pack.frame, knowledge_graph.context_pack.packer
| Kind | Name | Line | Description |
|---|---|---|---|
| class | TestContextPackCache |
23 | |
| method | TestContextPackCache.test_cache_stores_and_retrieves_rendered_pack |
24 | |
| method | TestContextPackCache.test_cache_miss_for_different_snapshot |
32 | |
| method | TestContextPackCache.test_cache_miss_for_different_task_type |
37 | |
| method | TestContextPackCache.test_cache_expires_after_ttl |
43 | |
| method | TestContextPackCache.test_cache_invalidate_clears_all_entries |
49 | |
| method | TestContextPackCache.test_cache_does_not_store_empty_render_or_empty_snapshot |
58 |
tests/knowledge_graph/context_pack/test_frame.py
source · 12 tests · 191 lines
Tests for knowledge_graph.context_pack.frame (SPEC-106 FR-002).
Covers: core.base.traces, knowledge_graph.context_injector, knowledge_graph.context_pack.frame
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_analyze_request_is_pure_function_of_text_and_graph |
24 | REQ-106-014: identical text + graph state -> identical RequestFrame. |
| function | test_exact_entity_match_class |
33 | A request token matching a Class's qualname links unambiguously. |
| function | test_normalized_case_underscore_dash_fold |
47 | REQ-106-012: case/underscore/dash-folded matching. |
| function | test_ambiguous_entity_kept_with_candidates |
67 | REQ-106-013: ambiguous matches are KEPT (not dropped/guessed). |
| function | test_entity_linking_project_qualified_id_via_properties |
82 | Ruling-2 ids ("{project}:{qualname}") link via name/qualified_name. |
| function | test_entity_linking_spec_requirement_volk |
116 | Spec/Requirement/Volk are linkable canonical labels (REQ-106-012). |
| function | test_explicit_task_type_overrides_classification |
129 | An explicit task_type= skips classification entirely. |
| function | test_task_type_classified_from_subject_payload |
143 | REQ-106-011: subject dict payload maps via SUBJECT_TASK_TYPE. |
| function | test_task_type_classified_from_free_text_keyword |
154 | A bare keyword in free text ("refactor") drives classification. |
| function | test_task_type_defaults_to_build_when_no_keyword_matches |
165 | No recognizable keyword -> documented BUILD default (a total function). |
| function | test_no_entities_linked_for_unrelated_text |
176 | Free text naming nothing in the graph links zero entities. |
| function | test_request_frame_is_a_frozen_dataclass_with_defaults |
187 | RequestFrame supports default construction (used by the CLI's fallback). |
tests/knowledge_graph/context_pack/test_packer.py
source · 9 tests · 230 lines
Tests for knowledge_graph.context_pack.packer (SPEC-106 FR-004).
Covers: core.base.traces, knowledge_graph.context_injector, knowledge_graph.context_pack.frame, knowledge_graph.context_pack.packer, knowledge_graph.context_pack.selector, memory.token_counter
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_budget_hard_ceiling_never_exceeded |
57 | REQ-106-030: a tight budget excludes lower-ranked nodes, never overspends. |
| function | test_greedy_packing_skips_a_miss_and_continues |
74 | Greedy-by-rank: a node that doesn't fit is skipped, not a hard stop. |
| function | test_empty_pack_with_reason |
100 | REQ-106-043: an explicit empty pack carries its degradation reason. |
| function | test_byte_stability_across_repeated_runs |
114 | REQ-106-034: same frame + same graph state -> byte-identical pack body. |
| function | test_provenance_present_per_section |
136 | REQ-106-033: every section carries node id, template, rank, token cost. |
| function | test_trim_and_revalidate |
160 | REQ-106-035: deleting a whole section keeps the pack valid, shrinks sections. |
| function | test_validate_pack_rejects_corrupted_section |
184 | A mangled provenance line (not a whole-section trim) fails validation. |
| function | test_validate_pack_rejects_empty_or_malformed_text |
204 | |
| function | test_perf_smoke_select_and_pack_p50_under_500ms |
210 | NFR: selection+packing p50 < 500ms against the live KG (small seeded graph). |
tests/knowledge_graph/context_pack/test_relevance.py
source · 19 tests · 576 lines
Tests for knowledge_graph.context_pack.relevance (SPEC-106 FR-006).
Covers: core.base.traces, knowledge_graph.context_injector, knowledge_graph.context_pack.relevance, knowledge_graph.context_pack.selector, knowledge_graph.context_pack/ (package)
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_refine_empty_subgraph_returns_empty_dict |
260 | An empty selection needs no projection at all — refine() is total. |
| function | test_refine_is_deterministic_across_calls |
268 | REQ-106-062: same subgraph + same task type => same tiers, every call. |
| function | test_refine_retracts_projected_facts_after_completion |
281 | REQ-106-064: dynamic predicates are empty once refine() returns. |
| class | TestRefineTaskTypeTiers |
151 | REQ-106-061: each task type's core_for rules, one seeded node per signal. |
| method | TestRefineTaskTypeTiers.test_build_promotes_defines_and_shares_requirement_to_core |
154 | |
| method | TestRefineTaskTypeTiers.test_refactor_promotes_defines_and_shares_requirement_to_core |
167 | |
| method | TestRefineTaskTypeTiers.test_document_promotes_defines_only_shares_requirement_is_related |
182 | DOCUMENT's core_for lacks the shares_requirement_with_root clause. |
| method | TestRefineTaskTypeTiers.test_debug_near_root_is_core_far_tested_unrelated_is_peripheral |
198 | |
| method | TestRefineTaskTypeTiers.test_test_promotes_tested_and_shares_requirement_to_core |
212 | |
| method | TestRefineTaskTypeTiers.test_review_promotes_tested_and_shares_requirement_to_core |
226 | |
| method | TestRefineTaskTypeTiers.test_review_ambiguous_guard_suppresses_tested_core_promotion |
241 | REVIEW's core_for requires \+ kg_ambiguous(N) alongside kg_tested. |
| class | TestRescoreByTier |
306 | Pure tests for :func:rescore_by_tier — no graph/Prolog required. |
| method | TestRescoreByTier.test_empty_tiers_leaves_order_identical |
314 | |
| method | TestRescoreByTier.test_core_outranks_related_outranks_peripheral_regardless_of_fr003_score |
325 | |
| method | TestRescoreByTier.test_tie_break_within_tier_preserves_fr003_score_then_node_id |
349 | |
| class | TestContextInjectorIntegration |
372 | The opt-in wiring through :meth:ContextInjector.inject_for_task. |
| method | TestContextInjectorIntegration.test_relevance_none_matches_pre_wiring_default |
376 | No behavior change (REQ-106-063): default vs. explicit relevance=None. |
| method | TestContextInjectorIntegration.test_wired_relevance_orders_core_nodes_before_peripheral |
399 | |
| class | TestRuntimeSignalRelevance |
444 | Tier-H runtime signals boost DEBUG relevance for recently touched nodes. |
| method | TestRuntimeSignalRelevance.test_debug_promotes_recently_mentioned_node_to_core |
447 | |
| method | TestRuntimeSignalRelevance.test_debug_promotes_failed_node_to_core |
478 | |
| method | TestRuntimeSignalRelevance.test_recent_signal_outside_window_does_not_promote |
505 | |
| method | TestRuntimeSignalRelevance.test_requirement_identity_unification_via_has_item |
533 | A node tracing to the parent Requirement shares relevance with a node |
tests/knowledge_graph/context_pack/test_selector.py
source · 11 tests · 233 lines
Tests for knowledge_graph.context_pack.selector (SPEC-106 FR-003).
Covers: core.base.traces, knowledge_graph.context_injector, knowledge_graph.context_pack.frame, knowledge_graph.context_pack.selector
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_no_linked_entities_returns_empty_subgraph |
31 | |
| function | test_refactor_template_walks_definess_containment |
40 | |
| function | test_review_template_also_reaches_traces_to |
53 | REVIEW expands both DEFINES and TRACES_TO (REQ-106-025 richest handler). |
| function | test_debug_template_k_hop_override_is_tighter_than_default |
64 | REQ-106-021: DEBUG's k=1 override excludes what REFACTOR's k=2 default includes. |
| function | test_node_without_canonical_key_is_skipped |
83 | A DEFINES-reachable node with neither id nor alias is silently skipped. |
| function | test_rank_ordering_uses_recency_signal |
93 | REQ-106-022: recency (updated_at) ranks a more-recent sibling higher. |
| function | test_rank_ordering_uses_tested_by_presence_signal |
108 | REQ-106-022: TESTED_BY presence ranks a tested sibling higher. |
| function | test_rank_tie_breaks_lexicographically_on_node_id |
122 | REQ-106-023: true ties (identical signals) break on node id, ascending. |
| function | test_ambiguous_root_entity_is_penalized_in_ranking |
137 | An ambiguous entity's candidate roots score lower than an unambiguous root. |
| function | test_build_template_expands_traces_and_structure_from_code_root |
168 | BUILD expands TRACES_TO and (since 2026-07-21) DEFINES containment. |
| function | test_ambiguous_candidates_do_not_expand_neighbors |
186 | Ambiguous candidates are retained hop-0 ONLY (2026-07-21). |