---
id: WF-PFM-INT-020
title: Test an extension handler
trigger: The initiating configuration administrator starts this flow.
product_area: platform
module: integrations
revision: 1
status: draft
design_intent: proposed
implementation_evidence: partially-observed
inference: []
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-PFM-INT-017
crosses: []
idempotency: Each test receives a separate invocation identity and can add another test record.
concurrency: Testing reads customer facts without changing business records and writes only its invocation outcome.
hops:
  - 'n': 1
    actor_or_service: Configuration administrator
    action: 'Request a test using a contract example or supplied input and the requested mode, defaulting to quote.'
    anchor: 'services-platform:modules/extensions/aws/api/extensions.routes.ts'
    seam: sync
    on_failure: Return request validation failure.
    left_inconsistent: No invocation is run.
    observer: The administrator
    provenance: observed
    source: 'services-platform:modules/extensions/aws/api/extensions.routes.ts'
  - 'n': 2
    actor_or_service: Extensions service
    action: Check test input against the chosen point-version input contract.
    anchor: 'services-platform:modules/extensions/services/test-invocation/test-handler.ts:testHandler'
    seam: sync
    on_failure: Return a contract error without executing the handler.
    left_inconsistent: No test invocation is written for rejected input.
    observer: The administrator
    provenance: observed
    source: 'services-platform:modules/extensions/services/test-invocation/test-handler.ts:testHandler'
  - 'n': 3
    actor_or_service: Extensions service
    action: 'For a non-rule handler, report that Platform has no configured test transport.'
    anchor: 'services-platform:modules/extensions/services/test-invocation/test-handler.ts:testHandler'
    seam: sync
    on_failure: Return the transport-unavailable result.
    left_inconsistent: No code invocation or invocation record is produced.
    observer: The administrator
    provenance: observed
    source: 'services-platform:modules/extensions/services/test-invocation/test-handler.ts:testHandler'
  - 'n': 4
    actor_or_service: Rule evaluator
    action: >-
      Evaluate a rule within its timeout budget, reading query facts for the same person with request-local
      caching.
    anchor: 'services-platform:modules/extensions/services/rules/record-facts.ts'
    seam: sync
    on_failure: Unavailable facts become unknown; timeout returns failure.
    left_inconsistent: Business records remain unchanged by the test.
    observer: The administrator
    provenance: observed
    source: 'services-platform:modules/extensions/services/rules/record-facts.ts'
  - 'n': 5
    actor_or_service: Extensions service
    action: Validate rule output or neutral output and record the test invocation and result.
    anchor: 'services-platform:modules/extensions/services/persistence/extension-invocations.ts'
    seam: sync
    on_failure: An invocation-recording failure fails the request.
    left_inconsistent: The evaluated result may have been computed without a saved invocation.
    observer: Invocation history
    provenance: observed
    source: 'services-platform:modules/extensions/services/persistence/extension-invocations.ts'
evidence:
  - >-
    services-platform at ad3f6a65: modules/extensions/services/test-invocation/test-handler.ts;
    services/rules/record-facts.ts, rule-transport.ts; docs/extensions.md (Rule handlers)
  - >-
    services-platform:modules/extensions/tests/e2e/rule-handlers.e2e.spec.js#records each run as a test
    invocation of the handler
  - >-
    services-platform:modules/extensions/tests/e2e/rule-handlers.e2e.spec.js#records each run as a test
    invocation of the handler
  - >-
    services-platform:modules/extensions/tests/e2e/rule-handlers.e2e.spec.js#records each run as a test
    invocation of the handler
  - >-
    services-platform:modules/extensions/tests/unit/rule-handlers.spec.js#answers FALSE for a subject no row
    answered, known absent
  - >-
    services-platform:modules/extensions/tests/e2e/rule-handlers.e2e.spec.js#records each run as a test
    invocation of the handler
controls: [TC-AVL-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-CRY-001, TC-CRY-002, TC-CRY-003, TC-CRY-004, TC-DAT-001, TC-DAT-003, TC-DAT-004, TC-DAT-006, TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-005, TC-SEC-001, TC-SEC-002, TC-SEC-003, TC-SEC-004, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-VEN-001, TC-VEN-002, TC-VEN-003]
---

# Test an extension handler

## What It Does

Handler tests validate a contract example or supplied input before running anything. Platform can evaluate a rule against live read-only facts and retain its test result. Non-rule handlers have no configured Platform test transport.

## The Flow

```mermaid
sequenceDiagram
  participant P0 as Configuration administrator
  participant P1 as Extensions service
  participant P2 as Rule evaluator
  P0->>P0: 1. Request a test using a contract example or supplied input and the requested mode
  P1->>P1: 2. Check test input against the chosen point-version input contract.
  P1->>P1: 3. For a non-rule handler
  P2->>P2: 4. Evaluate a rule within its timeout budget
  P1->>P1: 5. Validate rule output or neutral output and record the test invocation and result.
```

## When Something Fails

Return request validation failure. No invocation is run. Return a contract error without executing the handler. No test invocation is written for rejected input. Return the transport-unavailable result. No code invocation or invocation record is produced. Unavailable facts become unknown; timeout returns failure. Business records remain unchanged by the test. An invocation-recording failure fails the request. The evaluated result may have been computed without a saved invocation.

## Open Design Questions

Production screens show an unavailable message; mock previews do not establish connection to this service test path. External fact grants and code-handler transport remain incomplete.
