@hasna/capacity 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +6663 -0
  5. package/dist/domain/authority-evidence.d.ts +198 -0
  6. package/dist/domain/catalog.d.ts +65 -0
  7. package/dist/domain/counter.d.ts +7 -0
  8. package/dist/domain/eligibility.d.ts +4 -0
  9. package/dist/domain/ids.d.ts +47 -0
  10. package/dist/domain/invariants.d.ts +4 -0
  11. package/dist/domain/models.d.ts +300 -0
  12. package/dist/domain/native-subscription.d.ts +211 -0
  13. package/dist/domain/online-generation-receipt.d.ts +497 -0
  14. package/dist/domain/state.d.ts +19 -0
  15. package/dist/errors.d.ts +26 -0
  16. package/dist/http/handler.d.ts +3 -0
  17. package/dist/http/openapi.d.ts +1070 -0
  18. package/dist/http/stores.d.ts +20 -0
  19. package/dist/http/types.d.ts +141 -0
  20. package/dist/index.d.ts +56 -0
  21. package/dist/index.js +14909 -0
  22. package/dist/sdk/index.d.ts +8 -0
  23. package/dist/sdk/local.d.ts +5 -0
  24. package/dist/sdk/remote.d.ts +2 -0
  25. package/dist/sdk/types.d.ts +107 -0
  26. package/dist/serialization/dto.d.ts +13 -0
  27. package/dist/serialization/json.d.ts +7 -0
  28. package/dist/storage/credential-use-authorizer.d.ts +9 -0
  29. package/dist/storage/credential-verifier.d.ts +13 -0
  30. package/dist/storage/effect-dispatch.d.ts +278 -0
  31. package/dist/storage/file-recovery-ledger.d.ts +66 -0
  32. package/dist/storage/memory.d.ts +47 -0
  33. package/dist/storage/native-revocation.d.ts +10 -0
  34. package/dist/storage/postgres-config.d.ts +25 -0
  35. package/dist/storage/postgres-migrations.d.ts +10 -0
  36. package/dist/storage/postgres-migrator.d.ts +12 -0
  37. package/dist/storage/postgres.d.ts +90 -0
  38. package/dist/storage/recovery.d.ts +11 -0
  39. package/dist/storage/repository.d.ts +310 -0
  40. package/dist/storage/shared.d.ts +18 -0
  41. package/dist/storage/sqlite-migrations.d.ts +11 -0
  42. package/dist/storage/sqlite.d.ts +51 -0
  43. package/dist/version.d.ts +2 -0
  44. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hasna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @hasna/capacity
2
+
3
+ > **WIP CHECKPOINT — NO-GO.** This branch is preserved for local review only.
4
+ > The Accounts V1 successor contract is not independently approved or pinned,
5
+ > and the credential-effect journal still targets an obsolete candidate. Do not
6
+ > deploy, merge to `main`, publish, or treat `ACCOUNTS_V1_CONTRACT_SHA256` as a
7
+ > successor attestation until the exact contract, implementation, and final
8
+ > adversarial gates all pass.
9
+ >
10
+ > The current immutable but unpinned review pair is preserved under
11
+ > [`contracts/accounts-v1`](contracts/accounts-v1/README.md). Its presence on
12
+ > this branch is provenance only, not approval.
13
+
14
+ Accounts is the fail-closed provider-capacity metadata boundary for Hasna
15
+ `local` and `self_hosted` deployments. It models provider accounts,
16
+ entitlements, capacity pools, account lanes, credential bindings, native
17
+ AuthCapsule metadata, signed authority evidence, and non-reservational slot
18
+ eligibility.
19
+
20
+ Implemented adapters and surfaces:
21
+
22
+ - deterministic in-memory and owner-only SQLite repositories for local use;
23
+ - RLS-isolated PostgreSQL for Hasna-owned AWS self-hosting;
24
+ - persistent signed recovery and credential-effect journals outside the
25
+ restorable catalog;
26
+ - closed Ed25519 authority evidence and online generation-check receipts;
27
+ - local/self-hosted SDK selection with no fallback;
28
+ - authenticated HTTP handlers and generated OpenAPI 3.1;
29
+ - a safe local read/diagnostic CLI.
30
+
31
+ Accounts does not issue Infinity resource leases, schedule work, run provider
32
+ calls, return raw credential handles, launch processes, or provide SaaS tenant,
33
+ signup, billing, or public registration features. Ordinary model-call effects
34
+ remain broker/Run-Authority owned. Credential lifecycle execution requires the
35
+ separate one-use capsule-maintenance authority and external effect journal.
36
+
37
+ ## Build and verify locally
38
+
39
+ ```sh
40
+ bun install
41
+ bun test
42
+ bun run typecheck
43
+ bun run build
44
+ ```
45
+
46
+ The live PostgreSQL conformance test is opt-in and expects an empty disposable
47
+ database:
48
+
49
+ ```sh
50
+ ACCOUNTS_TEST_POSTGRES_URL='postgresql://user@127.0.0.1/accounts_test?sslmode=disable' \
51
+ bun test test/storage/postgres-live.test.ts
52
+ ```
53
+
54
+ Plaintext PostgreSQL is accepted only by this explicit loopback test path.
55
+ Self-hosted connections require `sslmode=verify-full`.
56
+
57
+ ## Local CLI
58
+
59
+ ```sh
60
+ HASNA_ACCOUNTS_DEPLOYMENT=local capacity doctor --json
61
+ capacity validate ./record.json --json
62
+ HASNA_ACCOUNTS_DEPLOYMENT=local capacity list access-methods --json
63
+ HASNA_ACCOUNTS_DEPLOYMENT=local capacity get access-methods <uuidv7> --json
64
+ HASNA_ACCOUNTS_DEPLOYMENT=local capacity eligibility <account-lane-uuidv7> \
65
+ --operation responses.create \
66
+ --model model.example \
67
+ --data-classification internal \
68
+ --json
69
+ ```
70
+
71
+ Positive local evaluation requires an explicitly configured, owner-only signed
72
+ recovery ledger through the SDK/factory. Without it, readiness and eligibility
73
+ stay on recovery hold. CLI output is local diagnostic evidence only and never a
74
+ reservation or production Infinity authority.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export declare function runAccountsCli(argv: readonly string[]): Promise<number>;