@plasius/economy 0.7.0 → 0.9.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.md CHANGED
@@ -437,12 +437,80 @@ principal only and terminates with `WALLET_INITIALIZED` or
437
437
  double-entry transaction or Token activity row and does not authorize value or
438
438
  provider writes.
439
439
 
440
+ `initialize-admin-reporting` is also additive to the audited command union. It
441
+ is restricted to a service principal and the system source so a host can bind
442
+ one create-only reporting bootstrap to its normal authority head, manifest,
443
+ receipt, and idempotency evidence. It does not authorize a balance mutation or
444
+ replace an existing reporting projection.
445
+
440
446
  Activity reads use bounded opaque cursor pagination in stable descending
441
447
  `(occurredAt, activityId)` order. Each row retains the component `walletId`
442
448
  whose signed display amount it represents. Cursor contents and signatures are
443
449
  adapter concerns; `assertWalletActivityPageForPortfolio()` proves that a result
444
450
  never expands the authorized portfolio scope.
445
451
 
452
+ ## Pseudonymous Admin reporting
453
+
454
+ `AdminEconomyReportingQueryPortV1` defines provider-neutral global summary,
455
+ pseudonymous wallet balance, activity, and trend results for governed finance
456
+ operations. It does not grant access or query a database. A host must
457
+ authenticate the caller, enforce the stored rollout flags
458
+ `economy.admin-history.enabled` and `mcp.admin-economy-history.enabled` as
459
+ applicable, re-check the finance capability, and use a least-privilege
460
+ reporting projection.
461
+
462
+ The global summary is an identifier-free point-read projection. It contains
463
+ exact available, reserved, held, reward-progress and lifetime totals, wallet
464
+ counts, and the canonical positive authority sequence through which the
465
+ projection is current. Wallet balance pages contain separate audience-bound
466
+ wallet and subject aliases, a closed component/status code, exact non-negative
467
+ amounts, update time, and authority sequence. They are capped at 100 rows and
468
+ support stable available-descending or update-time-descending pagination.
469
+
470
+ Activity rows are deliberately narrow:
471
+
472
+ - timestamp, normalized type/status/source, and exact signed TokenSubunits;
473
+ - a closed non-identifying label code that the presentation layer maps to
474
+ localized text; and
475
+ - distinct opaque row and subject aliases produced by a versioned,
476
+ audience- and purpose-separated HMAC adapter.
477
+
478
+ The label-code allowlist is `token-acquisition`, `token-spend`,
479
+ `token-reversal`, `token-hold`, `token-activity-failed`,
480
+ `token-system-adjustment`, and `token-activity-unclassified`. A label must also
481
+ be valid for its activity type.
482
+
483
+ Failure rows may use exact zero when a failed workflow has no related economic
484
+ transaction or attempted amount. Zero remains invalid for every economically
485
+ meaningful activity type.
486
+
487
+ The validator accepts only plain enumerable data properties and rejects
488
+ serialization hooks and undeclared properties, including raw account, wallet,
489
+ transaction, order, payment, provider-event, idempotency, and journal-integrity
490
+ identifiers. It also rejects provider-specific source names and free-form
491
+ labels. Result metadata fixes `rawIdentifiersIncluded` to `false`.
492
+
493
+ Activity pages are capped at 100 rows. Cursor values use a versioned `c1.`
494
+ base64url confidentiality-protected opaque format and cannot contain raw
495
+ identifiers. A resumed request carries both that value and its trusted,
496
+ server-decoded binding to the original window, sort, filters, pseudonym
497
+ audience, and version. Result metadata echoes the normalized filter. The
498
+ deterministic default reporting window is 30 days and the interactive maximum
499
+ is 365 days.
500
+
501
+ Hourly trends are limited to 31 days and daily trends may cover the maximum
502
+ window. The result ceiling is 3,720 points, covering all five activity types
503
+ through the maximum hourly window. Trend cohorts with fewer than five distinct
504
+ subjects contain only a suppression marker.
505
+
506
+ Reported trend points carry either a calculated 28-window same-time
507
+ conventional median/MAD indicator or an explicit unavailable result. Only
508
+ non-suppressed baseline cohorts may enter the calculation. Median and MAD
509
+ values use reduced exact rational TokenSubunits with denominators up to two,
510
+ so no floating point or rounding is introduced. Indicators are review alerts
511
+ only and never mutate the ledger. Routine contracts contain no
512
+ identity-resolution operation.
513
+
446
514
  ## Persistence ports
447
515
 
448
516
  `EconomyPersistencePort` remains exported unchanged for existing consumers.