Ready system · v0.9.0 · 98/98 tests · open source

The booking system that keeps your rooms from sitting empty

A booking system for a small inn or hotel, already implemented: per-night availability with no overbooking, seasonal rates, direct booking in the chat and on WhatsApp, an iCal calendar for Booking and Airbnb, and the staff on Telegram. Version 0.9.0, 98 of 98 tests passing and independent verification approved (Docker included). Clone it, configure your inn and run it.

Reserva Hotel banner: per-night availability, direct booking, iCal for Booking and Airbnb, and the staff on Telegram
Video

Watch the explainer

The project explained in a few minutes.

What it is

A ready system, built from the contract to 98 green tests

The application is in the repository and it works: ./reserva serve starts the guest chat and the staff page. It was built from a contract, a test suite and guardrails that kept the agent from cheating, with Claude Code and Codex running on the subscription. Its sibling Atende Clínica was built the same way and closed 93 of 93 tests.

Per-night availability, seasonal rates, direct booking, iCal for Booking and Airbnb, stay cycle, staff on Telegram, privacy law and Raio-X

🏨 The system

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, stay 3 nights, pay 2) and a direct-booking discount. Python 3 with the standard library only and SQLite, one inn per installation.

📦 How it was built

A 20-section specification, 98 black-box tests, 17 proposed and accepted decisions, a map to Raio-X, prompts for /goal and for the headless loop, and the guardrails that froze the contract. An adversarial validator fixed 13 problems in the plan before execution. All of it stays in the repository, in case you want to redo or adapt it.

📈 The Raio-X de Margem rules

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 to the Raio-X de Margem panel, which is the source of the business rules.

How it works

From "any rooms for the holiday?" to a completed stay

This is the flow of the implemented system. 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.

Website chat or WhatsApp (Evolution)→ Dates and guests→ Seasonal quote, with direct discount→ Booking with no overbooking→ Reminder, pre-check-in, check-in and check-out→ Post-stay and monthly figures for Raio-X

Guest

Through the chat or WhatsApp, checks availability and price, books, views and cancels their own booking according to the policy (free up to 7 days before, in the example), gets FAQ answers, asks for a human and sends "PARAR" to stop messages.

Staff on Telegram

Alerts for new and cancelled bookings, and the commands /chegadas, /ocupacao, /fila, /responder and /encerrar, also as a direct reply to the guest's message.

/equipe page

With a token: today's arrivals and departures, monthly occupancy map, check-in, check-out and no-show, deposit paid, registries of types, rooms, seasons and FAQ, blocks and the human queue.

Rates and seasons

Base rate per type, seasons (high, low, holiday) with a nightly price, extra person, low-season package and own-channel discount (direct or front desk), never for the OTA. Deposit as a written policy, marked as paid by the staff. Cents rounded half up.

iCal with Booking and Airbnb

Export per type and per room, to block dates on the OTAs. Import of the .ics downloaded from the OTA, uploaded as a file: it becomes a booking with origin booking or airbnb. No external URL is fetched in v1.

Stay cycle

Reminder with pre-check-in a few days before, check-in and check-out by the staff, no-show, post-stay message inviting guests to book direct (only with consent) and a waiting list for full dates.

Prerequisites

What you need

To run the system, Python is enough. Docker comes in for the VPS deploy; Evolution and Telegram are optional and yours. An agent on the subscription is only needed if you want to redo or adapt the system with the same method.

Python 3.10+

The application has no dependencies beyond the standard library. pytest is only used to run the tests.

# check
python3 --version
python3 -m pip install pytest   # optional

Docker, Evolution and Telegram

Docker runs the system on the VPS. An Evolution instance and a Telegram bot only if you want those channels; the credentials live in .env.

# check
docker --version

Claude Code or Codex (optional)

Only to redo or adapt, on the subscription, no paid API. For the headless loop, clone execucao-longa into ~/projetos.

# check
codex --version   # or: claude --version
User guide · step by step

From clone to a running system, in your environment

The commands below are the repository's. Steps 1, 2 and 7 are enough to run it. Steps 3 to 6 tell how the system was built (frozen contract, long run until 98 passed and LIMITES OK, independent verification) and are there to redo or adapt it.

1

Clone the repository and check the tests

./reserva is already in the repository. The whole acceptance suite should pass.

git clone https://github.com/inematds/reserva-hotel && cd reserva-hotel
./reserva --help                               # serve, backup, restaurar, raiox
python3 -m pytest -q tests/ | tail -1          # 98 passed
2

Fit the decisions to your inn

docs/DECISOES-ABERTAS.md lists the 17 default proposals that were accepted and applied to the specification and the tests. For a real pilot, replace exemplos/pousada.json with your room types, rooms, seasons and FAQ. If you want to change something marked ⚠ (for example the direct-booking discount, per-type inventory or the cancellation policy), that changes the contract: follow steps 3 to 6.

less docs/DECISOES-ABERTAS.md
3

How it was built: the frozen contract

Before implementation, the congelar.sh script recorded the hash of tests/, pytest.ini, the specification and both verifiers, plus the base commit, in hash-congelado.txt. From then on, any change to the tests was detected. To redo or adapt, edit the specification and tests, commit and freeze again.

git add -A && git commit -m "contrato v1"
bash longrun/2026-10-05-reservas-v1/congelar.sh
4

How it was built: the agent on a long run

a) Headless loop with Codex. This was the path used. 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. A new session in the project folder, following longrun/2026-10-05-reservas-v1/prompt-goal-claude.md: 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
5

How it was built: monitoring and the human gate

In the loop, loop.log shows each cycle and progress.md has one line per checkpoint. The exit code says what happened: 0 done, 1 cycle cap reached, 2 stopped after 3 cycles without progress, 3 another loop already running in the folder. A test that conflicts with the specification goes to failures.md and is a human gate. That is what happened here: an iCal re-import test reused another event's UID; the human fixed the test, re-froze the contract and the suite closed at 98 of 98.

tail -f longrun/2026-10-05-reservas-v1/loop.log
cat longrun/2026-10-05-reservas-v1/state.md
6

The independent verification (passed)

The agent never saw the last command: it looks for fixture values copied into the code, starts an inn that never appeared (other types, prices with cents, a winter low season, stay 4 pay 3, a 15 % discount, a 50 % deposit, another clock) and runs docker build with a healthcheck. Result on 2026-10-19: INDEPENDENTE OK. Run it again if you change the code.

python3 -m pytest -q tests/                                        # 98 passed
bash longrun/2026-10-05-reservas-v1/verificar-limites.sh              # LIMITES OK at close; now flags only guia/ and README.en/es (docs added later)
python3 longrun/2026-10-05-reservas-v1/verificar-independente.py     # INDEPENDENTE OK
7

Run your inn and deploy to the VPS

Copy the example, replace TROQUE-ESTE-TOKEN and TROQUE-ESTE-SEGREDO and start the server. The guest chat is 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, and is described in the README ("Deploy on the VPS" section): docker compose with the port only on 127.0.0.1:8080, behind an HTTPS proxy; the Evolution webhook at /webhook/evolution/<segredo> (event MESSAGES_UPSERT); the Telegram webhook with setWebhook and secret_token; the /ical/<segredo>/… URL registered on Booking and Airbnb; importing 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
What's in the repo

System, contract, tests and guardrails, with the real numbers

The code that runs, and everything that proved it does what it promises: the contract, the tests and the guardrails used to build it.

98 acceptance tests

Black-box, over HTTP and the command line, in 10 files. All passing on v0.9.0.

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

20-section specification

docs/ESPECIFICACAO.md: execution, pousada.json, nights and availability, rate calculation, authentication, HTTP API, conversation, waiting list, stay cycle, cancellation, iCal, export to Raio-X, privacy law (LGPD), what stays out of v1, pages, registries, database, Evolution, Telegram and Docker. Payment (Pix and card), iCal sync by URL, selling extras, dynamic pricing and multiple inns are explicitly out.

Anti-shortcut guardrails

Frozen hash of tests/, pytest.ini, the specification and both verifiers. File scope: the agent only touched the code and its own logs. No external dependency, no API key, no external URL and no 0.0.0.0 in the code. verificar-limites.sh checks all of it and prints LIMITES OK.

Independent verification

Level 4, hidden from the agent: looks for fixture values in the code, starts a never-seen inn with every argument explicit, and runs docker build and the container healthcheck. Only then does "98 passed" prove general logic. Passed on 2026-10-19.

17 proposed and accepted decisions

Language, channels, direct-booking discount and Booking rate parity, per-type inventory, OTAs via iCal only, deposit and cancellation, rates, stay cycle, what goes to Raio-X, one inn per installation and PT only in v1. Only the items marked ⚠ change the contract.

Validated by an adversarial agent

A validator that never saw the planning checked tests against the specification, redid 70 calculations and tried to break the guardrails. It found and fixed 13 problems, 3 of which would have blocked the run. The full report is in docs/VALIDACAO.md.

The business rules come from Raio-X

Direct booking versus OTA commission, low season with a package and returning guests: docs/MAPA-RAIO-X.md links each leak in the hotel package to a v1 piece or to the reason it stays out. Details in the Raio-X de Margem guide.

Brazilian rules built in

The LGPD privacy law (reminder as contract performance, post-stay only with consent, export and anonymize) and care with the rate-parity clause of Booking's contract in Brazil: no public page shows a price, and the direct discount only appears in the 1:1 conversation. The inn owner validates this point.

Roadmap

Where it is and where it goes

The plan was validated and the implementation is done: v0.9.0, 98 of 98 tests and independent verification passed, through the execucao-longa method. Atende Clínica followed the same path and closed 93 of 93. The next step depends on the inn owner.

Plan ✅
Specification, tests and guardrails validated20-section contract, 98 acceptance tests, proposed decisions, map to Raio-X and adversarial validation completed on 2026-10-05.
Build ✅
System built and verifiedCompleted on 2026-10-19: v0.9.0, 98 passed, LIMITES OK and INDEPENDENTE OK (never-seen inn, real docker build and healthcheck).
Pilot
At a real inn, with the ownerUp to you: real Evolution (WhatsApp) and Telegram credentials, deploy on your VPS, real room types, rooms, seasons and FAQ, staff operating / and /equipe, iCal registered on Booking and Airbnb, and tracking direct bookings, low-season occupancy and returns on the Raio-X Recovery Panel.
Later
Out of v1Payment, iCal sync by URL, selling extras, dynamic pricing, multiple inns and an EN/ES interface are left for a next version, with a human gate.