# BAS Agent Hack Day — presentation notes

This is a hack-day retrospective and an intentionally time-stamped work in progress. It covers both
the multi-agent experiment and the separation between the requested BAS workflow and what
the Xero APIs can actually support. Both implementation tracks shipped: Callum's is working locally,
and Craig's is running in dev. The shared context mono repo is
<https://github.com/TwoDotAi/exp-bas>.

## Current narrative

1. Callum and Craig deliberately sent multiple agents at the same end-to-end problem, keeping the
   goal fixed while varying the agent setup.
2. Callum used Hermes Agent with Codex SOL. The resulting BAS Agent is running locally and working.
3. Craig used the existing Crewbase read script to turn Jack's tasks into a verified summary at
   <https://bas-agent.daybreak.exp.twodot.ai/>. Jack then surfaced a FigJam diagram that would
   otherwise have been missed, and a clanker converted screenshots of it into Markdown and Mermaid.
4. That richer context was committed to the shared context mono repo,
   <https://github.com/TwoDotAi/exp-bas>, and every Craig-led session used it.
5. `API-MAP.md` proved especially valuable: it mapped each requirement to an API, OAuth scope,
   computation, experiment, or human step, exposing the Platform integration backlog implemented in
   mono PR #3762.
6. Craig launched three experiments: mono-aware with Will's local-environment instructions,
   deliberately repo-naïve, and Gas City. The Gas City run noticed existing work and asked to wait
   for it so it could improve the result instead of duplicating it. The Mono-aware implementation
   shipped to dev via Claude Fable and direct Codex SOL.
7. Rate limiting removed Claude while several sessions were active, so Craig wrote a tool to switch
   the sessions to Codex and keep them running.
8. Hooks from three hackathon participants made the swarm visible in the shared metrics collector.
   Liam hit 50 concurrent agents by himself—halfway to Grant's goal of 100.
9. The domain brief contained 27 requirements across five stages.
10. The intended flow is a funnel: calendar → readiness → reconciliation → calculation → sign-off.
11. The process was described through Xero UI operations, but several of those operations do not have
   public API equivalents.
12. BAS preparation and review are buildable; BAS lodgement is not.
13. W1 is the representative hard problem: it requires configured pay-item semantics and per-payslip
   data, not a single aggregate.
14. Three explicit human boundaries remain: bank-reconciliation attestation, ATO-prefill comparison,
   and lodgement.
15. The safe implementation shape is Demo Company only, GET-only, deterministic arithmetic, and LLM
   narration only.
16. The time-stamped output was an implementation-grade feasibility map, a working local build from
   Callum, and a Craig-led build running in dev.
17. A credible next slice proves one period end to end without lodging.
18. LedgerPilot for Xero provides a review-first Chrome-extension experiment for driving the visible
   Manual Journals UI. Journals were not required for this BAS design because Trial Balance plus
   transaction endpoints provide the evidence, but the robot is a useful probe for other Xero work
   where the usable API surface is missing or gated.

## `API-MAP.md` integration gaps

The map was verified against Xero's published OpenAPI specification and the Platform state at
`TwoDotAi/mono@44a1ba938`. It turned the agent design into a concrete integration backlog:

- Four ungated Xero OAuth scopes were missing:
  `accounting.reports.trialbalance.read`, `accounting.reports.taxreports.read`,
  `accounting.reports.profitandloss.read`, and `payroll.payruns.read`.
- Platform needed typed, centrally authorised read capabilities for Trial Balance, Profit & Loss,
  published BAS reports, and payroll pay runs. Published-BAS reads may validly return empty, so the
  human-input path must remain the contract.
- Existing Xero integrations must re-consent before the granular scopes become available.
- Google Chat scopes plus send, reply, and `call_human` resolution already existed. The missing
  production Kafka topic was a separate infrastructure dependency.
- `accounting.journals.read` was deliberately avoided because it requires the Xero Advanced tier,
  a security assessment, and use-case approval. Trial Balance plus transaction endpoints provides
  the required evidence without that dependency.
- No Xero API writes Activity Statement fields or lodges a BAS; those remain human actions.

Source: <https://github.com/TwoDotAi/exp-bas/blob/main/API-MAP.md> and
<https://github.com/TwoDotAi/mono/pull/3762>.

## Delivery summary — captured 2026-07-17

### Shipped and running

- Callum's Hermes + Codex SOL implementation, working locally.
- Craig's Claude Fable + direct Codex SOL implementation, running in dev.
- The initial 27-task, five-stage BAS workflow and its unit/fake-integration coverage.
- Exposure of the workflow to Kylie-enabled organisations and the assistant catalogue.
- The engineering-presentation publisher, BAS deck, hack-day lessons and embedded telemetry.
- The `exp-bas` shared context repo and implementation-grade `API-MAP.md`.

### Built and in review

- Four granular Xero report/pay-run scopes and four typed gateway reads.
- Seven Callum-led workflow PRs covering reconciliation evidence, prefill audit, lodgement dates,
  period-scoped labels, director Chat sign-off, lodgement frequency and scheduler E2E coverage.
- The production Google Chat subagent Kafka topic and per-host agent telemetry dashboard.

### Did not ship

- Direct ATO-prefill access or BAS write/lodgement; those remain human boundaries.
- A production-grade journal robot. LedgerPilot is an experiment for a demo organisation, not an
  API replacement or a bypass around Xero permissions, confirmation, validation or MFA.
- End-to-end proof against accountant-approved real Xero responses.

### Journal robot experiment

LedgerPilot for Xero observes privacy-safe fetch/XHR metadata and drives Xero's visible Manual
Journals UI. It supports draft creation and update plus review-gated post, reverse, delete and void
operations. Xero documents a Manual Journals API; the experiment is specifically useful for testing
signed-in UI automation without an OAuth client when the usable API surface is unavailable or gated.
The BAS design does not depend on Journals: Trial Balance plus transaction endpoints provide the
required evidence without the Advanced-tier `accounting.journals.read` scope.

## Lessons learned

- Under a severe time box, redundant full-problem attempts can buy optionality faster than a clean
  decomposition and coordination plan.
- A verified brief and machine-readable diagrams can give independent agents a common domain model
  and set of API constraints.
- A requirement-to-API map can expose reusable platform work before implementation begins; in this
  case it found missing scopes, capabilities, consent and infrastructure dependencies.
- Different agent mixes both reached working results: Hermes plus Codex SOL locally, and Claude
  Fable plus direct Codex SOL in dev.
- Varying the harness exposed different assumptions, including useful self-coordination from the Gas
  City run.
- Provider portability is critical-path resilience when rate limits consume most of the build window.
- Shared lifecycle hooks turn a swarm from invisible background work into something the team can
  inspect and learn from.

## Screenshot assets

- Callum's resulting BAS Agent run (`callum-hermes-bas-agent.png`) showing the local timeline at an
  escalation boundary.
- Callum's local BAS Agent input view (`callum-bas-agent-detail.png`) showing the request detail for
  an awaiting-input state.
- Agent metrics / concurrency dashboard (`agent-metrics-concurrency.png`) added from the hack-day
  Grafana capture; Liam's host peaks at 53, shown in the deck as a rounded 50.
- LedgerPilot browser-extension experiment (`xero-journal-robot.png`) shown beside Xero Manual
  Journals in the demo organisation.

## Source map

- Context mono repo: <https://github.com/TwoDotAi/exp-bas>.
- `requirements.txt` — PROJECT-052 task breakdown.
- `Stage1.png` … `Stage5.png` — original process diagrams.
- `BAS-AGENT.md` — reconstructed five-stage process design.
- `API-MAP.md` — requirement-to-capability mapping and Platform integration gap analysis.
- `PLAN.md` — corrected implementation and safety plan.
- `experiments/xero-journal-robot` — LedgerPilot for Xero browser-extension experiment.

## Appendix: BAS Agent PRs created 2026-07-17

### Craig (`twodotcraig`)

| PR | State | What it is |
|---|---|---|
| [mono #3749](https://github.com/TwoDotAi/mono/pull/3749) | Open | Per-host agent telemetry used in this deck, plus a bounded CACP row-window OOM fix. |
| [mono #3750](https://github.com/TwoDotAi/mono/pull/3750) | Merged | Initial 27-task, five-stage BAS workflow with unit and fake-integration E2E coverage. |
| [mono #3760](https://github.com/TwoDotAi/mono/pull/3760) | Merged | Initial BAS hack-day deck and the engineering-presentation CDN publisher. |
| [mono #3762](https://github.com/TwoDotAi/mono/pull/3762) | Open | Xero report/pay-run scopes and typed gateway reads discovered through `API-MAP.md`. |
| [mono #3763](https://github.com/TwoDotAi/mono/pull/3763) | Merged | Exposes the BAS workflow to Kylie-enabled organisations and the assistant catalogue. |
| [mono #3764](https://github.com/TwoDotAi/mono/pull/3764) | Merged | Expands the deck with the team's agent strategy, telemetry and lessons learned. |
| [mono #3767](https://github.com/TwoDotAi/mono/pull/3767) | Merged | Embeds the Grafana agent-concurrency capture in the presentation. |
| [mono #3769](https://github.com/TwoDotAi/mono/pull/3769) | Merged | Adds the context-repo and `API-MAP.md` findings plus this linked PR appendix. |
| [mono #3772](https://github.com/TwoDotAi/mono/pull/3772) | Merged | Marks the mono-aware BAS implementation as shipped to dev. |
| [mono #3773](https://github.com/TwoDotAi/mono/pull/3773) | Open | Adds the PDF export and the higher-resolution Callum screenshots. |
| [infra #1653](https://github.com/TwoDotAi/infra/pull/1653) | Open | Provisions the production Kafka topic required by the Google Chat subagent. |

### Callum (`twodotcal`)

| PR | State | What it is |
|---|---|---|
| [mono #3753](https://github.com/TwoDotAi/mono/pull/3753) | Open | Propagates Xero reconciliation evidence and escalates false or missing status. |
| [mono #3755](https://github.com/TwoDotAi/mono/pull/3755) | Open | Audits operator-approved prefill adjustments with responder and timestamp provenance. |
| [mono #3756](https://github.com/TwoDotAi/mono/pull/3756) | Open | Refreshes BAS periods and handles extensions, weekends and configured public holidays. |
| [mono #3757](https://github.com/TwoDotAi/mono/pull/3757) | Open | Persists reconciliation GLs and calculates period-scoped labels with ATO exclusion. |
| [mono #3761](https://github.com/TwoDotAi/mono/pull/3761) | Open | Routes director sign-off through a dedicated Google Chat space. |
| [mono #3765](https://github.com/TwoDotAi/mono/pull/3765) | Open | Gates preparation by inferred lodgement frequency and preserves Xero line evidence. |
| [mono #3766](https://github.com/TwoDotAi/mono/pull/3766) | Open | Covers the daily scheduler E2E and repairs canonical browser-session test setup. |
| [mono #3770](https://github.com/TwoDotAi/mono/pull/3770) | Open | Persists evidence and reasons for prior-period reconciliation decisions. |
| [mono #3771](https://github.com/TwoDotAi/mono/pull/3771) | Open | Proves matching and corrected planning paths both converge at Fill in W1. |

States captured from GitHub on 2026-07-17. The related set includes BAS workflow,
integration, infrastructure, presentation, and the telemetry work shown in the deck; unrelated PRs
created by either author that day are excluded.

## Refinement prompts worth answering

- Who is the audience: engineering, accounting operations, or leadership?
- What did each implementation ship, and what still needs hardening?
- Are there concrete Xero responses, dry-run results, or failures we can safely show?
- What decision or commitment should the room make at the end?
