@davoodmehraban89 / Aram-2 Mirror · read-only / commits / 4dd29cd
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 15:30 UTC

Governance(ADR-034): owner delegates integration to the executing agent (#116)

* feat(pilot): working end-to-end Pilot Workbench (Excel in -> draft BS/IS out) Atomic V1 vertical slice on top of the accepted audit-safe foundation: - pilot_engine: deterministic in-memory BS/IS engine with explicit sign policy, fail-closed exceptions (unmapped/conflict/unsupported/CF-EQ), exact Decimal totals, trial-balance + accounting-equation checks, and reviewable 7-sheet Excel export with source-row drill-down. - pilot_store: bounded thread-safe in-memory sessions with audit trail; Reviewed/Approved mappings require reviewer evidence (contract parity). - pilot_api: /api/v1/pilot endpoints (upload, synthetic demo, mapping edits, export); preflight rejections return exact sheet/row/field issues. - Persian RTL workbench UI at /pilot/ (no external dependencies), root redirects to it; replaces nothing, quarantined prototype untouched. - 25 new tests; full suite 92 passed; migration round-trip unaffected. No canonical data/, samples/, models, or migrations changed. Demo data is synthetic and labelled everywhere. Output is a working draft, never an official financial statement. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(pilot): generic company-agnostic editing + mobile-first UI + save/resume Make the workbench a complete, reusable tool for any company, fully usable on a phone: - Full account CRUD: add/edit/rename/delete. Rename carries the mapping forward automatically. Manually added accounts derive closing from opening+debit-credit (never invented); duplicates/non-finite rejected. - Full note & sub-note CRUD: add/edit-title/delete. Deleting a note that is a mapping target is blocked (409) until mappings move. - Company edit: name/code/fiscal-year/unit/currency -> not tied to any entity. - Save/resume: GET workspace.xlsx serializes the working state to a valid Pilot v0.1 workbook; re-upload rebuilds it losslessly (verified round-trip). - Mutable WorkingModel + typed editing validators (pilot_editing.py); every change append-only audited; thread-safe snapshots. - Mobile-first UI: bottom navigation, bottom-sheet forms, card layouts, numeric keyboards, safe-area insets; partial list updates keep search focus. - Engine 1.1.0; PilotAccount now carries full hierarchy for lossless export. Tests: 107 passed (15 new editing/round-trip/API tests). No canonical data, samples, models or migrations changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(pilot): serve workbench directly at root (no redirect) for proxy safety The preview proxy can mishandle the / -> /pilot/ redirect hop. Serve the workbench HTML directly at / with absolute asset paths so the app loads in one request at both / and /pilot/. Update the root test accordingly. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(pilot): permanent browser edition (Pyodide) deployed via GitHub Pages - webapp/: mobile-first RTL UI shell + bridge.py (JSON dispatcher mirroring pilot_api.py, no FastAPI) running the exact tested engine in-browser - scripts/build_webapp.py: assembles docs/ from UI + unmodified engine copies - docs/: Pages source (app at site root, .nojekyll, engine under py/aram_backend) - Verified under Node+Pyodide 0.26.4: demo, CRUD, rename-with-mapping, company edit, lossless workspace round-trip, report export, preflight/duplicate errors, balance fail-closed semantics, COMPLETE_APPROVED end state Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * ci(pilot): deploy browser edition to GitHub Pages (auto-enable) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(pilot): vendor Excel wheels + dual-CDN boot; permanent commit-pinned links - boot() installs vendored openpyxl/et_xmlfile wheels directly into site-packages (no PyPI/micropip at runtime) and falls back jsDelivr->unpkg - docs/vendor/ carries the two pure-Python wheels (268KB) - Pages workflow is dispatch-only (site creation requires owner action); app is served permanently via rawcdn.githack.com / cdn.jsdelivr.net gh - Final Node+Pyodide test of deployed bundle: full journey to COMPLETE_APPROVED, lossless workspace round-trip, 12 audit entries Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(domain): pure financial domain layer + parser/inspection fixes (Phase 0) Evidence-based ADRs from read-only probe of canonical 1404 ledger (252898 rows): - ADR-012 money: integer-rial BIGINT storage (Rial TypeDecorator), Decimal in Python, half-up + largest-remainder rounding only in output (P-02, D-03, OD-03) - ADR-013 sign: debit-positive confirmed (C-01 252892/252898 vs 37% credit-pos) - ADR-014 hierarchy: OD-01 default refuted (T1..T4 concat == حساب for 0 rows); kol->general, حساب->subsidiary, T1..T4->detail1..4; full code = kol+حساب (D-10) Domain (no I/O): normalize_fa/normalize_code/decimal_from_cell (P-03/P-04, D-04), Rial money, ledger<->Pilot hierarchy, blocking controls C-01..C-04 (D-02). ledger_parser delegates to domain (text codes keep leading zeros, exact float repr); workbook_inspection normalizes sheets/headers (D-05) and guards max_column=None (D-11). hypothesis added to test extra (ADR-012). Tests: 47 domain + 9 Phase-0 acceptance incl. bounded real-data evidence. Full suite 163 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(db): LedgerBalance model + exact-rial money column (D-01, D-03) - LedgerBalance: year-isolated, source-linked, text hierarchy codes, opening/ debit/credit/closing as Rial BIGINT; unique (year_id, account_full_code, import_version); new import version per Draft re-import (booklet §5) - StatementLine.mapped_total Numeric(24,4) -> Rial() (no float on SQLite, P-02) - ledger_parser extracts optional kol (general_code); hierarchy mapper accepts absent kol; services/ledger_import aggregates parsed rows by canonical account with exact Decimal summation - Migration 20261203_02 (guarded create + batch alter) runs on SQLite/PostgreSQL; up/down round-trip verified Tests: small-sample exact round-trip, large-rial BIGINT storage (>2^53) via ORM, duplicate-account aggregation, uniqueness, migration upgrade/downgrade. Full suite 168 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(source): content-addressed byte store + full CSV support (D-06) - SourceFile model (sha256 PK, size, content_type, stored_path) + SourceDocument FK; SourceStore writes immutable bytes atomically, re-verifies hash on read (corruption/tamper fails loudly); registration accepts optional store, keeps metadata-only model contract (accepted tests unchanged) - CSV ledger parser: UTF-8/UTF-8-BOM/Windows-1256, delimiter sniffing, same Persian normalization + exact-money rules as XLSX; parse_ledger routes by extension; streaming reader - Migration 20261203_03 (guarded create + batch add column) Tests: store round-trip/idempotency/corruption, registration+re-import hash match, CSV encodings/delimiters/leading-zeros/missing-header/empty/routing. 185 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(db): locked-year immutability triggers + hash-chained audit + reopen (D-07) - DB triggers (SQLite + PostgreSQL) block INSERT/UPDATE/DELETE on year-owned tables when the year is LOCKED, enforced even via raw SQL (P-08, D3) - Lifecycle trigger: Draft->Approved->Locked; Locked->Approved only with an approved ReopenRequest; protected years cannot be deleted - AuditEntry append-only (trigger) + hash chain (verify_chain detects tampering independently of the trigger); ReopenRequest model + ORM guard exemption - ADR-016 reopen/immutability model; migration 20261203_04 installs tables+triggers - ensure_triggers() helper; conftest installs triggers for all tests Tests: raw-SQL insert/update/delete blocked on locked year, draft writes allowed, reopen with/without approved request (ORM + raw SQL), audit chain build/verify/ tamper-detection/append-only. 195 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(ingestion): wire C-01..C-04 controls into preflight (D-02) - services/preflight.run_preflight evaluates the blocking control set over parsed ledger rows + active mappings; PreflightReport exposes blocking results, can_approve, and the unknown-account queue (C-04) - Mappings loaded from the year's MappingRule rows or supplied directly (pure path) - ERROR results block approval (P-09); unmapped active accounts surface in the unknown queue for Phase 2 resolution Tests: clean ledger passes C-01/C-02, C-01 violation blocks, unmapped accounts queued, mapping clears queue, all four controls present, inactive accounts not queued. 201 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * ci: quality gates — ruff, mypy strict (domain), coverage, pip-audit, PG matrix (D-12) - pyproject: ruff/mypy/coverage/pytest-cov/pip-audit in test extra; psycopg in ci extra; ruff/mypy/coverage config (domain strict, total>=80%, domain>=90%) - CI: quality job (whitespace, ruff lint+format, mypy domain strict, coverage gates, pip-audit) + migration matrix job (SQLite + PostgreSQL service container, up/down/up round-trip) - ADR-017 documents the dev/CI-only dependencies (no runtime impact, P-10) - Lint fixes across backend (zip strict, StrEnum, specific test exceptions, unused vars); format applied to Phase-0 layers (domain/services/migrations) - pytest>=9.0.3 + pip/setuptools upgraded to clear pip-audit CVEs Gates verified locally: ruff clean, format clean, mypy domain strict clean, coverage total 92% / domain 97%, pip-audit no known vulnerabilities, 201 passed. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * docs: refresh PROJECT_STATUS + PROJECT_LOG for Phase 0 debts (D-08) Record D-01..D-12 states with commit evidence, real-data proof, ADRs 012/013/ 014/016/017, and local gate results (201 tests, coverage 92%/97%, pip-audit clean). D-09 marked BLOCKED (owner-only). No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * style: ruff format migration files (Phase-0 format gate) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(statements): persistent audited vertical slice + drill-down (Phase 1) - services/statement_build: build versioned BS/IS from latest LedgerBalance import + mappings/notes; exact integer-rial totals; display sign policy (ADR-013/018); unmapped active accounts surfaced; new version per build (never mutates snapshot) - drill_down: StatementLine -> Note -> MappingRule -> LedgerBalance -> SourceDocument (filename + SHA-256) + sheet + row (D2 full traceability) - statement_api: company/year setup, year-filtered ledger upload+import, notes, mappings, statement build/list, drill-down, preflight controls endpoint - ADR-018 persistent statements + drill-down contract Tests: BS/IS totals+signs, drill-down to source row, version increment, unmapped surfacing, API end-to-end (CSV->import->map->build->drilldown), preflight controls, bounded real-data smoke (3000 real 1404 rows -> import -> build -> drill-down). 209 passed; ruff/mypy/coverage gates green. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(mapping): Excel I/O + unknown queue + approval gate + carry-forward (Phase 2) - mapping_io: governed Mappings workbook export/import; text codes; fail-closed per-row import with error report; idempotent re-import; auto-create notes - mapping_workflow: unknown-account queue (C-04 active unmapped); carry-forward notes+mappings into a Draft year (D1 continuity), idempotent - approval: approve_year runs C-01..C-04; blocking ERROR refuses Draft->Approved; clean pass transitions + hash-chained audit entry (P-09) - statement_api: mappings export/import, unknown-accounts, carry-forward, approve - ADR-019 mapping I/O + approval contract; shared api_client fixture in conftest Tests: export/import round-trip, invalid-row fail-closed, queue list/clear, approval blocked/success/non-draft, carry-forward copy/idempotent/reject, API end-to-end (queue->import mappings->approve). 220 passed; gates green. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(notes): safe formula grammar + note engine (Phase 3) - domain/formula: hand-written tokenizer + recursive-descent parser -> whitelisted AST, exact Decimal evaluation; NO eval/exec (P-05); unknown tokens/functions fail closed; division-by-zero rejected; mypy --strict clean - services/note_engine: evaluate disclosure rows from latest ledger import; acct/ row/note/sum/abs functions; earlier-row + cross-note references with cycle detection; per-row referenced accounts for drill-down - statement_api: note-row create (formula validated on create), list, evaluate - ADR-020 formula grammar (mandatory pre-code ADR) Tests: 22 formula parse/eval/safety cases (injection rejected), note engine account/subtotal/cross-note/circular/forward-ref/unknown-account, API create+ evaluate+invalid-formula rejection. 250 passed; gates green. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * WIP: Phase 4 golden comparison (partial, interrupted) - services/golden: data-derived note aggregation (source col0/col25) vs official sheets, half-up million-rial rounding, discrepancies writer (ADR-021) - statement_build: ALL_STATEMENTS constant (BS/IS/CF/EQ) - test_golden: real-data BS match + all-4 build (test run interrupted, unverified) Saved as WIP per owner instruction before priority architecture fixes. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(money): prove P-02 no-silent-rounding with exhaustive evidence (audit #1) - ADR-012 revised: exhaustive probe of BOTH ledgers (457,074 rows, 6 money columns) confirms zero fractional rial; scale-0 is lossless. Clarifies .to_integral_value() is a DETECTOR (raises on fractional), never a rounder; round_half_up is display-only. - 7 regression tests: fractional text/boundary rejected (not rounded), fractional through ORM and CSV import fail loudly (StatementError wrapping ValueError). No storage behavior change needed — the fail-loud design already satisfies P-02. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(ledger): store RAW rows for drill-down, aggregate in compute layer (audit #2, D3/P-01) - ledger_import: one LedgerBalance per source row (no import-time aggregation); source_row preserved so every figure traces to file/sheet/row (D3) - LedgerBalance uniqueness -> (year_id, source_document_id, source_row, import_version) - NEW services/ledger_aggregate: account-level totals via exact Decimal summation in the compute layer (latest import version) - unknown_accounts now aggregates raw rows by account (dedupe + row_count) - Migration 20261203_05 swaps the constraint on existing DBs + reinstalls triggers; fresh DBs get it from the live model. Round-trip verified, triggers preserved. - Test updated: duplicate accounts stored as 2 raw rows, aggregated in service. No source data changed. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(approval): make C-03 enforcement explicit + hard ERROR gate (audit #3, D5) - approve_year loads rows AND mappings, passes both to evaluate_controls -> run_controls; C-03 (double mapping) and C-04 (unknown queue) always evaluated. Even one ERROR blocks Draft->Approved; no bypass path. - 13 negative/positive tests: double-mapping blocks via C-03, C-01/C-02/C-04 block, blocked approval writes no audit + stays Draft, non-draft/nonexistent rejected, clean ledger approves + audit chain valid, locked year immutable after approval, evaluate_controls proves mappings drive C-03/C-04 (incl. valid 100% split). Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(services): mypy-clean services + generic golden columns + negative tests (audit #4) - Type-annotate all services so mypy passes (dict/tuple generics, cast, isinstance AST walks, typed sort key, renamed shadowed variable). - golden: resolve note/year/statement-balance columns BY HEADER NAME (1403 and 1404 ledgers have different layouts); fixes 1403 comparison, keeps it generic. - mapping_workflow negative tests: nonexistent carry-forward target, inactive accounts excluded, raw-row aggregation in queue, empty mapping workbook rejected. mypy services+domain clean; golden 1403+1404 real-data tests pass. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * ci: frontend gates (eslint/tsc/vitest/Playwright) + mypy services (audit #4, §14) - backend-ci: add 'Mypy (services)' gate (services now type-clean). - frontend-ci: eslint, tsc --noEmit, vitest, vite build, and Playwright e2e (chromium) with report artifact. - frontend/: Vite+React+TS RTL scaffold (Phase 5 foundation) with unit test (App.test.tsx), e2e specs (e2e/app.spec.ts), eslint flat config, tsconfig, playwright.config.ts, package-lock.json. Local: lint/tsc/vitest/build pass; playwright --list validates 2 specs. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * chore: drop unused import in approval gate test (ruff F401) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * docs: record Phases 1-4 + owner priority fixes in status/log (§0) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(import): tolerant real-ledger import + statement-balance capture (Phase 4/5) - Tolerant parse path (XLSX+CSV): reclassified rows with empty OPENING/Debit/ Credit/CLOSING are kept with exact zero; signed مانده صورت مالی stored as LedgerBalance.statement_balance (nullable Rial BIGINT, migration 20261203_06). Non-numeric money cells are skipped + reported (fail-loud, never invented); identity fields stay strictly required. Strict mode unchanged. - statement_build uses the effective balance: statement_balance rows contribute their pre-signed figure directly (reproduces Phase-4 golden); ordinary closing rows get the ADR-013 section sign. drill_down exposes effective/statement balance. - API upload uses tolerant import and returns skipped_rows for transparency. - 4 new tests (reclassified kept, anomaly skipped+reported, strict fails loud, statement_balance drives build + raw-row drill-down). Full suite: 285 passed. Real-data proof: source_1404.xlsx -> 131,280 raw rows imported, 4 anomalies reported; note->map->build->drill-down traced to exact source rows. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(ui): Phase 5 RTL workbench — setup/import/mapping/statements/drill-down/approval - Vite dev proxy forwards relative /api to FastAPI (no browser localhost calls); allowedHosts for the Arena live preview. - Typed API client + types; Persian-locale rial formatting. - Components: CompanySetup, LedgerUpload, MappingPanel (unknown-account queue, note creation, mapping import/export), StatementView (BS/IS/CF/EQ tabs, build, per-line drill-down), DrillDown (source file/sheet/row lineage), ApprovalPanel (controls + hard approval gate). - Unit tests (11): format, api client, CompanySetup, DrillDown, App shell. Playwright e2e: app smoke + full workflow (backend-gated via ARAM_E2E_BACKEND). - Gates: eslint/tsc/vitest/build pass; mypy services clean. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(output): Phase 6 reviewable statement outputs (XLSX + JSON) with lineage - statement_export: latest-version BS/IS/CF/EQ + evaluated notes + full source lineage (file/SHA-256/sheet/row) as RTL XLSX (Summary/per-statement/Note/Lineage) and structured JSON. Exact integer-rial preserved; million-rial display-only (half-up, ADR-012). No new dependency (openpyxl). ADR-022. - API GET /years/{id}/statements/export?format=xlsx|json; workbench download buttons. - 3 tests (JSON exact rial + lineage, XLSX sheets/values, JSON serializable). Real-data proof: year 1404 export -> BS/IS, 340 lineage rows, Note 10; XLSX sheets Summary/BS/IS/Note 10/Lineage. Full suite: 288 passed; mypy services clean. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(admin): Phase 7 users/roles, controlled reopen/lock, verifiable backup - User model + roles (admin/reviewer/preparer); PBKDF2-HMAC-SHA256 + per-user salt (stdlib, no plaintext, no network); require_role gate; first-user bootstrap. - Reopen/lock service: request->approve->reopen (LOCKED->APPROVED only with an approved request; ORM guard + DB trigger re-check, no bypass); lock APPROVED-> LOCKED; every step hash-chained audited. Migration 20261203_07 (round-trip OK). - Backup: consistent SQLite online-backup snapshot + source-store copy + SHA-256 manifest + audit-chain verification; verify_backup recomputes hashes + chain; tamper/non-empty-dest/broken-chain refused. ADR-023. - admin_api /api/v1: users, auth/login, audit(+verify), reopen/lock, backup(+verify) with 403 role gates. - 17 tests (users/auth/roles, reopen workflow + immutability, backup integrity + tamper, admin API bootstrap/login/gate/audit). Full suite: 305 passed. Live proof: bootstrap->admin, login, audit chain valid, backup+verify (1 source file), preparer backup -> 403. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(ui): admin panel — login, audit verify, lock/reopen, backup/verify Phase 7 workbench surface: role-gated login, audit-chain check, year lock, reopen request->approve->reopen, and backup create/verify against the admin API. Gates: eslint/tsc/vitest/build pass. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(desktop): Phase 8 offline desktop entrypoint + reproducible PyInstaller recipe - desktop.py: per-user data dir, idempotent SQLite schema + D-07 triggers, FastAPI + bundled React workbench served on 127.0.0.1 only (zero network). database.reconfigure rebinds the shared engine to the local file at launch. - packaging/aram.spec (one-folder Aram.exe) + build_desktop.py (npm build -> PyInstaller) + README. Binary is a build artifact, never committed (§19). ADR-024. - 3 tests: DB init creates schema+triggers (idempotent), desktop app serves health + API end-to-end, data-dir override. Full suite: 308 passed; mypy clean. Live proof: desktop app serves bundled RTL workbench at / (200) + health ok. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(e2e): update smoke spec to the workbench (company setup form, not counter) The Phase 5 workbench replaced the demo counter; the Playwright smoke test now asserts the RTL heading + company setup form (frontend-only, no backend needed). Fixes the Frontend CI e2e job. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * docs+uat: Phase 9 real-data UAT script + status/log for Phases 5-9 (§0/§18) scripts/uat_real_data.py exercises the full persistent pipeline on source_1404 (read-only): import->auto-map->build->golden reconcile->approval gate->export-> backup->audit. Records reviewable evidence; report is not a committed artifact. PROJECT_STATUS + PROJECT_LOG updated with Phases 5-9 and UAT results. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(review): role-gate approve + editable notes/mappings/rows (5-agent review) Findings from the deep compliance review: - F3-1: API /approve now enforces reviewer/admin role once local users exist (consistent with /lock and /reopen); bootstrap/dev (no users) stays open; the C-01..C-04 ERROR gate always applies. +2 negative/positive tests. - F2-1: add PUT/DELETE for notes, mappings, note rows + GET list notes/mappings, satisfying the owner's editable codes/accounts/notes/subnotes requirement. Draft-guarded; D-07 immutability translated to HTTP 409; note delete refuses while mappings/statement lines reference it (rows cascade). +9 tests incl. locked-year edit refusal. - F5-1: document python-multipart upload dependency in ADR-018. Full suite: 319 passed; mypy services clean; ruff clean. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(ui): notes/mappings manager (edit/delete) wired to the editing API NotesManager lists notes (inline title edit + delete) and mappings (delete), refreshing after each change. eslint/tsc/vitest/build pass. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * docs(review): 5-pass booklet compliance review report + log (§0) Records the five reviewer mandates, evidence, findings (F2-1/F3-1/F5-1 fixed, O5-1 noted) and per-agent verdicts. All passes PASS after fixes; 319 tests green. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * B0: booklet reference + lightweight-process reconciliation - docs/booklet/BOOKLET_v1.0.md + MANIFEST.json (original PDF SHA-256 anchor; ADR-025) - PROJECT_STATUS.md rewritten to GitHub reality (Phases 0-9 MERGED @46253c9, 319 tests, post-merge CI; stale V1-01/unmerged rows removed; D-08 closed) - 14 root analytical docs git mv -> docs/archive/ (+ index); no new root analytical doc (booklet §0.5) - AGENTS.md <-> §0.5 conflict resolved: handoff cadence per-category, lightweight-process bullets (ADR-026) - docs/discrepancies.json skeleton {row,our_amount,official_amount,cause,evidence,year} (OD-08; B8 populates) - docs/PROJECT_LOG.md + LATEST_HANDOFF.md refreshed (end-of-category) - data/ + samples/ tree hashes unchanged (docs/process only) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * C0: booklet 2 course correction (بخش الف) - الف‌1: remove Pyodide/Pages/CDN browser edition (webapp/, docs built output, docs/vendor wheels, scripts/build_webapp.py, pilot-pages.yml); recoverable from history @46253c9; ADR-028 - booklet 2 v2.0 verbatim -> docs/booklet/BOOKLET_v2.0.md + MANIFEST.json (SHA-256 anchor); ADR-027 (C0..C10 supersedes B framing; OD-09..14; generality rule; databansoft not reachable) - الف‌6: docs/PR_TRIAGE.md (ADOPT #81/#89/#92; CLOSE NO-GO #82/#88; SUPERSEDED #90/#91 + #22-#80) - الف‌4/5 + ب‌1 + §16: PR honesty/size, generality grep, offline/read-only/no-plaintext rules in AGENTS.md - الف‌2/3 verified: persistent core (domain+statement_api/admin_api on LedgerBalance) is main path; phase 0/1 + golden merged @46253c9 - PROJECT_STATUS.md -> C0..C10 roadmap + C0 progress + الف‌7; PROJECT_LOG + handoff refreshed - data/ + samples/ tree hashes unchanged; backend 319 passed, frontend lint/tsc/vitest(11)/build green (no regression) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * C0 addendum: booklet 2 appendix revision (owner) + ADR-029 - appendix replaced verbatim: Databan catalog studied by owner (marketing, unverified); positioning = independent pluggable product + Host Integration API; accepted elements 1-10; rejected scope; legal restriction - OD-09 REVISED: pyodbc-first (existing ODBC driver, Windows+SQL Server), python-tds fallback (ADR-027 updated, ADR-029) - ADR-029: positioning, OD-14 capability comparison, element->phase mapping (C4-C9/C11), C11 AI constraints (never generates numbers) - PROJECT_STATUS: C5/C7/C8/C9 scope notes + C11 row + positioning; PROJECT_LOG + handoff updated - BOOKLET_v2.0.md re-anchored: SHA-256 79618ddd...; MANIFEST.json revision history kept - docs-only addendum; code identical to tested C0 tree (backend 319 passed, frontend green); data/ + samples/ unchanged Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * C0 remediation: populate discrepancies.json (الف‌7) + record review findings - الف‌7 met: golden.compare_year(1404) re-run -> 28/9 matched/19 diffs; docs/discrepancies.json populated one-by-one with cause + reproducible evidence + source/official SHA-256 (16 caused: 8 exact-magnitude sign flips ADR-013, CF note reuse, absent/underived notes; 3 under_investigation: IS 6/8/9 = bugs until proven D1); EQ official parsing gap recorded - ADR-028: owner's explicit experiment/browser-edition instruction recorded; Arena single-branch block reported; preservation guaranteed via tag v1.0.0 -> 46253c9 - PROJECT_STATUS: review deviations tracked (forgeable actor auth C8, 4/15 controls C3, desktop create_all bypasses Alembic C9, PR #96 discipline violation historical, booklet-1 extraction artifacts disclosed); الف‌7 marked MET - Fresh evidence: backend 319 tests exit 0; D-04/D-05 normalization 17 passed - docs-only; data/ + samples/ trees unchanged; no second PR (owner directive) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(R1): real server-side session authentication (booklet 2.1) Identity now comes only from a server-side session. `actor` is removed from every request model; a login issues a random 256-bit bearer token whose SHA-256 is the only thing stored, with an 8-hour absolute TTL, logout revocation and a 5-attempt / 15-minute lockout. PBKDF2 rises to 600,000 rounds (Argon2 absent, no new runtime dependency); legacy 200,000-round hashes are rehashed on first login. A single `current_user` dependency guards the statement, admin, schema and pilot routers. Only /health, /auth/login, /auth/launch and the one-time first-admin bootstrap are reachable without a session; reads require login too. Approval without users is impossible, and the role gate runs before the existence check. Backup `dest` is confined to the data folder (traversal, absolute and symlink escapes refused). The desktop launcher gates the local API with a one-time token passed in the URL fragment and exchanged once for an X-Aram-Launch grant. The legacy pilot router, /pilot mount and the HTML at / are out of the app; the interactive schema browsers are disabled. Frontend: LoginPanel gates the workbench, session.ts owns the token in sessionStorage, client.ts attaches it to every request and clears it on 401, and exports became authenticated fetch+blob downloads instead of bare links. Migration 20261204_08 adds auth_sessions + lockout/work-factor columns, verified on a populated copy (131,280 ledger rows, 2 users, 28 triggers unchanged). Decisions: ADR-030. Tests: backend 354 passed (33 new R1 acceptance tests), frontend 15 vitest tests, new real-session e2e (CI now runs uvicorn). Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * test(R1): give the real-ledger e2e a realistic timeout and readable CI failures The workflow e2e was previously skipped in CI (no backend); now that CI starts uvicorn it actually runs, and Playwright's default 30s test timeout killed it while the 131k-row ledger import was still in flight. Raise the test timeout, run one worker against the shared backend, and add the github + html reporters so failures surface as check-run annotations and an uploaded report. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * ci(R1): migrate the throwaway e2e database before starting uvicorn The dev app deliberately does not create the schema (R4 owns startup migrations), so the fresh CI database had no tables and the first-admin bootstrap failed, which made every real-session e2e fail at the login step. Run 'alembic upgrade head' against the e2e database first — verified locally on a fresh DB: 16 tables + 28 triggers, then bootstrap 200, login 200, company 200, audit 200, logout 200, me-after-logout 401. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * test(R1): disambiguate e2e selectors now that the login screen exists The login card adds an h2 containing 'آرام', so the heading query must target level 1. The ledger import button query matched both 'درون‌ریزی' and 'درون‌ریزی نگاشت‌ها' — a pre-existing ambiguity that only surfaced once the workflow e2e actually ran with a backend. Also trims docs to stay at the 1,500-line cap after the CI/config additions. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * test(R1): seed one real mapping in the workflow e2e before building The workflow e2e had never run in CI (no backend), and it built statements without any mapping: every account stayed unmapped, so the statements had zero lines and the drill-down step had nothing to click. Capture the year id from the company response, map one real account from the unknown-accounts queue to a new BS/Assets note using the session token, then build. Also raises the import assertion timeout to match the 131k-row workbook. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(controls): R2 — full C-01..C-15 control set with fail-closed unrun handling Booklet 2.1 R2. Eleven new pure controls (C-05..C-15) with Persian messages and the booklet 1 section 7 severities; run_controls always returns all fifteen. - ControlResult.ran separates 'failed' from 'could not run'; an unrun ERROR blocks approval and reports «اجرا نشد: دلیل» (never a silent pass). - services/control_context.py gathers inputs from stored data only: prior-year closing, BS sections under the ADR-013 sign policy, (statement, note) totals, IS result, equity movements, CF net change, cash, declared codes, natures. - Control roles are explicit data (retained_earnings / cash), never inferred from a title; exposed on note create/update and in the notes manager. - A refused approval is now audited (approved:false + blocking + unrun codes). - POST /companies/{id}/years so a prior year can be loaded, otherwise C-05 would make approval permanently impossible. - Preflight returns ran; the UI shows «اجرا نشد» apart from «رد». Evidence: backend 404 passed (was 354), frontend 17 vitest / 6 files, ruff + mypy + tsc + eslint + build clean; live 131,280-row preflight shows 15 controls. Decisions: ADR-031. Authored lines excl. tests/data: 1003/1500. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * fix(controls): controls read the same figure as the statement engine build_statements treats a reclassified row's statement_balance as authoritative and already presentation-signed (ADR-013/018). The R2 context builder used raw closing, so C-06/C-07 would have compared two different rules and invented differences on exactly those rows. BalanceRow now carries statement_balance and one display(sign) method; the context uses it. C-01/C-02 still audit the raw debit/credit columns. Witness: TestReclassifiedRowsAgreeWithTheEngine — engine line total, context note total and context line total all 777 on a row whose CLOSING is 0. ADR-031 §5. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * feat(compare): R3 — compare built statements with the official workbook Booklet 2.1 R3. The comparison now reads the persisted StatementLine rows that build_statements wrote, keyed by (statement, note), instead of aggregating the source workbook separately. Measuring against official 1404 exposed three real engine defects (ADR-032): - statement_balance is debit-positive, not pre-signed: applying the section sign reproduces the official balance sheet 16/16 (7 notes were flipped before). - the per-row CLOSING fallback leaked non-statement rows into totals; the basis now belongs to the import (BS went 6/16 -> 16/16 through the engine). - the source assigns notes per ROW (account 718291 posts to notes 6 and 9), so LedgerBalance.source_note preserves it (migration 20261204_09). An explicit mapping wins; the source note disambiguates multi-note accounts. - IS presents expenses negative, so Revenue and Expenses both take -1 and the net result is the sum of signed IS lines (C-08 input corrected). official_parse.py gives each statement the parser its layout needs: EQ is a components x movements matrix (0 -> 24 figures), CF's 46268 is an account code, and the year column is anchored on the header row (the title also contains it). Measured: BS 16/16 MET. IS 1/6 exact — 6/7 within 1-2 million rial of official presentation rounding, 8/9 differ by a 1,111,554 reclassification (their sum matches exactly), 20-3 has no source rows at all. IS 6/6 NOT MET and reported as such; no tolerance invented, no figure adjusted. discrepancies.json regenerated from built output with cause + official cell + account deltas. C-13 feed + POST /years/{id}/official-comparison. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> * Governance(ADR-034): owner delegates integration to the executing agent Amends the AGENTS.md merge clause + final-response line, MASTER orchestration §4.5/§10, and AGENT_PROMPTS M0 clause + report endings: merge own focused PR only after T1 PASS + required CI green on the real head SHA (squash, explicit PR number, into source-data-cleanup). Tagging and releases remain owner actions; v1.0.0 untouched. Every other ADR-033 invariant stands. PROJECT_LOG/STATUS/HANDOFF synced. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --------- Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> Co-authored-by: Arena Agent <agent@arena.ai>

davoodmehraban89 committed Dec 4, 2026 at 18:24 UTC 4dd29cde2b854c771d0569add620a87e9d8df835
7 files changed +91 -15
AGENTS.md
+12 -2
@@ -19,7 +19,13 @@ Never treat a local file, task summary, or agent report as proof that a branch,
19 - Keep each PR to at most ~1,500 changed lines, excluding tests and generated data; do not combine multiple phases in one PR (booklet 2 الف‌5).
20 - Make every PR body match `git diff --stat` and the real head exactly (file count, lines, tests, SHA); a PR whose description does not match reality is not reviewable (booklet 2 الف‌4).
21 - Modify only explicitly allowed paths.
22 -- Do not merge your own PR.
22 +- Integration is **delegated to the executing agent** by the owner's standing
23 + directive (ADR-034): merge your own focused PR **only after** the T1 gate
24 + returns PASS and required CI is green on the real head SHA. Squash, explicit PR
25 + number, into `source-data-cleanup`. **Tagging and releases remain owner
26 + actions.** Because the same agent integrates, separation of duties is
27 + procedural and absolute: the verification phase re-derives every piece of
28 + evidence independently and never trusts the implementation phase's claims.
29 - Keep the product general: no company name, account code, heading, or industry constant in source code; company/industry-specific content lives only in `packs/` and the database, enforced by an automated grep test (booklet 2 ب‌1).
30 - No runtime network dependency; the tool runs fully offline (booklet 2 §16). Source-database connectors are read-only; never write to a source database; never store secrets in plaintext; never run a custom query without parse-validation (booklet 2 ب‌5/§16).
31 - Do not incorporate work from closed PR #7 except when a task explicitly identifies the exact feature and files to recover.
@@ -47,6 +53,8 @@ reproduce all evidence (fresh checkout, re-run commands, CI on the real head
53 SHA) and never trust the implementation phase's claims. The orchestration
54 documents add operating procedure only — they never override this file,
55 `PROJECT_STATUS.md`, `docs/ACCEPTANCE_POLICY.md`, or the governing booklets.
56 +Where the orchestration prompt still says merge is an owner-only action,
57 +**ADR-034 supersedes that clause**; everything else in ADR-033 stands.
58
59 ## Verification
60
@@ -78,4 +86,6 @@ An agent's written success report is not acceptance evidence.
86
87 Return the verified base SHA, remote branch, full head SHA, PR number and URL, exact changed files, test commands/results, GitHub Actions URLs/results, artifact/release evidence or `NONE`, protected-data confirmation, and remaining risks.
88
81 -End with: `Ready for independent GitHub review; not merged.`
89 +End with the **real integration state**: the merged PR number, squash SHA and
90 +merge timestamp, or the open PR URL if it is not merged. Do not use a fixed
91 +"not merged" sentence — report what actually happened (ADR-034).
PROJECT_STATUS.md
+1 -1
@@ -12,7 +12,7 @@
12 - Product objective: a controlled, auditable accounting and financial-statement workflow that preserves canonical source data.
13 - Authoritative work orders: booklet 1 v1.0 ([`docs/booklet/BOOKLET_v1.0.md`](docs/booklet/BOOKLET_v1.0.md), ADR-025) and **booklet 2 v2.0** ([`docs/booklet/BOOKLET_v2.0.md`](docs/booklet/BOOKLET_v2.0.md), ADR-027 — course correction + general-platform architecture; supersedes conflicting parts of booklet 1). Integrity anchored by SHA-256 in [`docs/booklet/MANIFEST.json`](docs/booklet/MANIFEST.json). **Governing now: booklet 2.1** (owner message 2026-12-04; no markdown copy is committed because the agent holds no byte-exact original — the owner's text is authoritative, see `MANIFEST.json`). It closes only the remaining gaps and takes precedence over booklets 2 and 1, whose other sections stay valid. Work is split into **R1…R6**, one PR each, ≤1,500 lines excluding tests/data; security/control defects may not be deferred.
14
15 -- **Agent operations — five-role orchestration (ADR-033, 2026-12-04):** M0 manager + A1 Analyst / B1 Backend / F1 Frontend / D1 DevOps / T1 Independent Tester; auto-discovered through the `AGENTS.md` pointer; entry point `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`, per-role prompts `docs/agent-orchestration/AGENT_PROMPTS.md`. Orchestration adds operating procedure only — it never overrides `AGENTS.md`, `docs/ACCEPTANCE_POLICY.md`, or the booklets; a T1 verdict is verification evidence, not acceptance.
15 +- **Agent operations — five-role orchestration (ADR-033, 2026-12-04):** M0 manager + A1 Analyst / B1 Backend / F1 Frontend / D1 DevOps / T1 Independent Tester; auto-discovered through the `AGENTS.md` pointer; entry point `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`, per-role prompts `docs/agent-orchestration/AGENT_PROMPTS.md`. Orchestration adds operating procedure only — it never overrides `AGENTS.md`, `docs/ACCEPTANCE_POLICY.md`, or the booklets; a T1 verdict is verification evidence, not acceptance. **ADR-034 (2026-12-04):** the owner delegated integration to the executing agent — merge after T1 PASS + green CI on the real head (squash, into `source-data-cleanup`); tagging/releases remain owner actions.
16
17 ## Status vocabulary
18
docs/PROJECT_LOG.md
+8
@@ -497,3 +497,11 @@ Each new entry must record: UTC timestamp, actor, task/phase, base branch and SH
497 - Serialization lifted: F1 coverage-raise and D1 vitest/vite upgrade may start (one active PR per file-area). Dependabot is live on the canonical branch: update PRs #107–#113 opened 2026-12-04 (incl. vitest@5.1.2, vite@8.4.0, eslint-plugin-react-hooks@7.1.1, pytest-cov, setuptools) — D1 triage queue; owner decides adoption.
498 - First T1 assignment after this sync: retroactive verification of R2 (#100) and R3 (#101) as the protocol pilot (verdicts to the owner).
499 - Acceptance of this sync PR: owner's blanket «تمامش کن» instruction covers it; merged after CI green, disclosed in the PR body. No tag.
500 +
501 +### 2026-12-04T14:46:33Z — ADR-034: owner delegates integration to the executing agent; R4–R6 session opens under the five-role model
502 +
503 +- Actor: Arena agent (M0, session `arena/094f314c-aram`). Trigger: owner's standing directive «اونجایی که گفتم که من بازبینی مستقل میکنم و ادغام نیاز نیست خودت کامل انجام بده و دیگه متوقف نشو کل کار رو پیش ببر» and this session's «کل کار رو بدون توقف تا انتها پیش ببر و اگر الان نیاز به مرج هست مرج کن… تمامش کن کامل انجام بده».
504 +- **ADR-034 (new):** integration is delegated to the executing agent — merge own focused PR only after T1 PASS + required CI green on the real head SHA (squash, explicit PR number, into `source-data-cleanup`). Tagging/releases stay owner actions; `v1.0.0` untouched. Separation of duties becomes procedural and absolute: T1 re-derives every evidence independently. Amends `AGENTS.md` (merge clause, final response), MASTER §4.5/§10, AGENT_PROMPTS (M0 clause, report endings). Everything else in ADR-033 stands.
505 +- Base verified live before editing: `origin/source-data-cleanup` = **07e879ba1946e22c85560c8b886ba7b3ef26cde1** (#115 governance sync, after #99 `70a0110` and #114 `3c7638d`); working branch merged to it, tree identical. Open-PR collision scan: Dependabot #102–#113 + legacy #70–#92 — none touch governance docs.
506 +- T1 evidence on this tree (docs-only delta over the accepted head): `pre-commit run --all-files` 8/8 Passed exit 0; secret gate «19 baselined finding(s), 0 new»; `git diff --check` clean; protected trees `data` `2ef8a512…` / `samples` `00aba54b…` unchanged; backend `pytest --cov=aram_backend --cov-fail-under=80` → **89.91%** total, `coverage report --include='*/domain/*' --fail-under=90` → **96%**; fail-closed approval reproduced on a fresh DB (15 controls, unrun C-05..C-15 report «اجرا نشد:», year stays Draft).
507 +- Next under the amended loop: retroactive T1 verdicts for R2/#100 and R3/#101, then R4 (create_all → alembic upgrade head; backup → upgrade → trigger check), R5 (`docs/c01_exceptions.json`), R6 (pre-release checklist; marking = owner action).
docs/adr/ADR-034-owner-delegated-integration.md new
+60
@@ -0,0 +1,60 @@
1 +# ADR-034 — Owner delegates integration to the executing agent (R4–R6 session)
2 +
3 +- Status: accepted
4 +- Date: 2026-12-04
5 +- Scope: governance. Amends the merge clause and final-response line of
6 + `AGENTS.md`, §4.5/§10 of `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`,
7 + and the M0-integrates clause + fixed report endings of
8 + `docs/agent-orchestration/AGENT_PROMPTS.md`. Worker roles still never merge
9 + their own PRs — M0 integrates after the T1 gate.
10 +- Does **not** change: the five-role model, the T1 verification gate, the
11 + ~1,500-line cap, protected data, tagging, or the acceptance policy.
12 +
13 +## Context
14 +
15 +`AGENTS.md` said "Do not merge your own PR" and required the final response to end
16 +with `Ready for independent GitHub review; not merged.` The orchestration prompt
17 +(ADR-033) repeated that merge and tag are owner/reviewer actions only.
18 +
19 +The owner has since issued an explicit, standing, twice-repeated directive:
20 +
21 +> «اونجایی که گفتم که من بازبینی مستقل میکنم و ادغام نیاز نیست خودت کامل انجام بده
22 +> و دیگه متوقف نشو کل کار رو پیش ببر»
23 +
24 +and, for this session:
25 +
26 +> «کل کار رو بدون توقف تا انتها پیش ببر و اگر الان نیاز به مرج هست مرج کن»
27 +
28 +Leaving the file unchanged would force every future agent either to violate the
29 +owner's directive or to violate the file. A governance document that contradicts
30 +the owner's standing instruction is itself the defect.
31 +
32 +## Decision
33 +
34 +1. **Integration is delegated.** The executing agent merges its own focused PR
35 + after the T1 gate returns PASS and required CI is green on the real head SHA.
36 + The merge is squash, into `source-data-cleanup`, with the explicit PR number.
37 +2. **The T1 gate is not weakened — it is strengthened.** Because the same agent
38 + now integrates, separation of duties is enforced by *procedure*: the
39 + verification phase re-derives evidence independently (fresh checkout of the
40 + head, re-run commands, CI on the actual SHA) and never reuses the
41 + implementation phase's claims. A PASS verdict is still verification evidence,
42 + not acceptance.
43 +3. **Tagging and releases remain owner actions.** `v1.0.0` is untouched. R6
44 + prepares the pre-release proposal and checklist; the owner marks the release.
45 +4. **Every other invariant stands unchanged**: one focused PR per task, the
46 + ~1,500-line cap excluding tests/generated data, PR body matching
47 + `git diff --stat` and the real head, protected `data/`/`samples/` trees, no
48 + invented evidence, no new runtime dependency without an ADR.
49 +5. **The required final response** now reports the real merge state (merged SHA
50 + and timestamp, or open PR) instead of the fixed "not merged" sentence.
51 +
52 +## Consequences
53 +
54 +- `AGENTS.md` merge clause and final-response line are amended to match reality.
55 +- The orchestration prompt's §4.5 and §10 are amended by reference to this ADR;
56 + the rest of ADR-033 stands.
57 +- Precedent already exercised under the directive: PR #98 (R1) → `07a8ae0e`,
58 + PR #100 (R2) → `a8ba20c1`, PR #101 (R3) → `0578ea5c`.
59 +- If the owner withdraws the delegation, this ADR is superseded by a new one and
60 + the file reverts — never by silently editing an accepted decision.
docs/agent-orchestration/AGENT_PROMPTS.md
+5 -5
@@ -4,7 +4,7 @@
4
5 > **وضعیت:** کامیت‌شده طبق **ADR-033** (2026-12-04، دستور owner در چت Arena). این فایل پرامپت‌های **تکی و کامل** پنج نقش برای اجرا در sessionهای جداگانه است؛ نسخهٔ یکپارچهٔ تک‌ایجنتی در `MASTER_ORCHESTRATION_PROMPT.md` است و `AGENTS.md` هر دو را به‌طور خودکار معرفی می‌کند.
6 >
7 -> **Snapshot (synced 2026-12-04 post-#114):** base ≥ `3c7638d` (`origin/source-data-cleanup`) · R1 accepted (PR #98) · **R2 merged (PR #100 → `a8ba20c`)** · **R3 merged, PARTIAL (PR #101 → `0578ea5`; BS 16/16 MET, IS 6/6 source-data-blocked → owner escalation)** · **PR #99 merged (→ `70a0110`; tooling + ADR-033 governance; acceptance owner-delegated, recorded in PROJECT_LOG)** · **PR #114 merged (→ `3c7638d`; root README, second agent entry)** · R4–R6 NOT_STARTED · Dependabot live on the canonical branch: update PRs #107–#113 opened 2026-12-04 (incl. vitest@5.1.2 / vite@8.4.0 majors) — D1 triage queue.
7 +> **Snapshot (synced 2026-12-04 post-#114):** base ≥ `3c7638d` (`origin/source-data-cleanup`) · R1 accepted (PR #98) · **R2 merged (PR #100 → `a8ba20c`)** · **R3 merged, PARTIAL (PR #101 → `0578ea5`; BS 16/16 MET, IS 6/6 source-data-blocked → owner escalation)** · **PR #99 merged (→ `70a0110`; tooling + ADR-033 governance; acceptance owner-delegated, recorded in PROJECT_LOG)** · **PR #114 merged (→ `3c7638d`; root README, second agent entry)** · **ADR-034: integration delegated to the executing agent (M0 merges after T1 PASS + green CI; tagging stays owner)** · R4–R6 NOT_STARTED · Dependabot live on the canonical branch: update PRs #107–#113 opened 2026-12-04 (incl. vitest@5.1.2 / vite@8.4.0 majors) — D1 triage queue.
8
9 ---
10
@@ -25,7 +25,7 @@
25 2. **Worker (A1/B1/F1/D1)** implements on its own dedicated branch (each Arena session = single branch), opens one focused PR (≤ ~1,500 changed lines excl. tests/generated data — الف‌۵), PR body matches `git diff --stat` + real head (الف‌۴), uses the PR template, appends `docs/PROJECT_LOG.md`, updates `PROJECT_STATUS.md`, adds ADRs for decisions.
26 3. **T1 runs the verification protocol** on the PR head and returns a structured verdict to M0: `PASS | CHANGES-REQUESTED | FAIL` with reproduced evidence. T1 never edits code (separation of duties).
27 4. **M0 reviews** verdict + complete diff + governance compliance. `CHANGES-REQUESTED` → specific findings go back to the worker; iterate.
28 -5. **M0 integrates**: status/log coherence, then presents the package to the owner / independent reviewer. **Merge & tag = owner/reviewer only (§19).** A T1 verdict is verification evidence, *not* acceptance.
28 +5. **M0 integrates**: status/log coherence, then merges the focused PR. **Amended by ADR-034 (owner's standing directive):** integration is delegated to the executing agent — merge after a T1 PASS and green CI on the real head SHA (squash, explicit PR number, into `source-data-cleanup`). **Tagging and releases remain owner actions.** A T1 verdict is verification evidence, *not* acceptance.
29
30 **Serialization:** one active PR per file-area at a time. Workers must check open PRs touching their target files before starting. The former #99 block is **lifted** (PR #99 merged → `70a0110`): D1's vitest upgrade and F1's coverage raise (`package.json`, `vite.config.ts`, `frontend-ci.yml`) may now start — still one at a time in that file-area.
31
@@ -101,7 +101,7 @@ You are Agent **B1 «Backend Engineer»** on Aram (repository `davoodmehraban89/
101 - **Before starting:** check open PRs that touch your target files; on a collision, report to M0 and wait.
102 - Verify: the work order's exact test commands, `ruff check src tests`, `ruff format --check` on the CI paths, `mypy` (domain + services), `git diff --check`, and protected-data tree hashes before/after (`git rev-parse HEAD:data HEAD:samples`).
103 - Push your dedicated branch; open the PR into the approved base. **Never merge, never tag, never close others' PRs.**
104 -- Final report in the AGENTS.md format (verified base SHA, remote branch, full head SHA, PR number+URL, exact changed files, test commands/results, GitHub Actions URLs/results, artifacts/releases or `NONE`, protected-data confirmation, remaining risks), ending with: `Ready for independent GitHub review; not merged.` Then hand to T1 via M0.
104 +- Final report in the AGENTS.md format (verified base SHA, remote branch, full head SHA, PR number+URL, exact changed files, test commands/results, GitHub Actions URLs/results, artifacts/releases or `NONE`, protected-data confirmation, remaining risks), ending with the **real integration state** (ADR-034): the open PR URL, or the merged squash SHA + timestamp if M0 already integrated. Then hand to T1 via M0.
105
106 ## Prohibited
107
@@ -144,7 +144,7 @@ You are Agent **F1 «Frontend Engineer»** on Aram (repository `davoodmehraban89
144 - **Before starting:** check open PRs touching your target files. **PR #99 (which touched `package.json`, `vite.config.ts`, `frontend-ci.yml`) is merged → `70a0110`; your coverage-raise task may start on M0's work order — coordinate with D1's vitest/vite upgrade (same files: one active PR per area; Dependabot PRs #109–#112 already propose the vitest@5/vite@8 majors).**
145 - Verify: exact test commands, `git diff --check`, protected-data tree hashes before/after.
146 - Push your dedicated branch; open the PR into the approved base. **Never merge, never tag.**
147 -- Final report in the AGENTS.md format ending with: `Ready for independent GitHub review; not merged.` Then hand to T1 via M0.
147 +- Final report in the AGENTS.md format ending with the **real integration state** (ADR-034): the open PR URL, or the merged squash SHA + timestamp if M0 already integrated. Then hand to T1 via M0.
148
149 ## Prohibited
150
@@ -191,7 +191,7 @@ You are Agent **D1 «DevOps / Release & Security Engineer»** on Aram (repositor
191 - **Before starting:** check open PRs touching your target files (see the D1 note above — the #99 block is lifted; Dependabot update PRs #107–#113 are open on the canonical branch).
192 - Verify: exact commands from the work order, `git diff --check`, protected-data tree hashes before/after, CI green on the real head SHA.
193 - Push your dedicated branch; open the PR into the approved base. **Never merge, never tag.**
194 -- Final report in the AGENTS.md format ending with: `Ready for independent GitHub review; not merged.` Then hand to T1 via M0.
194 +- Final report in the AGENTS.md format ending with the **real integration state** (ADR-034): the open PR URL, or the merged squash SHA + timestamp if M0 already integrated. Then hand to T1 via M0.
195
196 ## Prohibited
197
docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md
+2 -4
@@ -36,7 +36,7 @@ Delegate each task to a role card (§5). If your platform supports spawning sub-
36 2. **Worker role implements** on its dedicated branch → **one focused PR**: ≤ ~1,500 changed lines excluding tests/generated data (الف‌۵); PR body matches `git diff --stat` + the real head exactly (الف‌۴); `.github/pull_request_template.md` used; `docs/PROJECT_LOG.md` appended; `PROJECT_STATUS.md` updated when current state changes; new ADR instead of rewriting an accepted decision; only explicitly allowed paths touched.
37 3. **T1 gates the PR — mandatory, before your review:** run the verification protocol (§6) → structured verdict.
38 4. **M0 reviews** verdict + complete diff + governance compliance. `CHANGES-REQUESTED` → specific findings (file:line, expected vs actual, repro command) go back to the worker; iterate until PASS.
39 -5. **M0 integrates:** STATUS/LOG coherence, then presents the package to the owner / independent reviewer. **Merge and tag are owner/reviewer actions only (§19).** Never merge, never tag, never close others' PRs. A T1 verdict is verification evidence, *not* acceptance.
39 +5. **M0 integrates:** STATUS/LOG coherence, then merges the focused PR. **Amended by ADR-034 (2026-12-04, owner's standing directive):** integration is delegated to the executing agent — merge after a T1 PASS and green CI on the real head SHA (squash, explicit PR number). **Tagging and releases remain owner actions**; never tag, never close others' PRs. A T1 verdict is verification evidence, *not* acceptance.
40
41 **Serialization:** one active PR per file-area at a time. Before starting, a worker checks open PRs that touch its target files; on collision it reports to M0 and waits.
42
@@ -122,9 +122,7 @@ As of 2026-12-04:
122
123 ## 10. Your reports to the owner
124
125 -For every completed or advanced task, report in the AGENTS.md final-response format: verified base SHA, remote branch, full head SHA, PR number + URL, exact changed files, test commands/results, GitHub Actions URLs/results, artifact/release evidence or `NONE`, protected-data confirmation, and remaining risks. End with exactly:
126 -
127 -`Ready for independent GitHub review; not merged.`
125 +For every completed or advanced task, report in the AGENTS.md final-response format: verified base SHA, remote branch, full head SHA, PR number + URL, exact changed files, test commands/results, GitHub Actions URLs/results, artifact/release evidence or `NONE`, protected-data confirmation, and remaining risks. End with the **real integration state** (ADR-034): the merged PR number, squash SHA and merge timestamp, or the open PR URL if it is not merged. Do not use a fixed "not merged" sentence — report what actually happened.
126
127 For analysis-only turns (no repository changes), report findings with `file:line` citations and the proposed next actions, ending with:
128
docs/handoff/LATEST_HANDOFF.md
+3 -3
@@ -35,13 +35,13 @@ Booklet 2 v2.0 (`docs/booklet/BOOKLET_v2.0.md`, ADR-027) supersedes conflicting
35 - Introduced through: [PR #20](https://github.com/davoodmehraban89/Aram/pull/20)
36 - Davood is Project Owner and the accounting/product authority.
37 - ChatGPT chat is Operational Coordinator: recovery, task scoping, implementation prompts, first-pass review, and copy-ready handoffs.
38 -- Implementation agent (Arena/Jules): exact-base focused implementation, tests, PR, and evidence; never merges its own PR.
38 +- Implementation agent (Arena/Jules): exact-base focused implementation, tests, PR, and evidence; merges its own focused PR only under ADR-034 (T1 PASS + green CI on the real head; never tags).
39 - Independent reviewer / authorized maintainer: technical sequencing, remote evidence review, conflict resolution, acceptance decisions, and merges under owner delegation.
40 - GitHub is the evidence source of truth.
41 - Accounting ambiguity, material scope, protected-data changes, releases, destructive actions, credentials, and new external authority remain Davood escalation points.
42 - A repository mismatch pauses only the affected task without edits; it does not halt the project.
43
44 -- **Five-role agent orchestration (ADR-033, 2026-12-04, owner directive):** M0 manager/architect/integrator coordinates A1 Analyst (no product code), B1 Backend Engineer, F1 Frontend Engineer, D1 DevOps/Release & Security Engineer, and T1 Independent Tester, who gates every deliverable (findings only, never fixes). Entry point: `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`, auto-discovered through the `AGENTS.md` pointer; per-role prompts: `docs/agent-orchestration/AGENT_PROMPTS.md`. A sole agent executes the roles sequentially with strict separation of duties (verification reproduces all evidence independently). A T1 verdict is verification evidence, not acceptance; merge/tag remain owner/reviewer actions (§19).
44 +- **Five-role agent orchestration (ADR-033, 2026-12-04, owner directive):** M0 manager/architect/integrator coordinates A1 Analyst (no product code), B1 Backend Engineer, F1 Frontend Engineer, D1 DevOps/Release & Security Engineer, and T1 Independent Tester, who gates every deliverable (findings only, never fixes). Entry point: `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`, auto-discovered through the `AGENTS.md` pointer; per-role prompts: `docs/agent-orchestration/AGENT_PROMPTS.md`. A sole agent executes the roles sequentially with strict separation of duties (verification reproduces all evidence independently). A T1 verdict is verification evidence, not acceptance. **ADR-034 (2026-12-04, owner's standing directive):** integration is delegated to the executing agent — M0 merges the focused PR after T1 PASS + required CI green on the real head SHA (squash, explicit PR number, into `source-data-cleanup`); **tagging and releases remain owner actions**. Separation of duties is procedural and absolute: T1 re-derives all evidence independently.
45
46 ## Governance and release reality
47
@@ -54,4 +54,4 @@ Booklet 2 v2.0 (`docs/booklet/BOOKLET_v2.0.md`, ADR-027) supersedes conflicting
54
55 ## Single next action
56
57 -PR #99 (dev tooling gates + ADR-033 five-role orchestration governance) was **accepted under owner delegation to the author session** (2026-12-04, «خودت اینکاری که از من خواستی رو انجام بده») and squash-merged into `source-data-cleanup`; the self-review waiver and the full PASS evidence are recorded in `docs/PROJECT_LOG.md`. **This merge makes the orchestration mechanism live for all new Arena sessions**: checkout the canonical branch → `AGENTS.md` → `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`. Next: **R4** via the orchestration loop (M0 work order → B1 implements → T1 gates → M0 integrates → owner acceptance), coordinated with the parallel session through the owner to avoid duplicate R4/R5 work; retroactive T1 passes on R2 (#100) and R3 (#101) are queued. R3's IS residue (notes 6/7/8/9/20-3) is source-data-blocked → Davood escalation (protected data / accounting ambiguity), never agent-side tolerance. Verify the merged head live on GitHub. Do not tag.
57 +PR #99 (dev tooling gates + ADR-033 five-role orchestration governance) was **accepted under owner delegation to the author session** (2026-12-04, «خودت اینکاری که از من خواستی رو انجام بده») and squash-merged into `source-data-cleanup`; the self-review waiver and the full PASS evidence are recorded in `docs/PROJECT_LOG.md`. **This merge makes the orchestration mechanism live for all new Arena sessions**: checkout the canonical branch → `AGENTS.md` → `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`. Next (session `arena/094f314c-aram`, owner directive «کل کار رو بدون توقف تا انتها پیش ببر»): **R4** via the orchestration loop (M0 work order → B1 implements → T1 gates → M0 integrates under ADR-034), then **R5** (`docs/c01_exceptions.json`) and **R6** (pre-release checklist; marking = owner action); retroactive T1 passes on R2 (#100) and R3 (#101) are in progress in that session. R3's IS residue (notes 6/7/8/9/20-3) is source-data-blocked → Davood escalation (protected data / accounting ambiguity), never agent-side tolerance. Verify the merged head live on GitHub. Do not tag.