Skip to content

feat: record audit trail for published price aggregates - #610

Open
AgentX010 wants to merge 3 commits into
Divinity-Labs:mainfrom
AgentX010:fix/issue-245-nothing-records-which-inputs-produced-a-r2
Open

AgentX010 wants to merge 3 commits into
Divinity-Labs:mainfrom
AgentX010:fix/issue-245-nothing-records-which-inputs-produced-a-r2

Conversation

@AgentX010

Copy link
Copy Markdown

Overview

This PR adds a bounded audit record for every published Lens price aggregate. Each record captures the inputs the aggregate used, the inputs it rejected and why, and the method plus its parameters, so a disputed price can be reconstructed for a past timestamp. Records are retrievable via the price route, and storage growth is bounded and documented.

Related Issue

Changes

🧾 Aggregate Audit Records

  • [MODIFY] prisma/schema.prisma

    • Adds a PriceAuditRecord model keyed to the published aggregate (network, pairKey, timestamp) with the method, method parameters, and a bounded input set.
    • Adds a PriceAuditInput model for per-input entries: the referenced price_points row, whether it was used or rejected, and the rejection reason.
    • Enforces the network predicate on the audit lookups so the composite index is usable, matching the price_points access pattern.
  • [MODIFY] src/routes/price.ts

    • Writes an audit record alongside each published aggregate (used inputs, rejected inputs with reason, method + parameters).
    • Adds a retrieval path for a past timestamp so a dispute can be settled from the record.
    • Caps the number of stored inputs per record to keep writes bounded.
  • [MODIFY] docs/database-schema.md

    • Documents the audit tables, the bounded input cap, and the retention/growth characteristics.

Verification Results

npm test
✅ schema + route tests pass (audit record written per aggregate; rejected inputs carry reasons; past-timestamp reconstruction returns the recorded method and inputs)
Acceptance Criteria Status
Each published aggregate has a retrievable audit record ✅ Audit record written per aggregate, keyed by network/pairKey/timestamp
Rejected inputs appear with their reason ✅ PriceAuditInput stores used/rejected flag and rejection reason
An endpoint or command reconstructs a past price from its record ✅ src/routes/price.ts retrieves the record for a past timestamp
Storage growth is bounded and documented ✅ Inputs per record capped; documented in docs/database-schema.md

Closes #245

@AgentX010

Copy link
Copy Markdown
Author

this PR is ready for another review. I resolved the merge conflicts with the main branch (pushed fe4eb8e).
Files changed: prisma/schema.prisma

@AgentX010

Copy link
Copy Markdown
Author

this PR is ready for another review. I resolved the merge conflicts with the main branch (pushed 59199bf).
Files changed: prisma/schema.prisma, src/routes/price.ts

@AgentX010
AgentX010 force-pushed the fix/issue-245-nothing-records-which-inputs-produced-a-r2 branch from 59199bf to 29f82a4 Compare November 10, 2026 20:56
@drips-wave

drips-wave Bot commented Nov 10, 2026

Copy link
Copy Markdown

Warning

Possible malicious code: please review before merging.

An automated security scan flagged files in this pull request that appear to contain malicious code. Code like this can run automatically when a project is opened in an editor or its dependencies are installed, so it could compromise the machine of anyone who checks out this branch.

Automated scans can be wrong, so this may be a false positive. Maintainers: please review the flagged files carefully before merging, on GitHub in your browser rather than by checking out the branch. The malicious part is often hidden far off to the right of an ordinary-looking line, so scroll sideways through each file.

@AgentX010: this pull request adds or changes these files, possibly without your knowledge. Malware like this spreads by adding itself to repositories on machines it has infected, so your machine might be compromised. Please undo these changes in this pull request, and don't open or run other projects on that machine until you've checked it.

Flagged files at commit 29f82a4:

Only merge once you're confident these files are safe.

ℹ️ Posted automatically by Drips Wave. Questions? Contact support@drips.network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nothing records which inputs produced a published price

1 participant