Skip to content

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
vercel-labs:mainfrom
WalterGropius:feat/std-json-accessors
Open

Add typed JSON navigation accessors (std.json.root/kind/get/at/len/string/int/float/bool)#125
WalterGropius wants to merge 4 commits into
vercel-labs:mainfrom
WalterGropius:feat/std-json-accessors

Conversation

@WalterGropius
Copy link
Copy Markdown

Summary

Addresses P0-5: introduces typed JSON navigation accessors so programs can traverse a parsed JsonDoc without 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/JsonNode value types is not delivered upstream, so direct native execution of these accessors is deferred (the new fixture surfaces the expected CGEN004 "direct backend local type is unsupported: JsonDoc" target-readiness blocker at lower stage while check itself is ok: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 9 std.json.* accessors; register JsonNode and JsonKind as builtin type names.
  • native/zero-c/src/main.c — surface the 9 accessors in the std_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.
  • provenance guardrails — ok (29 surfaces).
  • 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.0ok:true, no diagnostics.
  • All 9 helpers present in bin/zero graph --json.
  • native:test:local: the --target linux-musl-x64 cross step fails on the pre-existing, unmodified std-json-duplicate-keys.0 fixture with BLD003 ("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

  • Add typed JSON navigation accessors (std.json.root/kind/get/at/len/string/int/float/bool) for traversing a parsed JsonDoc without re-tokenizing (check-level; native exec deferred pending aggregate-ABI codegen).

WalterGropius and others added 4 commits May 19, 2026 18:20
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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@WalterGropius is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant