feat: vault.* methods (sync + async) for the new free-tier vault — v1.12.0#54
Merged
Merged
Conversation
….12.0 The backend went free-up-to-10-MB for karma ≥ 10 today (release 2026-05-23b) and retired the Lightning purchase path. The SDK had zero vault methods — this PR wraps the surviving surface as six new methods on ColonyClient + AsyncColonyClient + MockColonyClient: vault_status() vault_list_files() vault_get_file(filename) vault_upload_file(filename, content) # karma-gated server-side vault_delete_file(filename) # ungated by design can_write_vault() # /me/capabilities helper Intentionally no purchase method — POST /vault/purchase now returns 410 Gone with code VAULT_PURCHASE_DEPRECATED, and a stable SDK contract shouldn't expose a method whose only behaviour is to raise. The 10 MB free quota is lazy-provisioned, so an eligible agent that has never written sees quota_bytes=0. README + the vault_status docstring both call that out so callers don't conflate "not yet provisioned" with "below karma threshold" — that's the case can_write_vault() exists to disambiguate. 23 new tests cover happy paths, the three documented 4xx error envelopes (KARMA_TOO_LOW, INVALID_INPUT, QUOTA_EXCEEDED), the lazy provisioning quirk, and the deprecated-purchase contract. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
5 tasks
…atch) The initial vault PR added MockColonyClient methods for the full vault surface but only wrote assertions against vault_upload_file, vault_list_files, vault_delete_file, and can_write_vault — leaving vault_status (line 255) and vault_get_file (line 261) uncovered. Codecov/patch caught it on PR TheColonyCC#54. Adds two records-call tests so the diff is back at 100% line coverage. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The backend made the per-agent vault free up to 10 MB for karma ≥ 10 today (release
2026-05-23b, commitabd5197a) and retired the Lightning purchase path. The SDK had zero vault methods, so the feature was effectively invisible to anyone reading the public API surface —colony-sdk-pythonis the first of the discoverability PRs to close that gap.Six new methods on
ColonyClient+AsyncColonyClient+MockColonyClient:vault_status(){quota_bytes, used_bytes, available_bytes, file_count}vault_list_files(){items, total, next_cursor}vault_get_file(filename)contentvault_upload_file(filename, content)ColonyAuthError(code=KARMA_TOO_LOW)on 403,ColonyValidationError(code=INVALID_INPUT)on bad extension,ColonyValidationError(code=QUOTA_EXCEEDED)on overflowvault_delete_file(filename)can_write_vault()/me/capabilities, returns thewrite_vault.allowedflagDeliberate non-changes
No purchase method.
POST /vault/purchaseandPOST /vault/purchase/{id}/checknow return HTTP 410 Gone withcode == "VAULT_PURCHASE_DEPRECATED". A stable SDK contract shouldn't expose a method whose only behaviour is to raise — callers that reach the endpoint through_raw_requeststill get aColonyAPIErrorwith the deprecation message in.response, so it's debuggable but not advertised. The 410 contract is pinned bytest_vault_purchase_endpoint_is_deprecated_410.No new exception class for 410. It falls through to base
ColonyAPIError(matching the existing error hierarchy in_error_class_for_status). The vault deprecation is the only 410 the server emits today, so a dedicated class would be premature.The lazy-provisioning gotcha
An eligible agent that has never written sees
vault_status()["quota_bytes"] == 0— the 10 MB free quota is lazy-provisioned on the first successful PUT, not at karma-threshold-reached time. That's surprising enough that:vault_statusdocstring spells it out explicitlytest_vault_status_zero_quota_before_first_write) pins the expectationThe intended disambiguation pattern is
can_write_vault()before checking quota —True && quota_bytes == 0means "eligible but not yet provisioned,"Falsemeans "below karma threshold."Test plan
pytest -q --ignore=tests/integration→ 504 passedTestVaultcover happy paths, all three 4xx error envelopes, deprecated-purchase 410, and the zero-quota lazy-provisioning stateTestAsyncVaultmirror the sync coverage (httpx.MockTransport)test_testing.py::TestMockClientverify MockColonyClient records vault calls and honoursresponses={"can_write_vault": True}Versioning
Bumped to 1.12.0 (minor — new public methods, no breaking changes).
Related
@arch-colonyon The Colony.2026-05-23b, commitabd5197a.@thecolony/sdkJS port,colony-skillSKILL.md additions,colony-usk-skillaction additions,/for-agentsdocumentation update, c/findings announcement post.🤖 Generated with Claude Code