---
id: TST-ACC-CLS-030
title: Filtered run and linked-reopen queries
kind: integration
product_area: accounting
module: close
revision: 1
status: draft
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
repository: services-accounting
files:
  - >-
    modules/fiscal-close/tests/integration/services/persistence/period-close-runs.queries.integration.spec.js
implements:
  - ATS-ACC-CLS-013-03
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 3
isolation: >-
  The suite owns test-identifier workspaces and fixture records, removed by its
  teardown.
binding_policy: >-
  Each binding identifies the assertions this suite executes; combined scenarios
  may require other bound suites. Existence is not a recorded execution result.
evidence:
  - >-
    services-accounting:modules/fiscal-close/tests/integration/services/persistence/period-close-runs.queries.integration.spec.js
  - provenance: test
    source: >-
      services-accounting:modules/fiscal-close/tests/integration/services/persistence/period-close-runs.queries.integration.spec.js
    assertion_titles:
      - 'fiscal close persistence: reading close runs (integration)'
      - a run by id
      - 'answers a finished run with its job, its key and when it finished'
      - 'answers a queued run with no job, no key and no finish'
      - answers undefined for a run the tenant does not have
      - answers undefined for another tenant’s run
      - a run by idempotency key
      - answers the run the key created
      - answers undefined for a key no run carries
      - answers undefined for another tenant’s key
      - a period’s active run
      - 'answers the queued run that holds the period, not its finished ones'
      - answers undefined for a period no run holds
      - answers undefined for another tenant’s period
      - a period’s runs
      - 'answers every run of the period, newest first'
      - 'answers at most the limit, the newest'
      - answers nothing for a period with no run
      - answers nothing of another tenant
      - refuses a limit above the page size
      - refuses a limit below one
      - the tenant’s runs (FC2-4)
      - 'answers every run of the tenant, newest first'
      - maps each run as every read answers it
      - filters by kind
      - filters by unit and year
      - pages by the last id answered
      - answers none of another tenant’s runs
      - refuses a page size above the maximum
      - a close run’s reopens (FC2-4)
      - answers the reopen runs that name the close run
      - answers none for a close run no reopen names
real_dependencies: >-
  Production persistence and mapping run with application-role transactions and
  workspace policies on PostgreSQL. Fixture records and fixed context values
  supply the inputs; the service and database enforcement under assertion remain
  real.
product_intent: proposed
implementation_evidence: observed
---
# Filtered run and linked-reopen queries

## Verification Boundary

The suite checks its declared service or persistence boundary against local PostgreSQL. Bindings identify the assertions it contributes to a capability case; they do not establish every assertion in a combined case.

## What This Suite Proves

The query suite reads runs and command lookups within the workspace, filters history, validates page bounds and returns linked reopen requests.

## What It Does Not Prove

This register records assertion scope without claiming a passing run or complete coverage of every rule and scenario variant.

## Real Dependencies and Test Doubles

Production persistence and mapping run with application-role transactions and workspace policies on PostgreSQL. Fixture records and fixed context values supply the inputs; the service and database enforcement under assertion remain real.

## Must Not Be Doubled

Keep production queries, writes, mappings, application-role privileges and database constraints real wherever they are the subject of an assertion. Recording financial ports establish invocation behavior; actual recognition and reversal require the suite using the real posting service.
