Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 01:45 UTC
codex/gate-2a-pilot-workbook-6864754244772568979
V1 Pilot Workbook Contract v0.1
This document governs the strictly structured V1 Pilot workbook format. It outlines the schema, validation rules, and cross-sheet relationships to ensure audit-safe processing and strict determinism.
1. Required Sheet Names and Header Order
The workbook must contain exactly the following sheets, with headers occurring exactly in this order.
Company
company_code(Text, Required)company_name(Text, Required)fiscal_year(Integer, Required)status(Text, Required: Draft, Reviewed, Approved)
Accounts
company_code(Text, Required)fiscal_year(Integer, Required)account_code(Text, Required, Unique within company/year)account_name(Text, Required)t1_code(Text, Optional)t2_code(Text, Optional)t3_code(Text, Optional)t4_code(Text, Optional)nature(Text, Optional)opening(Decimal, Required)debit(Decimal, Required)credit(Decimal, Required)closing(Decimal, Required)
Notes
company_code(Text, Required)fiscal_year(Integer, Required)note_number(Text, Required, Unique within company/year)title(Text, Required)row_order(Integer, Required)label(Text, Required)
Mapping
company_code(Text, Required)fiscal_year(Integer, Required)mapping_id(Text, Required, Unique within company/year)account_code(Text, Required)note_number(Text, Required)mapping_type(Text, Required)
Test_Log
test_iddescriptionresult
Checks
check_namestatus
Guide_FA
Contains instructional text in Persian guiding the user on how to populate the workbook.
Lists
Contains valid dropdown values for fields like status and mapping_type.
2. Constraints and Rules
2.1 Lifecycle/Status Values
The status field in the Company sheet must be exactly one of: Draft, Reviewed, Approved. The validation engine checks this value but never advances or mutates it.
2.2 Company/Year Isolation
All cross-sheet lookups and validations are strictly scoped by the composite key of company_code + fiscal_year.
- Every row in Accounts, Notes, and Mapping must correspond to a defined company_code + fiscal_year present in the Company sheet.
2.3 Cross-Sheet Keys & Duplicate Rules
- Accounts:
account_codemust be unique percompany_code+fiscal_year. - Notes:
note_numbermust be unique percompany_code+fiscal_year. (Duplicate rows for the same note are allowed ifrow_ordervaries, representing note lines). - Mapping:
mapping_idmust be unique percompany_code+fiscal_year.account_codereferenced here must exist in theAccountssheet for the same company/year. - Unknown Accounts: Any mapping row referencing an
account_codenot found inAccountswill be reported as an error. The system will never silently ignore them or guess values.
2.4 Financial Validation & closing_delta
The validator will compute closing_delta = opening + debit - credit - closing using strict Decimal arithmetic.
- A non-zero closing_delta is reported as a validation error.
- This calculation is strictly for validation. The system must never mutate source values, force balances, or treat this calculation as a financial statement rollup.
2.5 Validation Error Schema
Errors must be collected deterministically and reported comprehensively (no fail-fast). The error schema is:
- Severity: e.g., ERROR, WARNING
- Code: e.g., MISSING_FIELD, DUPLICATE_KEY, INVALID_TYPE, UNKNOWN_ACCOUNT, NON_ZERO_DELTA
- Sheet: Name of the sheet
- Row: 1-indexed Excel row number
- Field: The column header name
- Message: A descriptive error message
2.6 Immutability and No-Persistence Boundary
- The preflight validation API is read-only. It operates entirely in memory.
- It must never write to the database.
- It must never alter the uploaded workbook bytes.
- It must never perform automated corrections or silent guessing.