Skip to content

feat(stdlib): jsonField extern for minimal JSON field extraction#211

Merged
hyperpolymath merged 1 commit into
mainfrom
pr5db/json-field
May 18, 2026
Merged

feat(stdlib): jsonField extern for minimal JSON field extraction#211
hyperpolymath merged 1 commit into
mainfrom
pr5db/json-field

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Adds pub extern fn jsonField(json, key) -> String to stdlib/Vscode.affine + runtime impl in packages/affine-vscode/mod.js.

The wasm guest has no JSON parser (only stringConcat/stringEndsWith/stringIsEmpty), so it can't decode thenableResultJson / httpPostJson payloads. jsonField reads one top-level field — scalar coerced to string, object/array re-serialised — mirroring thenableResultJson's synchronous reg(string) shape with "" as the absent/parse-fail sentinel. Deliberately minimal: enough for { tier, tier_code, score } and the { __error } reject shape; nested/array access out of scope by design.

Surfaced as a real ABI gap by the first ever #205 consumer (rsr-certifier extension rewire, PR-5d-B); unblocks every future #205 consumer.

Full dune test --force gate green: 257/257, zero regression.

Refs #199 #205

🤖 Generated with Claude Code

Adds `pub extern fn jsonField(json, key) -> String` to
stdlib/Vscode.affine + runtime impl in packages/affine-vscode/mod.js.

The wasm guest has no JSON parser and only stringConcat/stringEndsWith/
stringIsEmpty, so it cannot decode the payloads returned by
thenableResultJson / httpPostJson. jsonField reads one top-level field
(scalar coerced to string; object/array re-serialised), mirroring
thenableResultJson's synchronous reg(string) shape with "" as the
absent/parse-fail sentinel. Deliberately minimal — enough for result
objects like { tier, tier_code, score } and the { __error } reject
shape; nested/array access is out of scope by design.

Surfaced as a real gap by the first #205 consumer (rsr-certifier
extension rewire, PR-5d-B); unblocks every future #205 consumer.

Full dune gate green (257/257), zero regression.

Refs #199 #205

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit d620b41 into main May 18, 2026
11 of 12 checks passed
@hyperpolymath hyperpolymath deleted the pr5db/json-field branch May 18, 2026 09:44
hyperpolymath added a commit that referenced this pull request May 18, 2026
…er (#213)

stdlib/Vscode.affine:307 declares
`withProgressNotification(title, work: fn(Unit) -> Thenable) -> Thenable / Async`,
but packages/affine-vscode/mod.js had no runtime impl — calling it from
the wasm/Node backend faulted (undefined extern). Surfaced by the first
#205 consumer (rsr-certifier extension rewire, standards#123), which had
to omit progress UI and document the gap.

Adds the impl following the established async-extern convention exactly:

  - `work` is the #199 closure (`fn(Unit) -> Thenable`); invoking it via
    wrapHandler returns the guest's Thenable *handle*, resolved through
    the shared handle table.
  - The overall progress Thenable is `reg`-ed so the guest observes
    completion with thenableThen / thenableResultJson, identical to
    httpPostJson (#210).
  - Failures settle as `{ __error }` — the same reject shape thenableThen
    / httpPostJson use, so guests branch to a fallback uniformly.
  - Graceful degradation: if the host has no `withProgress`
    (non-VS Code / test runner), the work still runs; only the progress
    chrome is skipped (mirrors httpPostJson's fetch-unavailable stance).

Pure adapter addition — no stdlib/compiler change (the extern was
already declared). Node syntax-checked; full dune gate green (257/257),
zero regression.

Closes #212
Refs #199 #205 #210 #211 ; consumer hyperpolymath/standards#123

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 44 issues detected

Severity Count
🔴 Critical 12
🟠 High 21
🟡 Medium 11

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stray AI.a2ml in root -- use 0-AI-MANIFEST.a2ml only",
    "type": "banned",
    "file": "AI.a2ml",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Superseded by 0-AI-MANIFEST.a2ml",
    "type": "banned",
    "file": "AI.djot",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/compile.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/runner.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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