---
id: ATS-PFM-QRY-020
scope: CAP-PFM-QRY-020
product_area: platform
module: queries
revision: 2
status: proposed
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
  rhythm-v2-docs: 99376625d3e7ac26936413cfc31a88fba6562464
scenarios:
  - id: ATS-PFM-QRY-020-01
    title: User callers cannot evaluate system conditions
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-01
    preconditions: A system context and a user context ask about the same contacts.
    steps: Evaluate the conditions and request their compilation as each context.
    expected: The system evaluation works; both user operations are refused.
    negative: true
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to:
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#refuses
        a user execution, because predicates are evaluated by the macroservice itself
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#refuses
        a user execution asking only for the statement
      - TST-PFM-QRY-266
    provenance: test
    source: >-
      services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#refuses
      a user execution, because predicates are evaluated by the macroservice itself
    category: permission
  - id: ATS-PFM-QRY-020-02
    title: Invalid evaluation lists are refused
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-02
    preconditions: A system context with access to a registered dataset.
    steps: 'Try empty and oversized subject and predicate lists, duplicate names and incompatible options.'
    expected: Each invalid request is refused before its statement runs.
    negative: true
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to: []
    provenance: proposed
    source: 'services-platform:modules/queries/services/execute/compile-predicates.ts:validPredicates'
    category: boundary
  - id: ATS-PFM-QRY-020-03
    title: Missing facts preserve the chosen null meaning
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-03
    preconditions: Contacts include known and absent values.
    steps: Evaluate positive and negated conditions under both null policies.
    expected: Default results retain unknown facts; filter-style results match the query’s treatment of those facts.
    negative: false
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to:
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#answers
        NULL for a predicate over a fact the contact does not have, when NULL means unknown
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#keeps
        a negated operator unknown over an absent value, and answers it as the filter does when NULL means
        false
      - TST-PFM-QRY-266
    provenance: test
    source: >-
      services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#answers
      NULL for a predicate over a fact the contact does not have, when NULL means unknown
    category: rule
  - id: ATS-PFM-QRY-020-04
    title: Collection calculations handle empty populations
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-04
    preconditions: 'Contacts have zero, one and several qualifying child records.'
    steps: 'Evaluate count, sum, minimum and maximum over their collections.'
    expected: Calculated values match qualifying children; empty collections return the stated zero or absent value.
    negative: false
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to: []
    provenance: proposed
    source: 'services-platform:modules/queries/services/execute/compile-query.ts:subjectPredicateCompiler'
    category: edge
  - id: ATS-PFM-QRY-020-05
    title: Evaluation follows the requested calendar day
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-05
    preconditions: A contact reaches an age threshold today and has dated affiliations.
    steps: Evaluate today and the previous day; use an invalid day and a date token on a non-date field.
    expected: The threshold changes with the chosen day; both invalid uses are refused.
    negative: true
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to:
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#resolves
        the same shift from the as-of day, so a contact eighteen today was not the day before
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#refuses
        an as-of value that is not a calendar date
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#refuses
        the as-of token on a field that is not a date
      - TST-PFM-QRY-266
    provenance: test
    source: >-
      services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#resolves
      the same shift from the as-of day, so a contact eighteen today was not the day before
    category: boundary
  - id: ATS-PFM-QRY-020-06
    title: Evaluation confines reads and avoids sensitive logs
    level: api
    proves:
      - BR-CAP-PFM-QRY-020-06
    preconditions: Two workspaces have records with the same identities.
    steps: 'Evaluate in each workspace and inspect the role, execution settings and emitted logs.'
    expected: >-
      Results contain only local records; database reads are read-only and logs contain no subject identities,
      values or statement text.
    negative: true
    data_needs: 'Controlled contacts, affiliations and system execution contexts.'
    bound_to: []
    provenance: proposed
    source: 'services-platform:modules/queries/services/execute/compile-predicates.ts:evaluateSubjectPredicates'
    category: invariant
  - id: ATS-PFM-QRY-020-07
    title: Dated conditions agree with a same-day question
    category: interaction
    level: api
    exercises:
      - CAP-PFM-QRY-002
      - CAP-PFM-QRY-020
    proves:
      - BR-CAP-PFM-QRY-002-10
      - BR-CAP-PFM-QRY-020-05
    preconditions: Two contacts straddle an age threshold on a chosen local calendar day.
    steps: Evaluate the dated predicate as a system caller and execute an equivalent contact question on that day.
    expected: >-
      The predicate’s true identities equal the contact question’s matching identities on each of two adjacent
      days.
    negative: false
    data_needs: Use a workspace calendar and two birthdays at the threshold.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-platform:modules/queries/tests/integration/services/execute/run-query.integration.spec.js#reads
        a day as that day in the tenant's zone, not in UTC
      - >-
        services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js#resolves
        the same shift from the as-of day, so a contact eighteen today was not the day before
evidence:
  - 'Pinned reference: services-platform:modules/queries/services/execute/compile-predicates.ts'
  - 'Pinned reference: services-platform:modules/queries/services/execute/compile-query.ts'
  - >-
    Pinned reference:
    services-platform:modules/queries/tests/integration/services/execute/compile-predicates.integration.spec.js
coverage_notes:
  transition: >-
    This capability has no formal lifecycle of its own. Audience and definition changes remain rule,
    permission and concurrency proofs; related lifecycles are exercised through interaction scenarios.
coverage:
  rule: covered
  transition: not-applicable
  validation: 'gap: FND-PFM-QRY-070'
  permission: covered
  edge: covered
  failure: 'gap: FND-PFM-QRY-070'
  boundary: covered
  concurrency: 'gap: FND-PFM-QRY-070'
  invariant: covered
  interaction: covered
coverage_findings:
  - FND-PFM-QRY-070
transition_obligations: []
unproved_rules: []
---

# Evaluate dated conditions for named records: Capability Test Specification

## Coverage

| Rule | Scenario or Finding |
|---|---|
| `BR-CAP-PFM-QRY-020-01` | `ATS-PFM-QRY-020-01` |
| `BR-CAP-PFM-QRY-020-02` | `ATS-PFM-QRY-020-02` |
| `BR-CAP-PFM-QRY-020-03` | `ATS-PFM-QRY-020-03` |
| `BR-CAP-PFM-QRY-020-04` | `ATS-PFM-QRY-020-04` |
| `BR-CAP-PFM-QRY-020-05` | `ATS-PFM-QRY-020-05`, `ATS-PFM-QRY-020-07` |
| `BR-CAP-PFM-QRY-020-06` | `ATS-PFM-QRY-020-06` |

## Interactions With Related Capabilities

The combined examples change a source, its audience or its retained state before checking the dependent outcome. Unbound examples remain proposed, and the coverage finding retains design obligations that these examples do not establish.

| Related Capability | Scenario |
|---|---|
| `CAP-PFM-QRY-002` | `ATS-PFM-QRY-020-07` |

## Evidence and Binding Limits

The source revisions pin the inspected assertions. A test binding identifies written assertions, and does not establish a successful run or approval of the expected behavior.
