Skip to content

feat(swift-example-app): GroveDB path elements diagnostic view (SYS-06)#3931

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/sys06-path-elements
Jun 18, 2026
Merged

feat(swift-example-app): GroveDB path elements diagnostic view (SYS-06)#3931
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/sys06-path-elements

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jun 18, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

SYS-06 (raw GroveDB path elements) was marked 🔌 SDK-only, no UI — the FFI dash_sdk_system_get_path_elements is fully implemented and proof-verified, but nothing in SwiftExampleApp surfaced it, so it could only ever be skipped in app QA. This adds the missing diagnostic surface.

What was done?

  • SwiftDashSDK (PlatformQueryExtensions.swift): added a thin read-only bridge systemPathElements(path:keys:) -> [PathElement] over the already-exported FFI dash_sdk_system_get_path_elements (call → marshal → parse the {key, element, type} JSON array → return; NoData[]). Mirrors the existing documentCount wrapper — no business logic.
  • SwiftExampleApp (GroveDBPathElementsView.swift, new; PlatformQueriesView.swift): a "Get GroveDB Path Elements" read view reachable via Platform Queries → System & Utility → Get GroveDB Path Elements. path + keys JSON fields, a Run button, a results list (type / key / element), an error section, and a "DPNS contract example" preset that fills the fields directly (no typed JSON → avoids the simulator's smart-punctuation mangling of quotes).
  • The preset uses a bounded path on purpose: empty/root-level queries (path=[]) fail GroveDB proof verification ("Cannot verify lower bound"); bounded path queries verify cleanly. The footer documents this.
  • TEST_PLAN.md: flipped SYS-06 from 🔌 to 🧪, updated the Appendix A read-query row and the SDK-only completeness list.

No Rust / xcframework change — dash_sdk_system_get_path_elements was already implemented and exported; this is Swift-only.

How Has This Been Tested?

Driven end-to-end on testnet (iPhone 16 Pro sim) via the new view: path=["40"] (the DataContractDocuments root, byte 0x40), keys=[DPNS system contract id]1 element returned, type tree (the DPNS contract's GroveDB subtree), proof-verified. Recorded pass for SYS-06 to the QA contract; it renders on the live QA dashboard. Also confirmed the empty-path preset path errors with a proof-verification failure, which is why the shipped preset is bounded.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a GroveDB path elements query interface to the example app, providing a diagnostic UI with preset DPNS contract examples for querying raw elements.
    • SDK now exposes a new method for querying GroveDB path elements with customizable path and key parameters.
  • Documentation

    • Updated test plan to reflect new diagnostic UI capabilities.

Surface the raw GroveDB path-elements query (SYS-06) in SwiftExampleApp
via a thin SDK wrapper + a diagnostic read view over the already-exported
FFI `dash_sdk_system_get_path_elements`.

- SwiftDashSDK: `systemPathElements(path:keys:) -> [PathElement]` wrapper
  in PlatformQueryExtensions (call -> marshal -> parse -> return; parses
  the {key,element,type} JSON array; NoData -> []). Pure bridge.
- SwiftExampleApp: GroveDBPathElementsView, reached via Platform Queries
  -> System & Utility -> "Get GroveDB Path Elements". Path + keys JSON
  fields, Run, results list (type/key/element), error section, and a
  "DPNS contract example" preset (path=["40"], keys=[DPNS contract id])
  that fills the fields directly (no typed JSON -> avoids the simulator's
  smart-punctuation mangling).
- The preset uses a *bounded* path on purpose: root-level queries
  (path=[]) fail GroveDB proof verification ("Cannot verify lower bound");
  bounded path queries verify cleanly.
- TEST_PLAN: flip SYS-06 from no-UI to drivable, update Appendix A +
  completeness lists.

No Rust/xcframework change: dash_sdk_system_get_path_elements was already
exported.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a PathElement struct and SDK.systemPathElements(path:keys:) FFI bridge over dash_sdk_system_get_path_elements. A new GroveDBPathElementsView SwiftUI screen exposes JSON-array inputs, a DPNS preset, and result rendering. The view is registered in the system query list and TEST_PLAN.md is updated to reflect the feature's new in-app status.

Changes

GroveDB Path Elements Feature

Layer / File(s) Summary
PathElement model and FFI bridge
packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
Adds the PathElement public Sendable struct with key, element, and type fields. Implements SDK.systemPathElements(path:keys:) as an @MainActor FFI bridge: JSON-serializes inputs, calls dash_sdk_system_get_path_elements, handles errors with memory cleanup, returns [] on nil data, and maps the JSON result to [PathElement].
GroveDBPathElementsView SwiftUI screen
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/GroveDBPathElementsView.swift
Adds a diagnostic read-only view with two JSON-array text fields (path, keys), a DPNS preset button, async query execution via sdk.systemPathElements, decodeStringArray input validation with a localized PathElementsInputError, conditional error/elements result sections, and a SwiftUI preview provider.
Navigation wiring and test plan update
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift, packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
Registers getPathElements as a QueryDefinition in the .system query list, adds a conditional navigation branch in QueryCategoryDetailView routing to GroveDBPathElementsView, and updates TEST_PLAN.md SYS-06 status from 🔌 to 🧪 with bounded-path guidance and removes the entry from Appendix B's SDK-only list.

Sequence Diagram

sequenceDiagram
  actor User
  participant GroveDBPathElementsView
  participant SDK
  participant FFI as dash_sdk_system_get_path_elements

  User->>GroveDBPathElementsView: tap "Run Query"
  GroveDBPathElementsView->>GroveDBPathElementsView: decodeStringArray(pathText, keysText)
  GroveDBPathElementsView->>SDK: sdk.systemPathElements(path:keys:)
  SDK->>SDK: JSONEncoder serialize path/keys
  SDK->>FFI: dash_sdk_system_get_path_elements(path_json, keys_json)
  FFI-->>SDK: SdkResult
  alt FFI error
    SDK-->>GroveDBPathElementsView: throws SDKError
    GroveDBPathElementsView->>User: display red error message
  else success
    SDK->>SDK: parse JSON → [PathElement]
    SDK-->>GroveDBPathElementsView: [PathElement]
    GroveDBPathElementsView->>User: render element list (type, key, element)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • dashpay/platform#3887: Established the SwiftExampleApp/TEST_PLAN.md test plan structure and tiered status system that this PR updates for the SYS-06 getPathElements entry.

Suggested reviewers

  • shumkov
  • llbartekll
  • ZocoLini

🐇 Hopping through the grove, keys in paw,
I query each path without a flaw.
JSON in, elements out — what a sight!
DPNS preset makes the dark feel bright.
The FFI bridge gleams, neat and clean,
The finest GroveDB hop I've ever seen! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a GroveDB path elements diagnostic view to SwiftExampleApp for the SYS-06 feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sys06-path-elements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw

thepastaclaw commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit a5ce2b4)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift`:
- Around line 1715-1725: The PathElement initialization in the map closure is
silently defaulting missing or incorrectly-typed fields to empty strings using
the nil-coalescing operator. Instead, validate that the key, element, and type
fields are present and properly typed, and throw an SDKError.serializationError
with a descriptive message if any of these required fields are missing or
invalid, rather than defaulting them to empty strings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca701a64-e2cf-4621-98e2-23b6e09a90ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2f1bcb8 and a5ce2b4.

📒 Files selected for processing (4)
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/GroveDBPathElementsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift
  • packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md

Comment on lines +1715 to +1725
guard let data = jsonString.data(using: .utf8),
let array = try? JSONSerialization.jsonObject(with: data) as? [[String: Any]] else {
throw SDKError.serializationError("Failed to parse path elements JSON array")
}

return array.map { entry in
PathElement(
key: entry["key"] as? String ?? "",
element: entry["element"] as? String ?? "",
type: entry["type"] as? String ?? ""
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fail fast on malformed path-element payloads instead of silently zero-filling fields.

Line 1722, Line 1723, and Line 1724 currently coerce missing/invalid fields to "". That hides FFI contract breaks and can produce misleading diagnostic output. This bridge should throw serialization errors when key/element/type are absent or wrong-typed.

Suggested fix
-        guard let data = jsonString.data(using: .utf8),
-              let array = try? JSONSerialization.jsonObject(with: data) as? [[String: Any]] else {
-            throw SDKError.serializationError("Failed to parse path elements JSON array")
-        }
-
-        return array.map { entry in
-            PathElement(
-                key: entry["key"] as? String ?? "",
-                element: entry["element"] as? String ?? "",
-                type: entry["type"] as? String ?? ""
-            )
-        }
+        struct RawPathElement: Decodable {
+            let key: String
+            let element: String
+            let type: String
+        }
+
+        guard let data = jsonString.data(using: .utf8) else {
+            throw SDKError.serializationError("Failed to parse path elements JSON array")
+        }
+
+        do {
+            let decoded = try JSONDecoder().decode([RawPathElement].self, from: data)
+            return decoded.map { PathElement(key: $0.key, element: $0.element, type: $0.type) }
+        } catch {
+            throw SDKError.serializationError("Invalid path elements payload: \(error.localizedDescription)")
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift`
around lines 1715 - 1725, The PathElement initialization in the map closure is
silently defaulting missing or incorrectly-typed fields to empty strings using
the nil-coalescing operator. Instead, validate that the key, element, and type
fields are present and properly typed, and throw an SDKError.serializationError
with a descriptive message if any of these required fields are missing or
invalid, rather than defaulting them to empty strings.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

@QuantumExplorer QuantumExplorer merged commit efa8943 into v3.1-dev Jun 18, 2026
15 of 18 checks passed
@QuantumExplorer QuantumExplorer deleted the claude/sys06-path-elements branch June 18, 2026 04:24

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Thin Swift wrapper around the already-shipped dash_sdk_system_get_path_elements FFI plus a read-only SwiftUI diagnostic view, with TEST_PLAN flips for SYS-06. All six agents converged on no in-scope findings; FFI memory ownership, string lifetimes via withCString, error/data free pairing, and NoData→[] mapping match existing precedent in the file. No correctness, security, FFI, or architectural issues introduced by this PR.

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.

2 participants