Skip to content

feat(server): add config instance Device API endpoints#79

Open
ben-miru wants to merge 7 commits into
mainfrom
feat/device-api-config-instances
Open

feat(server): add config instance Device API endpoints#79
ben-miru wants to merge 7 commits into
mainfrom
feat/device-api-config-instances

Conversation

@ben-miru

Copy link
Copy Markdown
Contributor

Summary

Adds four new HTTP endpoints to the agent's device-facing API (Unix socket) so on-device applications can access config instance data without reading files directly from disk:

  • GET /v0.2/config_instances/{id} — returns config instance metadata (JSON). Supports ?expand=content to include the raw file content inline with format detection.
  • GET /v0.2/config_instances/{id}/content — returns the raw config file with appropriate Content-Type (application/json or application/x-yaml) and Content-Disposition headers.
  • GET /v0.2/config_instances/{id}/parameters/{key} — returns a single parameter by dot-separated key path (e.g. network.connection_timeout_ms), with the value in its native JSON type.
  • GET /v0.2/config_instances/{id}/parameters — lists all leaf parameters flattened into dot-separated key paths. Supports ?prefix= filtering.

Implementation approach

  • Response types are defined as standalone Serialize structs in agent/src/server/responses/ rather than modifying the auto-generated libs/device-api/ models (which are sourced from the OpenAPI repo).
  • Service layer in agent/src/services/config_instance/ reads from the existing CfgInsts (metadata) and CfgInstContent (raw content) caches — no backend fallback needed since content is synced during deployment sync.
  • YAML parsing uses serde_yml (maintained fork of the deprecated serde_yaml), converting to serde_json::Value for uniform traversal.
  • 27 new tests (17 service + 10 handler integration).

Test plan

  • ./scripts/test.sh — all 1390 tests pass
  • ./scripts/lint.sh — all lints pass (import ordering, fmt, clippy, machete, audit)
  • GET config instance returns 200 with correct metadata fields
  • GET config instance with ?expand=content includes content field with format and data
  • GET config instance returns 404 for missing ID
  • GET content returns raw file body with correct Content-Type header (JSON and YAML)
  • GET content returns 404 for missing ID
  • GET parameter returns correct value for top-level, nested, and array-indexed keys
  • GET parameter returns 404 for missing key
  • List parameters returns all leaf parameters with correct dot-path keys
  • List parameters with ?prefix= filters correctly

🤖 Generated with Claude Code

ben-miru and others added 7 commits May 24, 2026 17:02
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Define ConfigInstanceResponse, ContentField, ParameterResponse, and
ParameterListResponse as standalone Serialize structs in the new
server/responses module for the device API config instance endpoints.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add serde_yml workspace dependency for YAML config parsing. Implement
config_instance service module with get, get_response, get_raw_content,
get_parameter, and list_parameters functions. Add ConfigInstanceNotFoundErr,
ParameterNotFoundErr, and ContentParseErr error types to ServiceErr.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add four handler functions: get_config_instance (with ?expand=content),
get_config_instance_content (raw file download with Content-Type and
Content-Disposition headers), get_config_instance_parameter (single
parameter lookup by dot-separated key), and list_config_instance_parameters
(with ?prefix= filtering). Register all routes under /config_instances/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add comprehensive service-layer tests for get, get_response,
get_raw_content, infer_format, get_parameter, and list_parameters.
Add handler integration tests for all four config instance routes
including content download, parameter lookup, prefix filtering,
and error cases. Add .covgate for the new service module.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…points

Resolve import linter findings (merge sibling imports under common parent),
cargo fmt reformatting, and suppress field-by-field-assert lint on array
element assertions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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