caisson-cli 0.0.0-stage → 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.
- package/README.math-mvp.md +28 -0
- package/README.md +37 -2
- package/dist/admin/adminRoutes.d.ts +10 -0
- package/dist/admin/adminRoutes.js +194 -0
- package/dist/admin/adminRoutes.js.map +1 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/workspaceAdmin.d.ts +417 -0
- package/dist/admin/workspaceAdmin.js +569 -0
- package/dist/admin/workspaceAdmin.js.map +1 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +3 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/metrics.d.ts +105 -0
- package/dist/analytics/metrics.js +837 -0
- package/dist/analytics/metrics.js.map +1 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.js +6 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/pipeline.d.ts +90 -0
- package/dist/audit/pipeline.js +424 -0
- package/dist/audit/pipeline.js.map +1 -0
- package/dist/audit/receiptSchema.d.ts +441 -0
- package/dist/audit/receiptSchema.js +208 -0
- package/dist/audit/receiptSchema.js.map +1 -0
- package/dist/audit/stageA.d.ts +50 -0
- package/dist/audit/stageA.js +218 -0
- package/dist/audit/stageA.js.map +1 -0
- package/dist/audit/stageB.d.ts +48 -0
- package/dist/audit/stageB.js +113 -0
- package/dist/audit/stageB.js.map +1 -0
- package/dist/auth/agentAuth.d.ts +18 -0
- package/dist/auth/agentAuth.js +59 -0
- package/dist/auth/agentAuth.js.map +1 -0
- package/dist/auth/agentCardSigner.d.ts +55 -0
- package/dist/auth/agentCardSigner.js +188 -0
- package/dist/auth/agentCardSigner.js.map +1 -0
- package/dist/billing/billingRoutes.d.ts +11 -0
- package/dist/billing/billingRoutes.js +303 -0
- package/dist/billing/billingRoutes.js.map +1 -0
- package/dist/billing/bountyRoutes.d.ts +9 -0
- package/dist/billing/bountyRoutes.js +332 -0
- package/dist/billing/bountyRoutes.js.map +1 -0
- package/dist/billing/index.d.ts +3 -0
- package/dist/billing/index.js +4 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/subscriptions.d.ts +226 -0
- package/dist/billing/subscriptions.js +673 -0
- package/dist/billing/subscriptions.js.map +1 -0
- package/dist/cli/caissonCli.d.ts +10 -0
- package/dist/cli/caissonCli.js +471 -0
- package/dist/cli/caissonCli.js.map +1 -0
- package/dist/cli/inviteCard.d.ts +12 -0
- package/dist/cli/inviteCard.js +49 -0
- package/dist/cli/inviteCard.js.map +1 -0
- package/dist/cli/mcpProxy.d.ts +36 -0
- package/dist/cli/mcpProxy.js +292 -0
- package/dist/cli/mcpProxy.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/db/adapter.d.ts +210 -0
- package/dist/db/adapter.js +769 -0
- package/dist/db/adapter.js.map +1 -0
- package/dist/db/sqlite.d.ts +7 -0
- package/dist/db/sqlite.js +60 -0
- package/dist/db/sqlite.js.map +1 -0
- package/dist/db/telemetry.d.ts +11 -0
- package/dist/db/telemetry.js +9 -0
- package/dist/db/telemetry.js.map +1 -0
- package/dist/economy/bountyEngine.d.ts +248 -0
- package/dist/economy/bountyEngine.js +836 -0
- package/dist/economy/bountyEngine.js.map +1 -0
- package/dist/economy/index.d.ts +5 -0
- package/dist/economy/index.js +6 -0
- package/dist/economy/index.js.map +1 -0
- package/dist/economy/scLedger.d.ts +183 -0
- package/dist/economy/scLedger.js +528 -0
- package/dist/economy/scLedger.js.map +1 -0
- package/dist/economy/scMinting.d.ts +177 -0
- package/dist/economy/scMinting.js +659 -0
- package/dist/economy/scMinting.js.map +1 -0
- package/dist/economy/scSinks.d.ts +135 -0
- package/dist/economy/scSinks.js +314 -0
- package/dist/economy/scSinks.js.map +1 -0
- package/dist/economy/usdLedger.d.ts +211 -0
- package/dist/economy/usdLedger.js +604 -0
- package/dist/economy/usdLedger.js.map +1 -0
- package/dist/mcp/handlers.d.ts +134 -0
- package/dist/mcp/handlers.js +781 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/httpServer.d.ts +25 -0
- package/dist/mcp/httpServer.js +368 -0
- package/dist/mcp/httpServer.js.map +1 -0
- package/dist/mcp/serverFactory.d.ts +4 -0
- package/dist/mcp/serverFactory.js +53 -0
- package/dist/mcp/serverFactory.js.map +1 -0
- package/dist/mcp/stdioServer.d.ts +2 -0
- package/dist/mcp/stdioServer.js +24 -0
- package/dist/mcp/stdioServer.js.map +1 -0
- package/dist/mcp/toolMetadata.d.ts +15 -0
- package/dist/mcp/toolMetadata.js +73 -0
- package/dist/mcp/toolMetadata.js.map +1 -0
- package/dist/memo/artifactIndex.d.ts +51 -0
- package/dist/memo/artifactIndex.js +162 -0
- package/dist/memo/artifactIndex.js.map +1 -0
- package/dist/memo/dependencyBundle.d.ts +33 -0
- package/dist/memo/dependencyBundle.js +86 -0
- package/dist/memo/dependencyBundle.js.map +1 -0
- package/dist/memo/embeddings.d.ts +110 -0
- package/dist/memo/embeddings.js +672 -0
- package/dist/memo/embeddings.js.map +1 -0
- package/dist/packs/foundryEvm.d.ts +21 -0
- package/dist/packs/foundryEvm.js +274 -0
- package/dist/packs/foundryEvm.js.map +1 -0
- package/dist/packs/index.d.ts +8 -0
- package/dist/packs/index.js +19 -0
- package/dist/packs/index.js.map +1 -0
- package/dist/packs/mathLean4.d.ts +7 -0
- package/dist/packs/mathLean4.js +145 -0
- package/dist/packs/mathLean4.js.map +1 -0
- package/dist/packs/rustKani.d.ts +17 -0
- package/dist/packs/rustKani.js +257 -0
- package/dist/packs/rustKani.js.map +1 -0
- package/dist/packs/sdk.d.ts +314 -0
- package/dist/packs/sdk.js +271 -0
- package/dist/packs/sdk.js.map +1 -0
- package/dist/preflight/leanTripwire.d.ts +19 -0
- package/dist/preflight/leanTripwire.js +105 -0
- package/dist/preflight/leanTripwire.js.map +1 -0
- package/dist/storage/blobStore.d.ts +11 -0
- package/dist/storage/blobStore.js +39 -0
- package/dist/storage/blobStore.js.map +1 -0
- package/dist/storage/gitStore.d.ts +68 -0
- package/dist/storage/gitStore.js +228 -0
- package/dist/storage/gitStore.js.map +1 -0
- package/dist/types/errors.d.ts +16 -0
- package/dist/types/errors.js +23 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/schemas.d.ts +453 -0
- package/dist/types/schemas.js +197 -0
- package/dist/types/schemas.js.map +1 -0
- package/dist/web/discoveryRoutes.d.ts +20 -0
- package/dist/web/discoveryRoutes.js +456 -0
- package/dist/web/discoveryRoutes.js.map +1 -0
- package/dist/web/explorer/dagLayout.d.ts +41 -0
- package/dist/web/explorer/dagLayout.js +183 -0
- package/dist/web/explorer/dagLayout.js.map +1 -0
- package/dist/web/explorer/index.d.ts +45 -0
- package/dist/web/explorer/index.js +512 -0
- package/dist/web/explorer/index.js.map +1 -0
- package/dist/web/explorer/renderers.d.ts +35 -0
- package/dist/web/explorer/renderers.js +397 -0
- package/dist/web/explorer/renderers.js.map +1 -0
- package/dist/web/repoBrowser.d.ts +19 -0
- package/dist/web/repoBrowser.js +128 -0
- package/dist/web/repoBrowser.js.map +1 -0
- package/dist/worker/executionAdapter.d.ts +14 -0
- package/dist/worker/executionAdapter.js +162 -0
- package/dist/worker/executionAdapter.js.map +1 -0
- package/dist/worker/finalize.d.ts +21 -0
- package/dist/worker/finalize.js +146 -0
- package/dist/worker/finalize.js.map +1 -0
- package/dist/worker/firecrackerAdapter.d.ts +180 -0
- package/dist/worker/firecrackerAdapter.js +421 -0
- package/dist/worker/firecrackerAdapter.js.map +1 -0
- package/dist/worker/loop.d.ts +56 -0
- package/dist/worker/loop.js +239 -0
- package/dist/worker/loop.js.map +1 -0
- package/dist/worker/postMergeSync.d.ts +17 -0
- package/dist/worker/postMergeSync.js +52 -0
- package/dist/worker/postMergeSync.js.map +1 -0
- package/dist/worker/prepareInput.d.ts +41 -0
- package/dist/worker/prepareInput.js +130 -0
- package/dist/worker/prepareInput.js.map +1 -0
- package/dist/worker/queue.d.ts +83 -0
- package/dist/worker/queue.js +278 -0
- package/dist/worker/queue.js.map +1 -0
- package/dist/worker/sandbox.d.ts +2 -0
- package/dist/worker/sandbox.js +3 -0
- package/dist/worker/sandbox.js.map +1 -0
- package/dist/worker/webhook.d.ts +14 -0
- package/dist/worker/webhook.js +110 -0
- package/dist/worker/webhook.js.map +1 -0
- package/migrations/001_init.sql +193 -0
- package/migrations/002_epic3_scale.sql +34 -0
- package/migrations/003_swarm_credits.sql +153 -0
- package/migrations/004_usd_bounties.sql +216 -0
- package/migrations_pg/001_init.sql +229 -0
- package/migrations_pg/002_multitenant_rls.sql +63 -0
- package/migrations_pg/003_swarm_credits.sql +135 -0
- package/migrations_pg/004_usd_bounties.sql +201 -0
- package/package.json +55 -4
- package/packs/foundry-evm/pack.json +60 -0
- package/packs/foundry-evm/verifier/Dockerfile +9 -0
- package/packs/foundry-evm/verifier/run.py +160 -0
- package/packs/math-lean4/pack.json +68 -0
- package/packs/rust-kani/pack.json +53 -0
- package/packs/rust-kani/verifier/Dockerfile +7 -0
- package/packs/rust-kani/verifier/run.py +159 -0
- package/public/.well-known/agent-card.json +153 -0
- package/public/llms.txt +35 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
// src/economy/scLedger.ts
|
|
2
|
+
// Swarm Credit Double-Entry Ledger (Epic 4 / E4-1)
|
|
3
|
+
// Reference: docs/08-business-model-unit-economics-branding-spec.md §2
|
|
4
|
+
//
|
|
5
|
+
// Core Invariants:
|
|
6
|
+
// 1. Immutable append-only journal (`sc_journal_entries` + `sc_ledger_lines`);
|
|
7
|
+
// every journal entry has >= 2 legs whose `delta_units` sum to strictly 0.
|
|
8
|
+
// 2. Global SC minting is restricted STRICTLY to audited public or sponsored public
|
|
9
|
+
// workspaces (`visibility === 'public'` AND `sc_minting_policy !== 'zero_sum_only'`).
|
|
10
|
+
// 3. Private workspaces allow ZERO global minting — strictly zero-sum transfers only.
|
|
11
|
+
// 4. Operator accounts can never go negative (overdraft protection).
|
|
12
|
+
// 5. Strict Dual-Ledger Firewall: currency is permanently locked to `'SC'` and
|
|
13
|
+
// non-convertible to USD or any fiat currency.
|
|
14
|
+
import { newId, nowIso } from '../db/sqlite.js';
|
|
15
|
+
import { SwarmError } from '../types/errors.js';
|
|
16
|
+
/** Integer micro-SC scale: 1 SC = 10,000 units (0.0001 SC resolution, zero float drift). */
|
|
17
|
+
export const SC_UNITS_PER_SC = 10_000;
|
|
18
|
+
export const SYSTEM_MINT_ACCOUNT = 'sys:mint';
|
|
19
|
+
export const SYSTEM_BURN_ACCOUNT = 'sys:burn';
|
|
20
|
+
export const SYSTEM_DEMURRAGE_ACCOUNT = 'sys:demurrage';
|
|
21
|
+
/** Converts a decimal SC amount to integer ledger units (`1 SC = 10,000 units`). */
|
|
22
|
+
export function scToUnits(sc) {
|
|
23
|
+
if (!Number.isFinite(sc)) {
|
|
24
|
+
throw new SwarmError('INVALID_INPUT', `Invalid SC amount: ${sc}`);
|
|
25
|
+
}
|
|
26
|
+
return Math.round(sc * SC_UNITS_PER_SC);
|
|
27
|
+
}
|
|
28
|
+
/** Converts integer ledger units to a decimal SC number (4 decimal places). */
|
|
29
|
+
export function unitsToSc(units) {
|
|
30
|
+
return Math.round(units) / SC_UNITS_PER_SC;
|
|
31
|
+
}
|
|
32
|
+
/** Canonical account ID for a human operator. */
|
|
33
|
+
export function operatorAccountId(operatorId) {
|
|
34
|
+
const clean = operatorId.trim();
|
|
35
|
+
if (!clean) {
|
|
36
|
+
throw new SwarmError('INVALID_INPUT', 'operatorId must be non-empty');
|
|
37
|
+
}
|
|
38
|
+
return clean.startsWith('op:') ? clean : `op:${clean}`;
|
|
39
|
+
}
|
|
40
|
+
/** Canonical account ID for an escrow hold. */
|
|
41
|
+
export function escrowAccountId(escrowKey) {
|
|
42
|
+
const clean = escrowKey.trim();
|
|
43
|
+
if (!clean) {
|
|
44
|
+
throw new SwarmError('INVALID_INPUT', 'escrowKey must be non-empty');
|
|
45
|
+
}
|
|
46
|
+
return clean.startsWith('escrow:') ? clean : `escrow:${clean}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dual-Ledger Firewall guard: permanently blocks any USD / fiat currency or conversion
|
|
50
|
+
* on the Swarm Credit ledger (Doc 08 §2 & Decision #20).
|
|
51
|
+
*/
|
|
52
|
+
export function assertSwarmCreditFirewall(currency, actionDescription) {
|
|
53
|
+
if (currency !== undefined && currency !== 'SC') {
|
|
54
|
+
throw new SwarmError('UNAUTHORIZED', `DUAL_LEDGER_FIREWALL: Swarm Credit ledger only accepts currency 'SC' (rejected '${currency}'${actionDescription ? ` for ${actionDescription}` : ''}). SC is permanently non-convertible to USD.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Explicitly rejects any attempt to convert Swarm Credits into USD or fiat cashout. */
|
|
58
|
+
export function rejectUsdConversion() {
|
|
59
|
+
throw new SwarmError('UNAUTHORIZED', 'DUAL_LEDGER_FIREWALL: Swarm Credits (SC) are permanently non-convertible to USD. Use Phase 3 Prepaid USD Credits for cash bounties.');
|
|
60
|
+
}
|
|
61
|
+
function hydrateAccount(row) {
|
|
62
|
+
return {
|
|
63
|
+
account_id: String(row.account_id),
|
|
64
|
+
account_type: row.account_type,
|
|
65
|
+
operator_id: row.operator_id ? String(row.operator_id) : null,
|
|
66
|
+
currency: 'SC',
|
|
67
|
+
identity_bonded: Number(row.identity_bonded) === 1,
|
|
68
|
+
bond_provider: row.bond_provider ? String(row.bond_provider) : null,
|
|
69
|
+
bonded_at: row.bonded_at ? String(row.bonded_at) : null,
|
|
70
|
+
balance_units: Number(row.balance_units),
|
|
71
|
+
balance_sc: unitsToSc(Number(row.balance_units)),
|
|
72
|
+
last_activity_at: String(row.last_activity_at),
|
|
73
|
+
created_at: String(row.created_at),
|
|
74
|
+
updated_at: String(row.updated_at),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Ensures the three system contra accounts exist (`sys:mint`, `sys:burn`, `sys:demurrage`). */
|
|
78
|
+
export function ensureSystemAccounts(db, now = nowIso()) {
|
|
79
|
+
const stmt = db.prepare(`
|
|
80
|
+
INSERT OR IGNORE INTO sc_accounts
|
|
81
|
+
(account_id, account_type, operator_id, currency, balance_units, last_activity_at, created_at, updated_at)
|
|
82
|
+
VALUES (?, ?, NULL, 'SC', 0, ?, ?, ?)
|
|
83
|
+
`);
|
|
84
|
+
stmt.run(SYSTEM_MINT_ACCOUNT, 'system_mint', now, now, now);
|
|
85
|
+
stmt.run(SYSTEM_BURN_ACCOUNT, 'system_burn', now, now, now);
|
|
86
|
+
stmt.run(SYSTEM_DEMURRAGE_ACCOUNT, 'system_demurrage', now, now, now);
|
|
87
|
+
}
|
|
88
|
+
/** Idempotently creates or retrieves an operator's Swarm Credit account. */
|
|
89
|
+
export function ensureOperatorAccount(db, operatorId, opts = {}) {
|
|
90
|
+
const cleanOp = operatorId.startsWith('op:') ? operatorId.slice(3) : operatorId.trim();
|
|
91
|
+
if (!cleanOp) {
|
|
92
|
+
throw new SwarmError('INVALID_INPUT', 'operatorId must be non-empty');
|
|
93
|
+
}
|
|
94
|
+
const accountId = operatorAccountId(cleanOp);
|
|
95
|
+
const ts = opts.now ?? nowIso();
|
|
96
|
+
db.prepare(`
|
|
97
|
+
INSERT OR IGNORE INTO sc_accounts
|
|
98
|
+
(account_id, account_type, operator_id, currency, balance_units, last_activity_at, created_at, updated_at)
|
|
99
|
+
VALUES (?, 'operator', ?, 'SC', 0, ?, ?, ?)
|
|
100
|
+
`).run(accountId, cleanOp, ts, ts, ts);
|
|
101
|
+
const row = db.prepare('SELECT * FROM sc_accounts WHERE account_id = ?').get(accountId);
|
|
102
|
+
return hydrateAccount(row);
|
|
103
|
+
}
|
|
104
|
+
/** Idempotently creates or retrieves an escrow SC account. */
|
|
105
|
+
export function ensureEscrowAccount(db, escrowKey, opts = {}) {
|
|
106
|
+
const accountId = escrowAccountId(escrowKey);
|
|
107
|
+
const ts = opts.now ?? nowIso();
|
|
108
|
+
db.prepare(`
|
|
109
|
+
INSERT OR IGNORE INTO sc_accounts
|
|
110
|
+
(account_id, account_type, operator_id, currency, balance_units, last_activity_at, created_at, updated_at)
|
|
111
|
+
VALUES (?, 'escrow', NULL, 'SC', 0, ?, ?, ?)
|
|
112
|
+
`).run(accountId, ts, ts, ts);
|
|
113
|
+
const row = db.prepare('SELECT * FROM sc_accounts WHERE account_id = ?').get(accountId);
|
|
114
|
+
return hydrateAccount(row);
|
|
115
|
+
}
|
|
116
|
+
/** Marks an operator's identity as bonded (e.g., GitHub, ORCID, Stripe card check) for the tau trust ramp. */
|
|
117
|
+
export function setOperatorIdentityBond(db, operatorId, params) {
|
|
118
|
+
const ts = params.now ?? nowIso();
|
|
119
|
+
const acc = ensureOperatorAccount(db, operatorId, { now: ts });
|
|
120
|
+
db.prepare(`
|
|
121
|
+
UPDATE sc_accounts
|
|
122
|
+
SET identity_bonded = ?,
|
|
123
|
+
bond_provider = ?,
|
|
124
|
+
bonded_at = ?,
|
|
125
|
+
updated_at = ?
|
|
126
|
+
WHERE account_id = ?
|
|
127
|
+
`).run(params.bonded ? 1 : 0, params.bonded ? (params.provider ?? 'verified') : null, params.bonded ? ts : null, ts, acc.account_id);
|
|
128
|
+
const updated = db.prepare('SELECT * FROM sc_accounts WHERE account_id = ?').get(acc.account_id);
|
|
129
|
+
return hydrateAccount(updated);
|
|
130
|
+
}
|
|
131
|
+
/** Fetches an operator's SC account (returning a zero-balance view if not yet materialized). */
|
|
132
|
+
export function getOperatorAccount(db, operatorId) {
|
|
133
|
+
const cleanOp = operatorId.startsWith('op:') ? operatorId.slice(3) : operatorId.trim();
|
|
134
|
+
const accountId = operatorAccountId(cleanOp);
|
|
135
|
+
const row = db.prepare('SELECT * FROM sc_accounts WHERE account_id = ?').get(accountId);
|
|
136
|
+
if (row)
|
|
137
|
+
return hydrateAccount(row);
|
|
138
|
+
const ts = nowIso();
|
|
139
|
+
return {
|
|
140
|
+
account_id: accountId,
|
|
141
|
+
account_type: 'operator',
|
|
142
|
+
operator_id: cleanOp,
|
|
143
|
+
currency: 'SC',
|
|
144
|
+
identity_bonded: false,
|
|
145
|
+
bond_provider: null,
|
|
146
|
+
bonded_at: null,
|
|
147
|
+
balance_units: 0,
|
|
148
|
+
balance_sc: 0,
|
|
149
|
+
last_activity_at: ts,
|
|
150
|
+
created_at: ts,
|
|
151
|
+
updated_at: ts,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Returns an operator's current SC balance in both integer units and decimal SC. */
|
|
155
|
+
export function getOperatorBalance(db, operatorId) {
|
|
156
|
+
const acc = getOperatorAccount(db, operatorId);
|
|
157
|
+
return {
|
|
158
|
+
operator_id: acc.operator_id,
|
|
159
|
+
balance_units: acc.balance_units,
|
|
160
|
+
balance_sc: acc.balance_sc,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Checks whether a workspace is eligible for global Swarm Credit minting.
|
|
165
|
+
* Rule (Doc 08 §2): Global SC mints EXCLUSIVELY on audited public or sponsored public workspaces.
|
|
166
|
+
* Private workspaces ALWAYS return `eligible: false` (zero-sum transfers only).
|
|
167
|
+
*/
|
|
168
|
+
export function checkWorkspaceMintEligibility(db, workspaceId, opts = {}) {
|
|
169
|
+
const ws = db.prepare('SELECT * FROM workspaces WHERE id = ? OR slug = ?').get(workspaceId, workspaceId);
|
|
170
|
+
if (!ws) {
|
|
171
|
+
return { eligible: false, reason: `Workspace '${workspaceId}' not found` };
|
|
172
|
+
}
|
|
173
|
+
if (ws.visibility !== 'public') {
|
|
174
|
+
return {
|
|
175
|
+
eligible: false,
|
|
176
|
+
reason: `Private workspace '${ws.id}' cannot mint global Swarm Credits (zero-sum transfers only)`,
|
|
177
|
+
workspace: ws,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const policy = String(ws.sc_minting_policy ?? 'audited_public');
|
|
181
|
+
if (policy === 'zero_sum_only') {
|
|
182
|
+
return {
|
|
183
|
+
eligible: false,
|
|
184
|
+
reason: `Workspace '${ws.id}' has sc_minting_policy='zero_sum_only'`,
|
|
185
|
+
workspace: ws,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Sponsored public workspaces are pre-approved; audited_public workspaces must have at least one
|
|
189
|
+
// verified FormalizationAudit (when FormalizationAudit nodes exist in the workspace).
|
|
190
|
+
const requireAudited = opts.requireAudited ?? true;
|
|
191
|
+
if (requireAudited && policy === 'audited_public') {
|
|
192
|
+
const auditStats = db
|
|
193
|
+
.prepare(`
|
|
194
|
+
SELECT
|
|
195
|
+
COUNT(*) AS total_audits,
|
|
196
|
+
SUM(CASE WHEN status = 'verified' THEN 1 ELSE 0 END) AS verified_audits
|
|
197
|
+
FROM nodes
|
|
198
|
+
WHERE workspace_id = ? AND type = 'FormalizationAudit'
|
|
199
|
+
`)
|
|
200
|
+
.get(ws.id);
|
|
201
|
+
if (Number(auditStats.total_audits) > 0 && Number(auditStats.verified_audits ?? 0) === 0) {
|
|
202
|
+
return {
|
|
203
|
+
eligible: false,
|
|
204
|
+
reason: `Workspace '${ws.id}' has no verified FormalizationAudit nodes yet`,
|
|
205
|
+
workspace: ws,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return { eligible: true, workspace: ws };
|
|
210
|
+
}
|
|
211
|
+
function loadJournalEntry(db, entryId) {
|
|
212
|
+
const header = db.prepare('SELECT * FROM sc_journal_entries WHERE id = ?').get(entryId);
|
|
213
|
+
if (!header) {
|
|
214
|
+
throw new SwarmError('NOT_FOUND', `Journal entry '${entryId}' not found`);
|
|
215
|
+
}
|
|
216
|
+
const lines = db
|
|
217
|
+
.prepare('SELECT * FROM sc_ledger_lines WHERE entry_id = ? ORDER BY rowid ASC')
|
|
218
|
+
.all(entryId);
|
|
219
|
+
return {
|
|
220
|
+
id: String(header.id),
|
|
221
|
+
idempotency_key: header.idempotency_key ? String(header.idempotency_key) : null,
|
|
222
|
+
entry_type: header.entry_type,
|
|
223
|
+
currency: 'SC',
|
|
224
|
+
workspace_id: header.workspace_id ? String(header.workspace_id) : null,
|
|
225
|
+
reference_type: header.reference_type ? String(header.reference_type) : null,
|
|
226
|
+
reference_id: header.reference_id ? String(header.reference_id) : null,
|
|
227
|
+
memo: String(header.memo ?? ''),
|
|
228
|
+
metadata: JSON.parse(String(header.metadata || '{}')),
|
|
229
|
+
created_at: String(header.created_at),
|
|
230
|
+
lines: lines.map((l) => ({
|
|
231
|
+
id: String(l.id),
|
|
232
|
+
entry_id: String(l.entry_id),
|
|
233
|
+
account_id: String(l.account_id),
|
|
234
|
+
delta_units: Number(l.delta_units),
|
|
235
|
+
delta_sc: unitsToSc(Number(l.delta_units)),
|
|
236
|
+
balance_after_units: Number(l.balance_after_units),
|
|
237
|
+
balance_after_sc: unitsToSc(Number(l.balance_after_units)),
|
|
238
|
+
created_at: String(l.created_at),
|
|
239
|
+
})),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Posts an atomic double-entry journal transaction into the immutable SC ledger.
|
|
244
|
+
* Enforces:
|
|
245
|
+
* - Strict zero-sum across all legs (`sum(deltaUnits) === 0`)
|
|
246
|
+
* - Dual-ledger firewall (`currency === 'SC'`)
|
|
247
|
+
* - Non-negative balance on all `operator` and `escrow` accounts
|
|
248
|
+
* - Strict audited-public workspace rule for `mint` entries
|
|
249
|
+
* - Idempotency via `idempotencyKey`
|
|
250
|
+
*/
|
|
251
|
+
export function postJournalEntry(db, params) {
|
|
252
|
+
assertSwarmCreditFirewall(params.currency, params.entryType);
|
|
253
|
+
if (params.legs.length < 2) {
|
|
254
|
+
throw new SwarmError('INVALID_INPUT', 'Double-entry journal requires at least 2 legs');
|
|
255
|
+
}
|
|
256
|
+
let legSum = 0;
|
|
257
|
+
for (const leg of params.legs) {
|
|
258
|
+
if (!Number.isInteger(leg.deltaUnits) || leg.deltaUnits === 0) {
|
|
259
|
+
throw new SwarmError('INVALID_INPUT', `Ledger leg deltaUnits must be a non-zero integer (got ${leg.deltaUnits})`);
|
|
260
|
+
}
|
|
261
|
+
legSum += leg.deltaUnits;
|
|
262
|
+
}
|
|
263
|
+
if (legSum !== 0) {
|
|
264
|
+
throw new SwarmError('INVALID_INPUT', `Double-entry invariant violated: legs sum to ${legSum} units (must be 0)`);
|
|
265
|
+
}
|
|
266
|
+
// Enforce strict global minting restriction
|
|
267
|
+
const touchesMintAccount = params.legs.some((l) => l.accountId === SYSTEM_MINT_ACCOUNT);
|
|
268
|
+
if (params.entryType === 'mint' || touchesMintAccount) {
|
|
269
|
+
if (params.entryType !== 'mint') {
|
|
270
|
+
throw new SwarmError('UNAUTHORIZED', `Only entry_type='mint' may debit ${SYSTEM_MINT_ACCOUNT}`);
|
|
271
|
+
}
|
|
272
|
+
if (!params.workspaceId) {
|
|
273
|
+
throw new SwarmError('UNAUTHORIZED', 'Global SC minting requires an audited public or sponsored workspaceId');
|
|
274
|
+
}
|
|
275
|
+
const elig = checkWorkspaceMintEligibility(db, params.workspaceId, {
|
|
276
|
+
requireAudited: params.requireAuditedWorkspace ?? true,
|
|
277
|
+
});
|
|
278
|
+
if (!elig.eligible) {
|
|
279
|
+
throw new SwarmError('UNAUTHORIZED', elig.reason ?? 'Workspace not eligible for SC minting');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const ts = params.now ?? nowIso();
|
|
283
|
+
const tx = db.transaction(() => {
|
|
284
|
+
// Check idempotency key inside transaction
|
|
285
|
+
if (params.idempotencyKey) {
|
|
286
|
+
const existing = db
|
|
287
|
+
.prepare('SELECT id FROM sc_journal_entries WHERE idempotency_key = ?')
|
|
288
|
+
.get(params.idempotencyKey);
|
|
289
|
+
if (existing) {
|
|
290
|
+
return loadJournalEntry(db, existing.id);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
ensureSystemAccounts(db, ts);
|
|
294
|
+
// Ensure all referenced accounts exist
|
|
295
|
+
for (const leg of params.legs) {
|
|
296
|
+
if (leg.accountId.startsWith('op:')) {
|
|
297
|
+
ensureOperatorAccount(db, leg.accountId.slice(3), { now: ts });
|
|
298
|
+
}
|
|
299
|
+
else if (leg.accountId.startsWith('escrow:')) {
|
|
300
|
+
ensureEscrowAccount(db, leg.accountId.slice(7), { now: ts });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const entryId = newId('scj');
|
|
304
|
+
db.prepare(`
|
|
305
|
+
INSERT INTO sc_journal_entries
|
|
306
|
+
(id, idempotency_key, entry_type, currency, workspace_id, reference_type, reference_id, memo, metadata, created_at)
|
|
307
|
+
VALUES (?, ?, ?, 'SC', ?, ?, ?, ?, ?, ?)
|
|
308
|
+
`).run(entryId, params.idempotencyKey ?? null, params.entryType, params.workspaceId ?? null, params.referenceType ?? null, params.referenceId ?? null, params.memo ?? '', JSON.stringify(params.metadata ?? {}), ts);
|
|
309
|
+
const touchedOperators = new Map();
|
|
310
|
+
for (const leg of params.legs) {
|
|
311
|
+
const acct = db
|
|
312
|
+
.prepare('SELECT account_id, account_type, operator_id, balance_units FROM sc_accounts WHERE account_id = ?')
|
|
313
|
+
.get(leg.accountId);
|
|
314
|
+
if (!acct) {
|
|
315
|
+
throw new SwarmError('NOT_FOUND', `SC ledger account '${leg.accountId}' not found`);
|
|
316
|
+
}
|
|
317
|
+
const nextBalance = Number(acct.balance_units) + leg.deltaUnits;
|
|
318
|
+
if ((acct.account_type === 'operator' || acct.account_type === 'escrow') && nextBalance < 0) {
|
|
319
|
+
throw new SwarmError('INVALID_INPUT', `Insufficient SC balance in account '${leg.accountId}': have ${unitsToSc(Number(acct.balance_units))} SC, need ${unitsToSc(-leg.deltaUnits)} SC`, false, {
|
|
320
|
+
account_id: leg.accountId,
|
|
321
|
+
available_units: Number(acct.balance_units),
|
|
322
|
+
required_units: -leg.deltaUnits,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
const touchActivity = leg.touchActivity !== undefined
|
|
326
|
+
? leg.touchActivity
|
|
327
|
+
: acct.account_type === 'operator' && params.entryType !== 'burn_demurrage';
|
|
328
|
+
if (touchActivity) {
|
|
329
|
+
db.prepare(`
|
|
330
|
+
UPDATE sc_accounts
|
|
331
|
+
SET balance_units = ?, last_activity_at = ?, updated_at = ?
|
|
332
|
+
WHERE account_id = ?
|
|
333
|
+
`).run(nextBalance, ts, ts, leg.accountId);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
db.prepare(`
|
|
337
|
+
UPDATE sc_accounts
|
|
338
|
+
SET balance_units = ?, updated_at = ?
|
|
339
|
+
WHERE account_id = ?
|
|
340
|
+
`).run(nextBalance, ts, leg.accountId);
|
|
341
|
+
}
|
|
342
|
+
const lineId = newId('scl');
|
|
343
|
+
db.prepare(`
|
|
344
|
+
INSERT INTO sc_ledger_lines (id, entry_id, account_id, delta_units, balance_after_units, created_at)
|
|
345
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
346
|
+
`).run(lineId, entryId, leg.accountId, leg.deltaUnits, nextBalance, ts);
|
|
347
|
+
if (acct.account_type === 'operator' && acct.operator_id) {
|
|
348
|
+
touchedOperators.set(String(acct.operator_id), nextBalance);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// Keep cached agent_identities.credit_balance_units synced for affected operators
|
|
352
|
+
const syncStmt = db.prepare('UPDATE agent_identities SET credit_balance_units = ? WHERE operator_id = ?');
|
|
353
|
+
for (const [opId, bal] of touchedOperators.entries()) {
|
|
354
|
+
syncStmt.run(bal, opId);
|
|
355
|
+
}
|
|
356
|
+
return loadJournalEntry(db, entryId);
|
|
357
|
+
});
|
|
358
|
+
return tx.immediate();
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Mints global Swarm Credits to an operator exclusively from an audited/sponsored PUBLIC workspace.
|
|
362
|
+
* Debits `sys:mint` and credits `op:<operatorId>`.
|
|
363
|
+
*/
|
|
364
|
+
export function mintSwarmCredits(db, params) {
|
|
365
|
+
if (!Number.isInteger(params.amountUnits) || params.amountUnits <= 0) {
|
|
366
|
+
throw new SwarmError('INVALID_INPUT', `Mint amountUnits must be a positive integer (got ${params.amountUnits})`);
|
|
367
|
+
}
|
|
368
|
+
return postJournalEntry(db, {
|
|
369
|
+
entryType: 'mint',
|
|
370
|
+
currency: 'SC',
|
|
371
|
+
workspaceId: params.workspaceId,
|
|
372
|
+
referenceType: params.referenceType ?? 'issuance',
|
|
373
|
+
referenceId: params.referenceId ?? null,
|
|
374
|
+
memo: params.memo ?? `SC mint for ${params.operatorId} in ${params.workspaceId}`,
|
|
375
|
+
metadata: params.metadata,
|
|
376
|
+
idempotencyKey: params.idempotencyKey ?? null,
|
|
377
|
+
now: params.now,
|
|
378
|
+
requireAuditedWorkspace: params.requireAuditedWorkspace,
|
|
379
|
+
legs: [
|
|
380
|
+
{ accountId: SYSTEM_MINT_ACCOUNT, deltaUnits: -params.amountUnits, touchActivity: false },
|
|
381
|
+
{ accountId: operatorAccountId(params.operatorId), deltaUnits: params.amountUnits, touchActivity: true },
|
|
382
|
+
],
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Zero-sum peer-to-peer Swarm Credit transfer between two operators.
|
|
387
|
+
* Permitted in BOTH public and private workspaces (never mints new SC).
|
|
388
|
+
*/
|
|
389
|
+
export function transferSwarmCredits(db, params) {
|
|
390
|
+
const fromAcc = operatorAccountId(params.fromOperatorId);
|
|
391
|
+
const toAcc = operatorAccountId(params.toOperatorId);
|
|
392
|
+
if (fromAcc === toAcc) {
|
|
393
|
+
throw new SwarmError('INVALID_INPUT', 'Cannot transfer Swarm Credits to the same operator');
|
|
394
|
+
}
|
|
395
|
+
if (!Number.isInteger(params.amountUnits) || params.amountUnits <= 0) {
|
|
396
|
+
throw new SwarmError('INVALID_INPUT', `Transfer amountUnits must be a positive integer (got ${params.amountUnits})`);
|
|
397
|
+
}
|
|
398
|
+
return postJournalEntry(db, {
|
|
399
|
+
entryType: 'transfer',
|
|
400
|
+
currency: 'SC',
|
|
401
|
+
workspaceId: params.workspaceId ?? null,
|
|
402
|
+
referenceType: params.referenceType ?? 'p2p_transfer',
|
|
403
|
+
referenceId: params.referenceId ?? null,
|
|
404
|
+
memo: params.memo ?? `Zero-sum transfer ${fromAcc} -> ${toAcc}`,
|
|
405
|
+
metadata: params.metadata,
|
|
406
|
+
idempotencyKey: params.idempotencyKey ?? null,
|
|
407
|
+
now: params.now,
|
|
408
|
+
legs: [
|
|
409
|
+
{ accountId: fromAcc, deltaUnits: -params.amountUnits, touchActivity: true },
|
|
410
|
+
{ accountId: toAcc, deltaUnits: params.amountUnits, touchActivity: true },
|
|
411
|
+
],
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/** Lists recent journal entries affecting a specific operator (newest first). */
|
|
415
|
+
export function listOperatorLedgerEntries(db, operatorId, limit = 50) {
|
|
416
|
+
const accId = operatorAccountId(operatorId);
|
|
417
|
+
const entryIds = db
|
|
418
|
+
.prepare(`
|
|
419
|
+
SELECT DISTINCT l.entry_id
|
|
420
|
+
FROM sc_ledger_lines l
|
|
421
|
+
JOIN sc_journal_entries j ON j.id = l.entry_id
|
|
422
|
+
WHERE l.account_id = ?
|
|
423
|
+
ORDER BY j.created_at DESC, j.id DESC
|
|
424
|
+
LIMIT ?
|
|
425
|
+
`)
|
|
426
|
+
.all(accId, Math.max(1, Math.min(500, limit)));
|
|
427
|
+
return entryIds.map((r) => loadJournalEntry(db, r.entry_id));
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Audits full double-entry ledger integrity:
|
|
431
|
+
* - Every journal entry sums to 0 with >= 2 legs
|
|
432
|
+
* - Every account's cached `balance_units` equals the sum of its ledger lines
|
|
433
|
+
* - Global trial balance across all accounts equals 0
|
|
434
|
+
* - No operator/escrow account has negative balance
|
|
435
|
+
* - No `mint` entry references a private workspace or non-SC currency
|
|
436
|
+
*/
|
|
437
|
+
export function verifyLedgerIntegrity(db) {
|
|
438
|
+
ensureSystemAccounts(db);
|
|
439
|
+
const violations = [];
|
|
440
|
+
const accounts = db.prepare('SELECT * FROM sc_accounts').all();
|
|
441
|
+
const entries = db.prepare('SELECT * FROM sc_journal_entries').all();
|
|
442
|
+
const lineCountRow = db.prepare('SELECT COUNT(*) AS cnt FROM sc_ledger_lines').get();
|
|
443
|
+
// 1. Every journal entry sums to 0 and has >= 2 lines
|
|
444
|
+
const unbalancedEntries = db
|
|
445
|
+
.prepare(`
|
|
446
|
+
SELECT j.id, COUNT(l.id) AS leg_count, COALESCE(SUM(l.delta_units), 0) AS net_delta
|
|
447
|
+
FROM sc_journal_entries j
|
|
448
|
+
LEFT JOIN sc_ledger_lines l ON l.entry_id = j.id
|
|
449
|
+
GROUP BY j.id
|
|
450
|
+
HAVING COUNT(l.id) < 2 OR COALESCE(SUM(l.delta_units), 0) <> 0
|
|
451
|
+
`)
|
|
452
|
+
.all();
|
|
453
|
+
for (const row of unbalancedEntries) {
|
|
454
|
+
violations.push(`Entry ${row.id} unbalanced (legs=${row.leg_count}, sum=${row.net_delta})`);
|
|
455
|
+
}
|
|
456
|
+
// 2. Account balance reconciliation against immutable lines
|
|
457
|
+
const lineSums = new Map();
|
|
458
|
+
const sumRows = db
|
|
459
|
+
.prepare('SELECT account_id, COALESCE(SUM(delta_units), 0) AS total FROM sc_ledger_lines GROUP BY account_id')
|
|
460
|
+
.all();
|
|
461
|
+
for (const r of sumRows) {
|
|
462
|
+
lineSums.set(r.account_id, Number(r.total));
|
|
463
|
+
}
|
|
464
|
+
let trialBalance = 0;
|
|
465
|
+
let circulatingUnits = 0;
|
|
466
|
+
let totalMintedUnits = 0;
|
|
467
|
+
let totalBurnedUnits = 0;
|
|
468
|
+
let totalDemurrageUnits = 0;
|
|
469
|
+
for (const a of accounts) {
|
|
470
|
+
const bal = Number(a.balance_units);
|
|
471
|
+
const expected = lineSums.get(a.account_id) ?? 0;
|
|
472
|
+
trialBalance += bal;
|
|
473
|
+
if (bal !== expected) {
|
|
474
|
+
violations.push(`Account ${a.account_id} balance mismatch: stored=${bal}, sum_lines=${expected}`);
|
|
475
|
+
}
|
|
476
|
+
if ((a.account_type === 'operator' || a.account_type === 'escrow') && bal < 0) {
|
|
477
|
+
violations.push(`Account ${a.account_id} has negative balance: ${bal}`);
|
|
478
|
+
}
|
|
479
|
+
if (a.currency !== 'SC') {
|
|
480
|
+
violations.push(`Account ${a.account_id} violates SC currency firewall: ${a.currency}`);
|
|
481
|
+
}
|
|
482
|
+
if (a.account_type === 'operator' || a.account_type === 'escrow') {
|
|
483
|
+
circulatingUnits += bal;
|
|
484
|
+
}
|
|
485
|
+
else if (a.account_id === SYSTEM_MINT_ACCOUNT) {
|
|
486
|
+
totalMintedUnits = -bal;
|
|
487
|
+
}
|
|
488
|
+
else if (a.account_id === SYSTEM_BURN_ACCOUNT) {
|
|
489
|
+
totalBurnedUnits = bal;
|
|
490
|
+
}
|
|
491
|
+
else if (a.account_id === SYSTEM_DEMURRAGE_ACCOUNT) {
|
|
492
|
+
totalDemurrageUnits = bal;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (trialBalance !== 0) {
|
|
496
|
+
violations.push(`Global trial balance non-zero: ${trialBalance}`);
|
|
497
|
+
}
|
|
498
|
+
// 3. Mint entries must strictly reference public workspaces
|
|
499
|
+
const illegalMints = db
|
|
500
|
+
.prepare(`
|
|
501
|
+
SELECT j.id, j.workspace_id, w.visibility
|
|
502
|
+
FROM sc_journal_entries j
|
|
503
|
+
LEFT JOIN workspaces w ON w.id = j.workspace_id
|
|
504
|
+
WHERE j.entry_type = 'mint'
|
|
505
|
+
AND (j.workspace_id IS NULL OR w.id IS NULL OR w.visibility <> 'public')
|
|
506
|
+
`)
|
|
507
|
+
.all();
|
|
508
|
+
for (const row of illegalMints) {
|
|
509
|
+
violations.push(`Illegal mint entry ${row.id}: workspace=${row.workspace_id ?? 'NULL'}, visibility=${row.visibility ?? 'MISSING'}`);
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
ok: violations.length === 0,
|
|
513
|
+
total_accounts: accounts.length,
|
|
514
|
+
total_entries: entries.length,
|
|
515
|
+
total_lines: Number(lineCountRow.cnt),
|
|
516
|
+
trial_balance_units: trialBalance,
|
|
517
|
+
circulating_supply_units: circulatingUnits,
|
|
518
|
+
circulating_supply_sc: unitsToSc(circulatingUnits),
|
|
519
|
+
total_minted_units: totalMintedUnits,
|
|
520
|
+
total_minted_sc: unitsToSc(totalMintedUnits),
|
|
521
|
+
total_burned_units: totalBurnedUnits,
|
|
522
|
+
total_burned_sc: unitsToSc(totalBurnedUnits),
|
|
523
|
+
total_demurrage_units: totalDemurrageUnits,
|
|
524
|
+
total_demurrage_sc: unitsToSc(totalDemurrageUnits),
|
|
525
|
+
violations,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
//# sourceMappingURL=scLedger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scLedger.js","sourceRoot":"","sources":["../../src/economy/scLedger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,mDAAmD;AACnD,uEAAuE;AACvE,EAAE;AACF,mBAAmB;AACnB,iFAAiF;AACjF,gFAAgF;AAChF,sFAAsF;AACtF,2FAA2F;AAC3F,wFAAwF;AACxF,uEAAuE;AACvE,iFAAiF;AACjF,oDAAoD;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AA8ExD,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,IAAI,CAAC,MAAM,CA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