Add typed JSON navigation accessors (std.json.root/kind/get/at/len/string/int/float/bool)#125
Open
WalterGropius wants to merge 4 commits into
Open
Add typed JSON navigation accessors (std.json.root/kind/get/at/len/string/int/float/bool)#125WalterGropius wants to merge 4 commits into
WalterGropius wants to merge 4 commits into
Conversation
Register std.json.root/kind/get/at/len/string/int/float/bool with JsonNode and JsonKind builtin types so navigation over the existing arena tree type-checks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add the navigation accessors to the std helper table so they appear in zero graph --json with target-neutral support. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Navigate {"choices":[{"message":{"content":"hi\n"}}]} via the accessor
API and assert the unescaped string plus a \uXXXX surrogate-pair emoji.
Runs at host check level alongside std-platform-basics.0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add the navigation accessor table, a worked example, and a design note that native-exec lowering is deferred to the aggregate-ABI work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@WalterGropius is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses P0-5: introduces typed JSON navigation accessors so programs can traverse a parsed
JsonDocwithout re-tokenizing. Adds nine helpers —std.json.root,std.json.kind,std.json.get,std.json.at,std.json.len,std.json.string,std.json.int,std.json.float,std.json.bool— with full type signatures, graph metadata, a provider-shaped conformance fixture, and module docs.Acceptance is check-level. The aggregate-ABI codegen for the
JsonDoc/JsonNodevalue types is not delivered upstream, so direct native execution of these accessors is deferred (the new fixture surfaces the expectedCGEN004"direct backend local type is unsupported: JsonDoc" target-readiness blocker at lower stage whilecheckitself isok:true). No stubs were added; this is purely the typed surface + metadata, gated at check level exactly as the conformance harness expects.Source
Addresses P0-5; recovered after an agent stream-timeout; reproduced against main @ 3ec2d30. Branch rebased cleanly from the pre-Turborepo base onto main @ 3ec2d30 (the
docs-site/→docs/rename was tracked automatically; no conflicts).Changes
native/zero-c/src/checker.c— return type, arg count, and arg type entries for the 9std.json.*accessors; registerJsonNodeandJsonKindas builtin type names.native/zero-c/src/main.c— surface the 9 accessors in thestd_helpers[]graph-metadata table (target-neutral, allocation facts).conformance/native/pass/std-json-nav.0— new provider-shaped JSON navigation conformance fixture.conformance/run.mjs— register the new fixture.docs/articles/modules/json.md— document the typed navigation API.Conformance
Built and gated locally on macOS arm64 (host Node 22.11 < pnpm's 22.13, so the underlying harnesses were invoked directly with
node— identical to what the npm scripts run):make -C native/zero-c— clean, no warnings.conformance:local(node conformance/run.mjs) — conformance ok.command-contracts:local(node scripts/snapshot-command-contracts.mts) — command contract snapshots ok.bin/zero check --json conformance/native/pass/std-json-nav.0—ok:true, no diagnostics.bin/zero graph --json.native:test:local: the--target linux-musl-x64cross step fails on the pre-existing, unmodifiedstd-json-duplicate-keys.0fixture withBLD003("host runtime object build failed") because no cross C toolchain / zig is installed in this environment. This is environmental and pre-existing — our diff only adds type-signature and metadata table entries and touches no codegen/lowering/object/linker/toolchain path, so it cannot affect that build. Not a regression.The only red CI check on fork PRs ("Vercel — Authorization required to deploy") is external-fork deploy-auth, not code.
Proposed CHANGELOG line
std.json.root/kind/get/at/len/string/int/float/bool) for traversing a parsedJsonDocwithout re-tokenizing (check-level; native exec deferred pending aggregate-ABI codegen).