Skip to main content
Loading navigation
Back to prompt library

Build a Delegated Consent Receipt and Agent Activity Auditor — implementation

Linked challenge: Build a Delegated Consent Receipt and Agent Activity Auditor

Prompt source

implementation91 lines11 sectionsNo variables1 code block
## Build
Inspect delegated agent actions across e-commerce procurement workflows against user consent receipts. Verify authorization bounds, time-to-live expirations, and permissible transaction values.

## User
Digital Governance Auditor

## Workflow
1. Parse machine-readable consent receipts containing delegation scopes and expiry timestamps.
2. Ingest simulated autonomous agent transaction logs from buyer platform adapters.
3. Compare item purchase categories and monetary values against authorized consent thresholds.
4. Emit audit reports flagging out-of-scope actions and revoking breached delegation tokens.

## Interface
Audit timeline showing active consent grants, incoming agent actions, and scope compliance indicators.

## Data
Generate synthetic JSON consent receipts and mocked Beckn order transaction records.
Starter examples below are synthetic. They are not downloaded records.

## Source
[ONDC protocol specifications](https://raw.githubusercontent.com/ONDC-Official/ONDC-Protocol-Specs/master/README.md)
Uses ONDC open network transaction semantics to validate delegated ordering requests against buyer intent.

## Tools
pydantic-ai, sqlmodel, rich.
Enforces strict typing and condition checking on consent receipt bounds and audit claims.
Local or hosted LLM for explaining discrepancy reasons in human-readable terms.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Accurately detects transactions that exceed permitted spending thresholds.
- Validates consent expiry timestamps against transaction receipt context.
- Outputs structured compliance scorecards with explicit violation line-items.
- Maintains an immutable mock ledger of evaluated transactions.

## Starter Examples
```json
[
  {
    "input": {
      "consent_receipt": {
        "consent_id": "CON-101",
        "delegate_agent_id": "AGT-AUTO-BUY",
        "allowed_categories": [
          "grocery",
          "stationery"
        ],
        "max_transaction_inr": 2000,
        "valid_until": "2026-12-31T23:59:59Z"
      },
      "transaction_event": {
        "event_id": "EVT-881",
        "timestamp": "2026-05-10T10:15:00Z",
        "category": "grocery",
        "amount_inr": 1450,
        "item_count": 4
      }
    },
    "expected_output": {
      "status": "APPROVED",
      "consent_valid": true,
      "violations": []
    }
  },
  {
    "input": {
      "consent_receipt": {
        "consent_id": "CON-102",
        "delegate_agent_id": "AGT-AUTO-BUY",
        "allowed_categories": [
          "stationery"
        ],
        "max_transaction_inr": 500,
        "valid_until": "2026-06-01T00:00:00Z"
      },
      "transaction_event": {
        "event_id": "EVT-882",
        "timestamp": "2026-06-02T11:00:00Z",
        "category": "electronics",
        "amount_inr": 1200,
        "item_count": 1
      }
    },
    "expected_output": {
      "status": "BLOCKED",
      "consent_valid": false,
      "violations": [
        "CONSENT_EXPIRED",
        "UNAUTHORIZED_CATEGORY_ELECTRONICS",
        "SPEND_LIMIT_EXCEEDED"
      ]
    }
  }
]
```

## Safety
Contains no real citizen identification records; validates simulated token boundaries on synthetic orders.
Use mock external writes. Require human review before any real deployment.