Skip to content

feat(file): add file management API, deploy provider, and templates#228

Merged
retr0h merged 11 commits intomainfrom
docs/file-deploy-template-plan
Mar 7, 2026
Merged

feat(file): add file management API, deploy provider, and templates#228
retr0h merged 11 commits intomainfrom
docs/file-deploy-template-plan

Conversation

@retr0h
Copy link
Collaborator

@retr0h retr0h commented Mar 7, 2026

Summary

  • Add complete file management API domain: upload (multipart), get, list,
    delete with OpenAPI spec, validation, and RBAC
  • Add file deploy and status provider with SHA-256 change detection, Go
    template rendering (with facts/vars/hostname), and file mode support
  • Add node file deploy and status endpoints for agent-side file operations
  • Wire Object Store and file-state KV into NATS infrastructure
  • Add job client methods for file deploy/status with target routing
  • Add agent processor for file deploy/status jobs
  • Add CLI commands: client file {upload,get,list,delete} and
    client node file {deploy,status}
  • Extract reusable FactsAware/FactsFunc pattern into provider package
  • Standardize HTTP test naming (ValidationHTTP/HTTP/RBACHTTP) across all
    API domains
  • Add validation coverage for node endpoints missing hostname → 400 cases
  • Close test coverage gaps with marshalJSON/unmarshalJSON hooks

Test plan

  • just go::unit — all unit tests pass
  • just go::vet — golangci-lint clean
  • go build ./... — compiles
  • Manual: upload a file, deploy to agent, verify template rendering
  • Manual: check file status reports in-sync/drifted/missing correctly

🤖 Generated with Claude Code

retr0h and others added 10 commits March 6, 2026 09:45
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add CreateOrUpdateObjectStore and ObjectStore to the NATSClient
interface for upcoming file deploy feature. Add replace directive
for local nats-client development.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add NATSObjects and NATSFileState config structs with builder
functions and JetStream setup. Add file:read and file:write
permissions to built-in roles. Add implementation plan for
file deploy and template rendering feature.

Co-Authored-By: Claude <noreply@anthropic.com>
Add OpenAPI spec for file management endpoints (upload, list, get,
delete) with generated server code. Add file.deploy.execute and
file.status.get operation constants, FileState struct for KV tracking,
and file provider interface with Deploy/Status methods plus mocks.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
File API handlers (Task 4): upload, list, get, delete endpoints with
Object Store backend. Includes HTTP wiring tests and RBAC tests for
all endpoints (36 tests).

File deploy provider (Task 7): SHA-based idempotent file deployment
with state tracking via file-state KV. Status checks for in-sync,
drifted, and missing files (12 tests).

Job client methods (Task 10): ModifyFileDeploy and QueryFileStatus
convenience methods following existing patterns (7 tests).

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Server wiring (Task 5): Add GetFileHandler to ServerManager, Object
Store handle in natsBundle, conditional file handler registration.

Template rendering (Task 8): Go text/template with TemplateContext
providing Facts, Vars, and Hostname. 12 test cases covering
substitution, conditionals, range, and error handling.

Node API endpoints (Task 11): POST /node/{hostname}/file/deploy (202)
and POST /node/{hostname}/file/status (200) with OpenAPI spec,
generated code, handlers, HTTP wiring and RBAC tests (32 tests).

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Agent wiring (Task 9): Add fileProvider to Agent struct, file category
processor dispatch for deploy/status operations, startup wiring with
Object Store and file-state KV handles. Graceful nil-provider handling
when Object Store is not configured. 12 new agent tests.

CLI commands (Task 12): File management commands (upload, list, get,
delete) and node file commands (deploy, status) with flag handling,
display formatting, and broadcast support. SDK calls scaffolded as
TODOs pending SDK integration (Task 13).

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add feature page for file management covering upload, deploy, template
rendering, SHA-based idempotency, and status checking. Update
docusaurus navbar, configuration reference with nats.objects and
nats.file_state sections, and README features matrix.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
…gaps

Wire validateFileName into file get/delete handlers following the
validateHostname pattern. Add 400 responses to OpenAPI spec and
regenerate. Close test coverage gaps in deploy (corrupt state, invalid
mode), status (invalid JSON), and template (execution error).

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Wire file management end-to-end: multipart upload with force flag and
content-type support, template rendering with agent facts, node file
deploy/status CLI commands, and Object Store bucket creation.

Standardize HTTP test naming across all API domains (ValidationHTTP
for endpoints with input validation, HTTP for plain wiring, RBACHTTP
for auth). Add missing ValidationHTTP + RBACHTTP tests for node disk,
load, memory, OS, and uptime endpoints. Close coverage gaps in
provider/facts, agent GetFacts, file list/upload/deploy handlers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Thank you for contributing to this project! 😊🕹️

Rename FileProvider → Service and NewFileProvider → New to eliminate
the golangci-lint type-stutter warning (file.FileProvider → file.Service).
Add package comment to satisfy revive package-comments rule. Extract
reusable FactsAware/FactsFunc pattern into provider package. Close
remaining test coverage gaps with marshalJSON/unmarshalJSON hooks and
additional edge-case tests. Remove dead validation.Struct call from
PostFile handler. Standardize HTTP test method naming across all API
domains (ValidationHTTP for endpoints with validation tags, HTTP for
plain wiring tests).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@retr0h retr0h force-pushed the docs/file-deploy-template-plan branch from d4d718b to efe59da Compare March 7, 2026 06:54
@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #228    +/-   ##
========================================
  Coverage   99.98%   99.98%            
========================================
  Files         166      182    +16     
  Lines        6009     6518   +509     
========================================
+ Hits         6008     6517   +509     
  Misses          1        1            
Files with missing lines Coverage Δ
internal/agent/agent.go 100.00% <100.00%> (ø)
internal/agent/facts.go 100.00% <100.00%> (ø)
internal/agent/heartbeat.go 100.00% <ø> (ø)
internal/agent/processor.go 100.00% <100.00%> (ø)
internal/agent/processor_file.go 100.00% <100.00%> (ø)
internal/api/file/file.go 100.00% <100.00%> (ø)
internal/api/file/file_delete.go 100.00% <100.00%> (ø)
internal/api/file/file_get.go 100.00% <100.00%> (ø)
internal/api/file/file_list.go 100.00% <100.00%> (ø)
internal/api/file/file_upload.go 100.00% <100.00%> (ø)
... and 37 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d916601...efe59da. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@retr0h retr0h merged commit dd9d879 into main Mar 7, 2026
9 checks passed
@retr0h retr0h deleted the docs/file-deploy-template-plan branch March 7, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant