# Unify framing and JSON adapters and use checked response serialization Task ID: T-PROTOCOL-005 Role: sol_implementer Status: READY ## 1. Context and baseline Repository /home/faumaray/Projects/VoidLanguageServer on feat/implement-roadmap, base ca04975. The bootstrap vls namespace has known working framing/lifecycle behavior. The new untracked Void::LanguageServer::Protocol duplicated that adapter before checked StrictJson serialization landed on main 7d7d23e. Source ownership was released by the original writer. T-PLAN-002 and the preflight direct one canonical implementation. ## 2. Objective and deliverables Expose one implementation of checked framing/JSON helpers and preserve compatibility for existing vls consumers. Make all response encoding failures explicit and use upstream serializer. Provide tests of escaping, round-trip, depth/UTF-8 and failure behavior. Root owns stdio dispatch and integration. ## 3. Scope and non-goals Protocol adapter and narrow compatibility headers only. Numeric exactness needs raw token metadata that current upstream lacks. Preserve existing request_id behavior on currently representable inputs, carry an explicitly open upstream gate and keep the new raw-wire regressions enabled. Do not develop a second JSON/decimal parser. ## 4. Files to inspect Read include/{vls,Void/LanguageServer/Protocol}/{Json,Framing}.hpp and their source implementations, src/Server.cpp and tests/{FramingTests,JsonTests,LifecycleTests,JsonCapabilities}.cpp, docs/roadmap/02-lsp-protocol-lifecycle.md. Compare the actual upstream parse and checked serialize in build/bootstrap/_deps/voidlibrary-src/include/Void/Data/StrictJson.hpp. Inspect CMakeLists.txt and T-NATIVE-001 for target ownership. ## 5. Write ownership and coordination Write scope: include/Void/LanguageServer/Protocol; src/Protocol; include/vls/Framing.hpp; include/vls/Json.hpp; src/Framing.cpp; src/Json.cpp; tests/ProtocolEncodingTests.cpp No edits to build.cpp or CMake, existing suites, Server.hpp/cpp or sibling checkouts. Other agents share the branch and handle these paths. Keep old implementation paths usable until root wires both builds, and arrange final removal of dead forwarding translation units with root. ## 6. Implementation or investigation approach Compare the two adapters and choose the canonical behavior covered by the bootstrap. Replace the custom serializer with StrictJson::serialize and convert its error type into an explicit error result. Retain ingress validation/depth bounds. Keep IDs signed-32-bit integer or string and preserve checks on numeric decoded values. For unrepresentable exact tokens, coordinate against the upstream gate instead of guessing. Compatibility headers import canonical types/functions without copying algorithms. Give root the interfaces needed to create typed JSON responses. Preserve exact frame size/input handling; mark any new egress limit or failure contract for caller. ## 7. Interfaces and data contracts Canonical Json and RequestId keep their current types on upstream main. serialize_json(const Json&, std::size_t maximum_depth = 64) returns std::expected. Keep Protocol helpers find_member/as_object/as_array/as_string/as_bool/as_int64/as_uint32 for other slices, with checked type/range semantics. FrameLimits defaults to 8192 and 16777216. Expose public API for checked envelope egress. One implementation is linked per executable. If preserving legacy quote_json/encode_id as wrappers until root rewires server, document the migration and do not silently fabricate data. ## 8. Dependencies and integration Root serializes build definitions and actual error/result dispatch. Native migration is in progress. To keep it buildable, use a staged migration with root; avoid deleting definitions while their only target still references the old files. Hand off canonical source list and precise switch steps. The formal JSON exactness fix requires upstream release/override verification. Docs/workspace tests are disjoint. ## 9. Edge cases security and performance Invalid UTF-8 object keys/values, nonfinite manually constructed doubles and over-depth values must return an error and produce no partial protocol frame. Before/after framing boundaries must match including CRLF and clean EOF. Keep JSON handling bounded and avoid reparsing serialized request IDs. Preserve tested stdio behavior and document any remaining legacy transitional limitations. ## 10. Acceptance criteria 1. Canonical namespace and vls source-compatibility resolve to one set of framing/JSON definitions after root integration. 2. Checked serialization propagates upstream failures and round-trips complex valid values including decimal numbers, controls and escaped data. 3. All original framing/lifecycle/ID cases retain behavior. The known precision/range failures remain visible until upstream resolves them. Actual failures and registration evidence are returned. 4. Expose unambiguous checked egress and typed ID helpers for root's Server integration. ## 11. Verification commands and evidence Root has used dev cpp-gcc -c cmake --build build/bootstrap --parallel 2 and dev cpp-gcc -c ctest --test-dir build/bootstrap --output-on-failure. For an isolated focused binary, use dev cpp-gcc -c g++ -std=c++26 -freflection -Iinclude -Ibuild/bootstrap/_deps/voidlibrary-src/include with your canonical sources/tests, using observed Void::Testing archives in build/vbs-framework-probe or the existing bootstrap tree. Put artifacts under build/protocol-check. Test with --list --no-color and actual filtered bodies. Format owned files only. ## 12. Constraints and stop conditions Stop before writing other workers' build or session files and before changing numeric semantics without evidence. If a proposed signature breaks a consumer contact root with locations and the narrowest remedy. Stop after two unsuccessful repairs of the same defect and return evidence. No per-dependency source patches in this task. ## 13. Authorization and decisions D-021, D-022, D-024, D-025, D-026 and D-027. Protocol cleanup is within requested implementation and user approved continuation from the existing files. Use GPT-6.2 Sol at Max for this package after fresh preflight. No external writes, staging, commits or global settings. ## 14. Return format Return T-PROTOCOL-005 DONE/PARTIAL/BLOCKED, source paths, signatures/integration steps, commands and exit codes, case counts, original vs new coverage, any observed limitation and required wiring. No children or user messages. Fresh preflight found that StrictJson::serialize(maximumDepth=64) can admit the 65th empty container, whereas VLS ingress counts every container opening. Make egress and ingress agree at 64, including empty containers and root scalars at depth 0. Keep this bounded even for arbitrarily deep in-memory values. Switch legacy/new headers, sources and build wiring in one coordinated root integration.