Skip to content

Commit 387bcba

Browse files
author
Mateusz
committed
Typed contracts boundary checking; assorted fixes
1 parent 7a52648 commit 387bcba

File tree

57 files changed

+8825
-5801
lines changed

Some content is hidden

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

57 files changed

+8825
-5801
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ When working on specs, the user will invoke `/kiro:*` commands. Follow the instr
7979
| Test (Integration) | `./.venv/Scripts/python.exe -m pytest tests/integration` |
8080
| **Lint/Fix** | `./.venv/Scripts/python.exe -m ruff check --fix .` |
8181
| **Format** | `./.venv/Scripts/python.exe -m black .` |
82+
| **Boundary Type Check** | `./.venv/Scripts/python.exe dev/scripts/check_boundary_types.py` |
8283
| **Inspect CBOR wire captures** | `./.venv/Scripts/python.exe scripts/inspect_cbor_capture.py <file> --detect-issues` |
8384

8485
## Quality & Testing Standards

dev/boundary_types_allowlist.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"version": "1.0",
3+
"description": "Time-bounded exceptions for boundary type violations. Entries expire and must be renewed or violations fixed.",
4+
"entries": [
5+
{
6+
"file": "src/connectors/base.py",
7+
"symbol": "chat_completions",
8+
"violation": "dict[str, Any]",
9+
"reason": "Legacy connector API compatibility. Will be hardened in Phase 1 with canonical connector API.",
10+
"expires_at": "2026-06-30T00:00:00Z",
11+
"tracking": "typed-contracts-boundary-hardening Phase 1"
12+
},
13+
{
14+
"file": "src/connectors/base.py",
15+
"symbol": "chat_completions",
16+
"violation": "Any-in-signature",
17+
"reason": "Legacy connector cancellation coordinator. Will be hardened in Phase 1 with typed ISessionCancellationCoordinator.",
18+
"expires_at": "2026-06-30T00:00:00Z",
19+
"tracking": "typed-contracts-boundary-hardening Phase 1"
20+
},
21+
{
22+
"file": "src/core/interfaces/response_processor_interface.py",
23+
"symbol": "process_response",
24+
"violation": "Any-in-signature",
25+
"reason": "Accepts raw provider-specific LLM responses before normalization. This is internal processing, not boundary-carried data.",
26+
"expires_at": "2026-06-30T00:00:00Z",
27+
"tracking": "typed-contracts-boundary-hardening Phase 2"
28+
},
29+
{
30+
"file": "src/core/interfaces/response_processor_interface.py",
31+
"symbol": "process",
32+
"violation": "Any-in-signature",
33+
"reason": "Middleware interface accepts raw responses/chunks for processing. Internal processing boundary, not cross-layer contract exchange.",
34+
"expires_at": "2026-06-30T00:00:00Z",
35+
"tracking": "typed-contracts-boundary-hardening Phase 2"
36+
},
37+
{
38+
"file": "src/core/interfaces/response_processor_interface.py",
39+
"symbol": "process_non_streaming",
40+
"violation": "Any-in-signature",
41+
"reason": "Feature middleware accepts raw responses for processing. Internal processing boundary.",
42+
"expires_at": "2026-06-30T00:00:00Z",
43+
"tracking": "typed-contracts-boundary-hardening Phase 2"
44+
},
45+
{
46+
"file": "src/core/interfaces/response_processor_interface.py",
47+
"symbol": "process_streaming",
48+
"violation": "Any-in-signature",
49+
"reason": "Feature middleware accepts raw chunks for processing. Internal processing boundary.",
50+
"expires_at": "2026-06-30T00:00:00Z",
51+
"tracking": "typed-contracts-boundary-hardening Phase 2"
52+
},
53+
{
54+
"file": "src/core/domain/usage_summary.py",
55+
"symbol": "from_dict",
56+
"violation": "dict[str, Any]",
57+
"reason": "JSON deserialization method. Accepts dict[str, Any] from JSON parsing, validates and converts to typed contract.",
58+
"expires_at": "2026-06-30T00:00:00Z",
59+
"tracking": "typed-contracts-boundary-hardening - serialization methods"
60+
},
61+
{
62+
"file": "src/core/domain/usage_summary.py",
63+
"symbol": "to_dict",
64+
"violation": "dict[str, Any]",
65+
"reason": "JSON serialization method. Returns dict[str, Any] for JSON serialization compatibility.",
66+
"expires_at": "2026-06-30T00:00:00Z",
67+
"tracking": "typed-contracts-boundary-hardening - serialization methods"
68+
},
69+
{
70+
"file": "src/core/domain/usage_summary.py",
71+
"symbol": "to_legacy_dict",
72+
"violation": "dict[str, Any]",
73+
"reason": "Legacy serialization method for backward compatibility. Returns dict[str, Any] for JSON serialization.",
74+
"expires_at": "2026-06-30T00:00:00Z",
75+
"tracking": "typed-contracts-boundary-hardening - serialization methods"
76+
},
77+
{
78+
"file": "src/core/domain/request_context.py",
79+
"symbol": "get_modification_summary",
80+
"violation": "dict[str, Any]",
81+
"reason": "Returns summary dict for logging/debugging. Internal diagnostic method, not cross-layer contract.",
82+
"expires_at": "2026-06-30T00:00:00Z",
83+
"tracking": "typed-contracts-boundary-hardening - diagnostic methods"
84+
},
85+
{
86+
"file": "src/core/transport/fastapi/adapters/protocols.py",
87+
"symbol": "normalize",
88+
"violation": "dict[str, Any]",
89+
"reason": "Accepts provider-specific usage formats before normalization. Internal processing, converts to canonical format.",
90+
"expires_at": "2026-06-30T00:00:00Z",
91+
"tracking": "typed-contracts-boundary-hardening Phase 2"
92+
},
93+
{
94+
"file": "src/core/transport/fastapi/adapters/protocols.py",
95+
"symbol": "merge_streaming_usage",
96+
"violation": "dict[str, Any]",
97+
"reason": "Accepts provider-specific usage formats for merging. Internal processing, converts to canonical format.",
98+
"expires_at": "2026-06-30T00:00:00Z",
99+
"tracking": "typed-contracts-boundary-hardening Phase 2"
100+
},
101+
{
102+
"file": "src/core/transport/fastapi/adapters/protocols.py",
103+
"symbol": "inject_reasoning",
104+
"violation": "Any-in-signature",
105+
"reason": "Accepts provider-specific content formats before normalization. Internal processing boundary.",
106+
"expires_at": "2026-06-30T00:00:00Z",
107+
"tracking": "typed-contracts-boundary-hardening Phase 2"
108+
},
109+
{
110+
"file": "src/core/transport/fastapi/adapters/protocols.py",
111+
"symbol": "build_streaming_payload",
112+
"violation": "Any-in-signature",
113+
"reason": "Accepts provider-specific content formats before normalization. Internal processing boundary.",
114+
"expires_at": "2026-06-30T00:00:00Z",
115+
"tracking": "typed-contracts-boundary-hardening Phase 2"
116+
},
117+
{
118+
"file": "src/core/transport/fastapi/adapters/protocols.py",
119+
"symbol": "inject_headers",
120+
"violation": "Any-in-signature",
121+
"reason": "Accepts canonical_usage as Any for backward compatibility. Will be hardened to UsageSummary in Phase 2.",
122+
"expires_at": "2026-06-30T00:00:00Z",
123+
"tracking": "typed-contracts-boundary-hardening Phase 2"
124+
},
125+
{
126+
"file": "src/core/transport/fastapi/adapters/protocols.py",
127+
"symbol": "sanitize",
128+
"violation": "Any-in-signature",
129+
"reason": "JSON sanitization accepts any content type for conversion. Internal processing boundary.",
130+
"expires_at": "2026-06-30T00:00:00Z",
131+
"tracking": "typed-contracts-boundary-hardening Phase 2"
132+
},
133+
{
134+
"file": "src/core/transport/fastapi/adapters/protocols.py",
135+
"symbol": "schedule_capture",
136+
"violation": "Any-in-signature",
137+
"reason": "Accepts raw response content and context for capture. Internal capture boundary, not cross-layer contract exchange.",
138+
"expires_at": "2026-06-30T00:00:00Z",
139+
"tracking": "typed-contracts-boundary-hardening Phase 2"
140+
}
141+
]
142+
}

dev/boundary_types_scope.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "1.0",
3+
"description": "Phase 0/1 boundary surface enforcement scope - signature-first, explicit file pinning. Phase 1 adds connector contracts.",
4+
"explicit_files": [
5+
"src/connectors/base.py",
6+
"src/core/interfaces/response_processor_interface.py",
7+
"src/core/transport/fastapi/adapters/protocols.py",
8+
"src/core/domain/responses.py",
9+
"src/core/domain/request_context.py",
10+
"src/core/domain/backend_target.py",
11+
"src/core/domain/usage_summary.py",
12+
"src/core/domain/streaming/contracts.py"
13+
],
14+
"include_globs": [
15+
"src/connectors/contracts/**/*.py"
16+
],
17+
"exclude_globs": []
18+
}

0 commit comments

Comments
 (0)