Skip to content

Commit 567229f

Browse files
committed
feat(ka): add governed decision capability batch
1 parent 0d7acc6 commit 567229f

43 files changed

Lines changed: 1929 additions & 328 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
## [Unreleased]
2727

2828
### Added
29+
- **Phase 18 CP18-C governed-decision Batch 03**: restored eight deterministic,
30+
read-only capabilities for context selection, intent clarification, knowledge
31+
promotion admission, simulation cost/budget admission, cross-instance
32+
agreement, reasoning anomaly measurement, and explainability coverage. The
33+
authority advances to 148 implementations/65 gaps, the KA suite passes 517
34+
tests, and all duplicate, collision, unclassified, and honesty gates pass.
2935
- **Phase 18 CP18-C restored-analysis Batch 02**: restored eight distinct
3036
original-design capabilities under their collision-free canonical IDs:
3137
Pareto optimization, norm emergence detection, cross-modal evidence

HANDOFF.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| Last reviewed | 2026-07-25 |
1818
| Next-review trigger | Every checkpoint, handoff, blocker, or release-decision change |
1919
| Requirements and evidence | Active plan, open-work ledger, and `reports/production-readiness/2026/` |
20-
| Active plan | `PRODUCTION_COMPLETION_PLAN_2026.md` v1.27.0 |
20+
| Active plan | `PRODUCTION_COMPLETION_PLAN_2026.md` v1.28.0 |
2121
| Completed phase | Object-store Replacement Control; SeaweedFS selected for rebuilt installed qualification |
2222
| Current phase | Phase 18 Knowledge Algorithm production completion; CP18-C active |
2323
| Release verdict | Production/public release: **NO-GO** |
@@ -83,6 +83,12 @@ implementation progress advances to 140 real sources and 73 gaps. The full KA
8383
suite passes 493 tests, and duplicate collisions, unresolved duplicates,
8484
unclassified surfaces, and static honesty flags remain zero.
8585

86+
CP18-C Batch 03 passed for eight governed decision-support KAs. They make
87+
read-only context, intent, promotion, simulation-budget, consensus, anomaly,
88+
and explainability-coverage decisions without starting work or claiming truth.
89+
The authority is now 148 implementations/65 gaps and the KA suite is 517
90+
passed; no duplicate, collision, unclassified, or honesty finding remains.
91+
8692
Baseline evidence:
8793
`reports/production-readiness/2026/phase-18/baseline-and-plan.md`.
8894

@@ -701,9 +707,9 @@ replacement. See
701707
## Exact next action
702708

703709
1. Continue Phase 18 CP18-C against the approved 213-capability manifest:
704-
Batches 01-02 qualified 11 existing implementations and restored eight
710+
Batches 01-03 qualified 11 existing implementations and restored 16
705711
missing capabilities; qualify the remaining existing implementations and
706-
build the 73 explicit gaps in semantic batches
712+
build the 65 explicit gaps in semantic batches
707713
with strict schemas, limits, failure behavior, and authoritative
708714
effect/service integration.
709715
2. Preserve canonical IDs and behavior until parity proof permits each

PRODUCTION_COMPLETION_PLAN_2026.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Field | Value |
66
|---|---|
7-
| Document version | v1.27.0 |
7+
| Document version | v1.28.0 |
88
| Plan date | 2026-07-12 |
99
| Status | Active production completion program |
1010
| Product target | Local-first Windows 11 x64 governed LLM middleware with a desktop control, administration, audit, and validation application |
@@ -258,6 +258,15 @@ or static honesty flags. The full KA suite passes 493 tests. The authority gates
258258
now enforce monotonic implementation progress from the CP18-A/CP18-B baselines
259259
instead of freezing their old implementation/gap counts.
260260

261+
CP18-C Batch 03 passed on 2026-07-25 for eight governed decision-support
262+
capabilities covering context selection, intent clarification, knowledge
263+
promotion admission, simulation cost/budget admission, cross-instance
264+
agreement, reasoning anomaly measurement, and explainability coverage. All are
265+
bounded, deterministic, read-only, individually tested, and explicit about
266+
measurement/inference limitations. The authority advances to 148
267+
implementations and 65 gaps; the full KA suite passes 517 tests and all
268+
no-duplicate, collision, honesty, and classification gates remain clean.
269+
261270
## 1. Purpose
262271

263272
This plan defines the complete program required to finish DataLogicEngine as a
@@ -4008,17 +4017,17 @@ artifact rather than against a known-incomplete subsystem.
40084017
record.
40094018

40104019
**Checkpoint status 2026-07-25:** CP18-A and CP18-B passed. CP18-C Batches 01
4011-
and 02 also passed: 11 existing implementations were made honest and eight
4020+
through 03 also passed: 11 existing implementations were made honest and 16
40124021
preserved capabilities were restored as distinct production sources. The
4013-
authority now reports 140 implementations and 73 gaps with 493 KA tests passing
4022+
authority now reports 148 implementations and 65 gaps with 517 KA tests passing
40144023
and no duplicate, unclassified, or static-honesty finding. The approved
40154024
capability authority is
40164025
`reports/production-readiness/2026/phase-18/ka-capability-crosswalk.json`.
40174026
`scripts/verify_ka_capability_inventory.py` and
40184027
`scripts/verify_ka_runtime_authority.py` enforce the deduplicated identity and
40194028
single-runtime boundaries. Batch evidence is under
40204029
`reports/production-readiness/2026/phase-18/`, including
4021-
`cp18-c-batch-02-restored-analysis.json`.
4030+
`cp18-c-batch-03-governed-decisions.json`.
40224031
CP18-C is active; CP18-C through CP18-H remain open, and the signed rebuild
40234032
remains blocked.
40244033

@@ -4433,8 +4442,8 @@ exit gate.
44334442
## 33. Immediate next action
44344443

44354444
Continue Phase 18 CP18-C against the approved 213-capability manifest. Batches
4436-
01-02 have qualified 11 existing implementations and restored eight gaps;
4437-
qualify the remaining existing implementations and build the 73 explicit gaps
4445+
01-03 have qualified 11 existing implementations and restored 16 gaps; qualify
4446+
the remaining existing implementations and build the 65 explicit gaps
44384447
in validated batches. Replace every placeholder, metadata-only facade, mock/simulated
44394448
operation, weak or unrecorded random default, and false success with bounded
44404449
typed production behavior or an honest prerequisite failure through an

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ administration, audit, observability, and validation application.
6767
> 493-test KA suite passes, implementation progress is 140/213 with 73 gaps,
6868
> and the no-duplicate authority remains clean. CP18-C is active for the
6969
> remaining implementation
70-
> completion. Phase 18 will finish production implementations and application
70+
> completion. Batch 03 adds eight governed decision-support KAs, advancing the
71+
> verified authority to 148 implementations/65 gaps and 517 passing KA tests.
72+
> Phase 18 will finish production implementations and application
7173
> wiring, and require one named functional test per canonical KA before rebuild.
7274
> The completed checkpoint passes 2,192 backend tests with 18 skips, all 422
7375
> frontend tests, frontend lint/typecheck/production build, the CI Ruff rules,
@@ -154,9 +156,9 @@ Current production-completion focus:
154156
Python/TypeScript SDK catalogs/clients, and compatibility adapters; 132
155157
implementation sources have unique canonical owners, the 81 gaps are explicit,
156158
and duplicate canonical collisions are zero
157-
- Phase 18 CP18-C Batches 01-02 passed: 11 existing implementations qualified,
158-
eight distinct missing capabilities restored, 140 implementations/73 gaps,
159-
493 KA tests passing, and zero duplicate or static-honesty findings; CP18-C
159+
- Phase 18 CP18-C Batches 01-03 passed: 11 existing implementations qualified,
160+
16 distinct missing capabilities restored, 148 implementations/65 gaps,
161+
517 KA tests passing, and zero duplicate or static-honesty findings; CP18-C
160162
remains active and the release-candidate rebuild remains paused through CP18-G
161163
- Production behavior, dynamic application call path, and one individually
162164
named functional test for every canonical KA

TODO.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| Last reviewed | 2026-07-25 |
1818
| Next-review trigger | Phase checkpoint, blocker disposition, or release-decision change |
1919
| Requirements and evidence | Active plan and `reports/production-readiness/2026/` |
20-
| Active plan | `PRODUCTION_COMPLETION_PLAN_2026.md` v1.27.0 |
20+
| Active plan | `PRODUCTION_COMPLETION_PLAN_2026.md` v1.28.0 |
2121
| Completed phase | Object-store Replacement Control; SeaweedFS selected for rebuilt installed qualification |
2222
| Current phase | Phase 18 Knowledge Algorithm production completion; CP18-C active |
2323
| Release decision | Production/public release: **NO-GO** |
@@ -66,7 +66,11 @@ catalog-only.
6666
and individually named semantic tests. The authority advances to 140
6767
implementations and 73 gaps, and the full KA suite passes 493 tests
6868
with zero duplicate, collision, unclassified, or static-honesty finding.
69-
- [ ] Qualify the remaining existing implementations, build the 73 remaining
69+
- [x] Batch 03 restored eight governed decision-support capabilities with
70+
strict schemas, read-only decisions, explicit limitations, and named
71+
tests. The authority advances to 148 implementations and 65 gaps; 517
72+
KA tests pass with all no-duplicate and honesty gates clean.
73+
- [ ] Qualify the remaining existing implementations, build the 65 remaining
7074
implementation gaps, and connect effect proposals to authoritative
7175
service application/receipt paths.
7276
- [ ] **CP18-D — dynamic integration:** give every canonical KA a real selector
@@ -740,7 +744,7 @@ Details: `reports/production-readiness/2026/phase-15/deferred-gates.md`.
740744
| 15 | System qualification and release candidate | **Release-candidate engineering checkpoint complete 2026-07-14; installed/signed exit gates retained** |
741745
| 16 | Production documentation replacement and professional review dossier | **CP16-F replacement closure complete 2026-07-15; CP16-G exact-artifact binding and signed/manual/external exits retained** |
742746
| 17 | Documentation consolidation and release lock | **CP17-A through CP17-D complete 2026-07-15; CP17-E retained for clean signed installed walkthrough** |
743-
| 18 | Knowledge Algorithm production completion and dynamic integration | **Active; CP18-A/CP18-B and CP18-C Batches 01-02 passed 2026-07-25, CP18-C in progress at 140 implementations/73 gaps** |
747+
| 18 | Knowledge Algorithm production completion and dynamic integration | **Active; CP18-A/CP18-B and CP18-C Batches 01-03 passed 2026-07-25, CP18-C in progress at 148 implementations/65 gaps** |
744748
| 19 | Production launch and maintenance | Blocked by prior phases |
745749

746750
## Release blockers retained across phases
@@ -759,8 +763,8 @@ Details: `reports/production-readiness/2026/phase-15/deferred-gates.md`.
759763
## Exact next action
760764

761765
Continue Phase 18 CP18-C against the approved 213-capability manifest. Batches
762-
01-02 qualified 11 existing implementations and restored eight gaps; qualify
763-
the remaining existing implementations and build the 73 explicit gaps without
766+
01-03 qualified 11 existing implementations and restored 16 gaps; qualify
767+
the remaining existing implementations and build the 65 explicit gaps without
764768
duplicate identities, private runtimes, placeholders, false effects, or
765769
capability loss. Every batch must add strict contracts, limits, failure
766770
semantics, authoritative service integration where applicable, and focused
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"""KA-1072: deterministic context selection under a declared token budget."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Any
6+
7+
from pydantic import BaseModel, ConfigDict, Field, model_validator
8+
9+
from core.knowledge_algorithm.ka_base import KnowledgeAlgorithm
10+
11+
12+
class ContextElement(BaseModel):
13+
model_config = ConfigDict(extra="forbid")
14+
15+
element_id: str = Field(min_length=1, max_length=200)
16+
token_count: int = Field(ge=1, le=200_000)
17+
relevance: float = Field(ge=0, le=1)
18+
priority: float = Field(default=1, ge=0, le=10)
19+
required: bool = False
20+
content_ref: str | None = Field(default=None, max_length=2_000)
21+
22+
23+
class KA1072Input(BaseModel):
24+
model_config = ConfigDict(
25+
extra="forbid",
26+
json_schema_extra={
27+
"examples": [
28+
{
29+
"context_elements": [
30+
{
31+
"element_id": "policy",
32+
"token_count": 200,
33+
"relevance": 1,
34+
"required": True,
35+
},
36+
{
37+
"element_id": "history",
38+
"token_count": 500,
39+
"relevance": 0.7,
40+
},
41+
],
42+
"token_budget": 600,
43+
}
44+
]
45+
},
46+
)
47+
48+
context_elements: list[ContextElement] = Field(
49+
min_length=1,
50+
max_length=2_000,
51+
)
52+
token_budget: int = Field(ge=1, le=2_000_000)
53+
54+
@model_validator(mode="after")
55+
def validate_ids(self) -> KA1072Input:
56+
ids = [item.element_id for item in self.context_elements]
57+
if len(ids) != len(set(ids)):
58+
raise ValueError("context element IDs must be unique")
59+
return self
60+
61+
62+
class KA1072ContextWindowOptimizer(KnowledgeAlgorithm):
63+
"""Select required then highest utility-density context elements."""
64+
65+
input_schema = KA1072Input
66+
67+
def __init__(self, context: dict[str, Any]):
68+
super().__init__(context, None, None, None)
69+
self.ka_id = "KA-1072"
70+
71+
def _run_logic(self, input_data: KA1072Input) -> dict[str, Any]:
72+
required = sorted(
73+
(item for item in input_data.context_elements if item.required),
74+
key=lambda item: item.element_id,
75+
)
76+
required_tokens = sum(item.token_count for item in required)
77+
if required_tokens > input_data.token_budget:
78+
return {
79+
"success": False,
80+
"status": "required_context_exceeds_budget",
81+
"required_tokens": required_tokens,
82+
"token_budget": input_data.token_budget,
83+
"required_element_ids": [item.element_id for item in required],
84+
}
85+
optional = sorted(
86+
(item for item in input_data.context_elements if not item.required),
87+
key=lambda item: (
88+
-((item.relevance * item.priority) / item.token_count),
89+
-item.relevance,
90+
item.token_count,
91+
item.element_id,
92+
),
93+
)
94+
selected = list(required)
95+
remaining = input_data.token_budget - required_tokens
96+
excluded: list[dict[str, Any]] = []
97+
for item in optional:
98+
if item.token_count <= remaining:
99+
selected.append(item)
100+
remaining -= item.token_count
101+
else:
102+
excluded.append(
103+
{
104+
"element_id": item.element_id,
105+
"reason": "token_budget",
106+
}
107+
)
108+
selected_ids = {item.element_id for item in selected}
109+
ordered = [
110+
item.element_id
111+
for item in input_data.context_elements
112+
if item.element_id in selected_ids
113+
]
114+
return {
115+
"success": True,
116+
"status": "context_selected",
117+
"selected_element_ids": ordered,
118+
"selected_token_count": (input_data.token_budget - remaining),
119+
"remaining_tokens": remaining,
120+
"excluded": excluded,
121+
"selection_method": "required_then_utility_density",
122+
"deterministic": True,
123+
"limitations": (
124+
"Utility density is a bounded deterministic heuristic, not a "
125+
"proof of globally optimal semantic context."
126+
),
127+
}
128+
129+
130+
def run(context: dict[str, Any]) -> dict[str, Any]:
131+
return KA1072ContextWindowOptimizer(context).run(context)

0 commit comments

Comments
 (0)