Specification, 98 acceptance tests, guardrails and prompts for an agent to build, in your own environment, the booking system of a small inn or hotel: per-night availability with no overbooking, seasonal rates, direct booking in chat and WhatsApp, an iCal calendar for Booking and Airbnb, and the staff on Telegram. The system is not implemented yet: this repository is the plan, and you run the implementation.

There is no finished app here. There is the contract for what the app must do, the test battery that proves it, and the guardrails that stop the agent from cheating. Claude Code or Codex builds it, running on your machine, on your subscription. The sibling project Atende Clínica was made exactly this way and closed 93 of 93 tests.
Room types and numbered rooms, per-night availability (check-in inclusive, check-out exclusive) with no overbooking, minimum stay, closures and blocks. Seasonal rates with a low-season package (for example, 3 nights pay 2) and a direct-booking discount. Python 3 with only the standard library and SQLite, one inn per installation.
A 20-section specification, 98 black-box tests, 17 decisions already proposed, a map to Raio-X, prompts for /goal and for the headless loop, and the guardrails that freeze the contract. An adversarial validator already went through everything and fixed 13 problems, 3 of which would have blocked the run.
A guest who books direct pays no OTA commission, and the low season gets its own price and package. The system returns receita_ota, retorno_atual_pct, ocupacao_baixa_pct and other figures for the Raio-X de Margem panel, which is the source of the business rules.
This is the flow of the planned system, what the agent will build. A Python server with no dependencies, SQLite in a data folder, and Docker for the VPS. Evolution and Telegram come in only through environment variables; without them, the outbox is simulated and no network call goes out.
Through chat or WhatsApp the guest checks availability and price, books, views and cancels their own booking according to the policy (free until 7 days before, in the example), gets answers from the FAQ, asks for a human agent and sends "PARAR" (stop) when they want no more messages.
Notices of new and cancelled bookings, and the commands /chegadas (arrivals), /ocupacao (occupancy), /fila (queue), /responder (reply) and /encerrar (close), also as a direct reply to the guest's message.
With a token: the day's arrivals and departures, the month's occupancy map, check-in, check-out and no-show, deposit paid, records for types, rooms, seasons and FAQ, blocks and the human queue.
Base rate per type, seasons (high, low, holiday) with a price per night, extra guest, low-season package and an own-channel discount (direct or front desk), never for the OTA. The deposit is a written policy, marked as paid by the staff. Cents rounded half up.
Export per type and per room, to block the dates on the OTAs. Import of the .ics downloaded from the OTA, sent as a file: it becomes a booking with source booking or airbnb. No external URL is fetched in v1.
A reminder with pre-check-in a few days ahead, check-in and check-out by the staff, no-show, a post-stay message inviting the guest to book direct (only with consent) and a waitlist for full dates.
To run the plan you only need Python for the tests and an agent logged in through a subscription. Docker only comes in at the final check and the deploy; Evolution and Telegram are optional and yours.
The tests use pytest (a development tool). The application itself will have no dependencies.
# check python3 --version python3 -m pip install pytest
Through the subscription, no paid API. For the headless loop, clone execucao-longa into ~/projetos.
# check codex --version # or: claude --version
Docker does the final build and the VPS deploy. An Evolution instance and a Telegram bot only if you want the channels; the credentials live in .env.
# check docker --version
The commands below are the repository's own. The cycle: answer the decisions, freeze the contract, run the agent until 98 passed and LIMITES OK, and check with the independent verification.
There is no ./reserva yet: the repository only holds the plan. Check that the suite is collected without errors and that nothing passes yet (without the implementation the tests fail or error out, and that is expected).
git clone https://github.com/inematds/reserva-hotel && cd reserva-hotel python3 -m pytest -q --collect-only | tail -1 # 98 tests collected python3 -m pytest -q | tail -1 # 0 passed
Read docs/DECISOES-ABERTAS.md (written in Portuguese): there are 17 default proposals already applied in the specification and the tests. Answering "ok on everything" unblocks the run. If you change anything marked ⚠ (for example the direct-booking discount, per-type inventory or the cancellation policy), edit docs/ESPECIFICACAO.md and the tests before freezing. For a real pilot, also replace exemplos/pousada.json with your own room types, rooms, seasons and FAQ.
less docs/DECISOES-ABERTAS.md
With everything committed, the script records the hash of tests/, pytest.ini, the specification and the two verifiers, plus the base commit in hash-congelado.txt, and makes one commit. From then on, any change to the tests is detected. If there are pending changes, the script stops and asks you to commit first.
git add -A && git commit -m "contrato v1" bash longrun/2026-10-05-reservas-v1/congelar.sh
a) Headless loop with Codex (recommended). loop.env sets 20 cycles of 30 min, 8 GB per cycle, a stop after 3 cycles without progress, model gpt-6-astra and CODEX_ARGS="-c sandbox_workspace_write.network_access=true": without it the Codex sandbox blocks the tests' local server.
~/projetos/execucao-longa/tools/loop-longrun.sh longrun/2026-10-05-reservas-v1
b) /goal in Claude Code. Open a new Claude Code session in the project folder and follow longrun/2026-10-05-reservas-v1/prompt-goal-claude.md: paste the /goal condition (the output must show 98 passed and LIMITES OK) and, as the first message, the block from prompt-goal-codex.md starting at RESULTADO:.
claude # new session, inside reserva-hotel
c) Codex TUI. Paste the contents of longrun/2026-10-05-reservas-v1/prompt-goal-codex.md.
codex -c sandbox_workspace_write.network_access=true
In the loop, loop.log shows each cycle and progress.md has one line per checkpoint. The loop's exit code tells you what happened: 0 done (the final test passed), 1 cycle ceiling reached, 2 stopped after 3 cycles without progress, 3 another loop is already running in the folder. A test that conflicts with the specification goes to failures.md: that is a human gate, and the agent must not adjust the test or the specification.
tail -f longrun/2026-10-05-reservas-v1/loop.log cat longrun/2026-10-05-reservas-v1/state.md
When the agent says "done", run the three commands. The last one the agent has never seen: it looks for fixture values copied into the code, brings up an inn that never appeared (other types, prices with cents, a winter low season, a 4-pay-3 package, a 15 % discount, a 50 % deposit, another clock) and runs docker build with a healthcheck. Then open / and /equipe in the browser.
python3 -m pytest -q tests/ # 98 passed bash longrun/2026-10-05-reservas-v1/verificar-limites.sh # LIMITES OK python3 longrun/2026-10-05-reservas-v1/verificar-independente.py # INDEPENDENTE OK
With the system implemented, copy the example, replace TROQUE-ESTE-TOKEN and TROQUE-ESTE-SEGREDO (the placeholder token and secret) and start the server. The guest chat lives at / and the staff page at /equipe (header X-Token).
mkdir -p dados && cp exemplos/pousada.json dados/pousada.json ./reserva serve --porta 8080 --dados dados
The deploy is yours, with your credentials. The agent itself writes the deploy README as part of the goal: bring up docker compose (port only on 127.0.0.1:8080, behind an HTTPS proxy), the Evolution webhook at /webhook/evolution/<secret> (event MESSAGES_UPSERT), the Telegram webhook with setWebhook and secret_token, the /ical/<secret>/… URL registered on Booking and Airbnb, the import of their .ics through the staff page and the daily backup (./reserva backup in cron).
cp .env.exemplo .env && chmod 600 .env # fill in EVOLUTION_*, TELEGRAM_*, WEBHOOK_SEGREDO docker compose up -d --build
Everything the agent needs to build, and everything that stops it from pretending it built.
Black-box, over HTTP and the command line, in 10 files.
test_inventario.py 17 test_integracoes.py 16 test_conversa.py 14 test_ciclo.py 11 test_tarifas.py 10 test_cadastros.py 9 test_ical.py 7 test_basico.py 6 test_docker.py 4 test_lgpd_raiox.py 4
docs/ESPECIFICACAO.md: execution, pousada.json, nights and availability, rate calculation, authentication, HTTP API, conversation, waitlist, stay cycle, cancellation, iCal, export to Raio-X, privacy law (LGPD), what stays out of v1, pages, records, database, Evolution, Telegram and Docker. Payment (Pix and cards), iCal sync by URL, selling extras, dynamic pricing and multiple inns are explicitly out.
A frozen hash of tests/, pytest.ini, the specification and the two verifiers. File scope: the agent only touches the code and its own records. No external dependency, no API key, no external URL and no 0.0.0.0 in the code. verificar-limites.sh checks all of this and prints LIMITES OK.
Level 4, hidden from the agent: it looks for fixture values in the code, brings up an inn nobody has seen, with every argument explicit, and runs docker build and a container healthcheck. Only then does "98 passed" prove general logic.
Language, channels, the direct-booking discount and Booking parity, per-type inventory, OTAs through iCal only, deposit and cancellation, rates, the stay cycle, what goes to Raio-X, one inn per installation and PT only in v1. Only the items marked ⚠ change the contract.
A validator that never saw the planning checked tests against the specification, redid 70 calculations and tried to get around the guardrails. It found and fixed 13 problems, 3 of which would have blocked the run. The full account is in docs/VALIDACAO.md.
Direct booking versus OTA commission, a low season with a package, and the guest who comes back: docs/MAPA-RAIO-X.md ties each leak of the hotel pack to a piece of v1 or to the reason it stays out. Details in the Raio-X de Margem guide.
LGPD (Brazil's privacy law: the reminder as contract performance, the post-stay message only with consent, export and anonymize) and the care around price parity in Booking's contract in Brazil: no public page shows a price, and the direct discount only appears in the 1:1 conversation. The inn's owner validates this point. Outside Brazil, adapt them to local law.
The plan is ready and validated. The implementation does not exist yet: it is born when you run the /goal, through the execucao-longa method. Atende Clínica followed the same path and closed 93 of 93.
98 passed and LIMITES OK, then the independent verification. Today the system is not implemented.