# Labuh **Every deploy request in one harbour. An agent checks it, a person gives the Gas.** Labuh turns merge and deploy requests on GitLab into boats in a harbour. Label an MR `labuh` and a reviewer agent (named in `reviewer.json`; the examples call it Labuh) reads it, says GO or NO-GO with evidence you can open, and answers questions in the MR thread. The approver sees every request on one board, on a laptop or a phone, and taps **Gas**: Labuh merges, follows the deploy pipeline, and tells the team when it docked. - **Nothing gets lost.** Every request has a place and a state, instead of a message somewhere in a chat. - **Evidence before Gas.** Each finding points at a file and line, a pipeline job or a rubric rule, checked by Labuh before anyone sees it. - **A person stays in charge.** Nothing merges, tags or closes without an approver's tap, and every tap can be undone for 15 seconds. > Labuh is in its first release (v0.1). It works with gitlab.com and runs the reviewer on Codex. --- ## What it's for - **A team that ships through MRs and asks for deploys in chat.** The requests, the review and the decision move into one place; the chat only gets notifications. - **An approver who is not always at a desk.** The agent's review is ready before you are, and Gas works from a phone. - **Repositories that release from tags.** Labuh proposes the next version and its changelog; you confirm the number. Labuh adds nothing GitLab has to enforce: merge permission stays the gate, so if Labuh is down the old flow still works. ## What it can do | | | |---|---| | **Agent review** | Each labelled MR is reviewed against your rubric, the repository and (optionally) your team's notes. A new commit updates the same verdict comment; `@labuh why?` in the thread gets an answer. | | **Checked evidence** | The reviewer answers in a fixed shape. Labuh checks every reference (the line exists at that commit, the job belongs to that pipeline, the rule is in the rubric) and applies hard rules the model can't override: a red pipeline or a moved head is never GO. A malformed answer is retried once, then shown as "needs a manual check". | | **The harbour** | One lane per environment (Prod, Staging), three zones: **Dicek**, **Siap gas**, **Beres**. On a laptop boats glide between berths; on a phone the harbour is one water scene and detail opens as a sheet from the shore. | | **Gas, Tunda, Tolak** | Gas merges the exact commit that was reviewed, after 15 seconds to change your mind. Tunda (hold) and Tolak (reject) take a note the MR thread sees; a rejected MR can be closed from the board. | | **Deploy tracking** | After a merge Labuh follows the pipeline: green docks, red or stuck is flagged. | | **Release proposals** | For branches that deploy from `vX.Y.Z` tags, Labuh proposes the next patch with a changelog of MRs since the last tag. Keep or change the number and press **Rilis**; Labuh creates the annotated tag. | | **Notifications** | A Telegram group hears what needs someone: ready to Gas, deploy failed, release proposal, reviewer error, and a reminder after 4 hours without a decision. | | **Dry mode** | Every check runs and nothing merges, tags or closes, so you can rehearse on real MRs. | The board speaks Indonesian (ajuan = request, dermaga = environment, berlabuh = docked). ## How it fits together ``` developer ── MR + label "labuh" ──► gitlab.com ◄── reads, comments, merges, tags ── Hub │ SQLite approver ── board (browser, phone) ── Gas · Tunda · Tolak · Rilis ──► store ◄────────┤ │ reviewer (Codex app-server, read-only) ◄──────┘ Telegram group ◄── notifications ``` - **Hub:** one process that polls GitLab, runs the reviewer, posts comments and carries out the approver's actions. - **Board:** a small web server for the harbour. It reads the Hub's store and records decisions; only the Hub talks to GitLab. - **Reviewer:** Codex app-server in its own container, reached only by the Hub. It holds no GitLab token, sees the checkouts read-only, and every command it wants to run is first checked by the Hub against an allowlist of programs and paths. --- ## Getting started ### What you need - A GitLab project on gitlab.com and three accounts for Labuh (service accounts work on the Free tier): - **a reader** (Reporter) for polling; - **the reviewer's bot** (Reporter), named like the reviewer so `@labuh` mentions reach it; - **a merge account** that may merge into your target branches (Maintainer for protected ones). It is used only after an approver's action. - A **GitLab OAuth application** for the board: scope `read_api`, redirect `https:///auth/callback`. - **Codex** access for the reviewer (an API key for a server). - Optional: a **Telegram bot** and the chat it posts to. ### Host it (Docker) ```bash git clone https://git.senkensha.space/senkensha/labuh.git && cd labuh mkdir data cp hub.example.json data/hub.json cp board.example.json data/board.json cp reviewer.example.json data/reviewer.json ``` Edit the three files (see [Options](#options)), then put the secrets in two env files next to `compose.yaml`, and make the token the Hub uses to reach the reviewer: ```ini # hub.env GITLAB_TOKEN= # reader LABUH_BOT_TOKEN= # reviewer's bot LABUH_MERGE_TOKEN= # merge account LABUH_TELEGRAM_TOKEN= # optional # board.env LABUH_OAUTH_SECRET= ``` ```bash openssl rand -hex 32 > reviewer.token chmod 600 hub.env board.env reviewer.token sudo chown 1000:1000 reviewer.token && mkdir -p data/.work && sudo chown -R 1000:1000 data # the containers run as uid 1000 ``` Log the reviewer in to Codex once, then start: ```bash docker compose build docker compose run --rm reviewer codex login --with-api-key # paste the key, then Ctrl-D docker compose run --rm hub node src/hub-cli.ts check-bot docker compose up -d ``` Three containers start: the **hub**, the **reviewer** and the **board**. The board listens on port 4810; put it behind your TLS proxy at the `publicUrl` you configured. The reviewer has no published port. `data/` holds the store (`.work/hub/labuh.db`) and the checkouts, the `reviewer-codex` volume holds the reviewer's Codex login and threads: back both up, and run only one Hub per store. Team notes for the reviewer (`knowledge` in `reviewer.json`) are mounted read-only into the hub and the reviewer at the same path; see the commented lines in `compose.yaml`. Start with `"mode": "shadow"` and `"gas": {"mode": "dry"}`: the reviewer's comments go to `data/.work/hub/outbox/` and Gas only rehearses. Switch to `live` when the reviews look right. ### Run it on a laptop Needs Node 23.6 or newer, `glab` logged in to gitlab.com (it is the reader) and the Codex CLI logged in. ```bash cp hub.example.json hub.json && cp board.example.json board.json && cp reviewer.example.json reviewer.json npm run hub -- run # in one terminal npm run board # in another ``` On macOS the tokens can live in the Keychain instead of the environment: `labuh-bot-token`, `labuh-merge-token`, `labuh-telegram-token`, `labuh-oauth-secret`. For local work, `LABUH_BOARD_DEV_USER=` skips sign-in while the board listens on 127.0.0.1. ## Using Labuh **Developers** label their MR `labuh`, read the reviewer's comment, push fixes, and ask it in the thread (`@labuh` in the examples). The board shows them the same harbour, without the buttons. **Approvers** open the board (or tap the link in a notification), read the verdict and findings, and choose: - **Gas:** merge now. "Merge dalam 15 dtk" with **Batalkan** to take it back. - **Tunda:** hold, with a note for the MR. - **Tolak:** reject, with a note; **Tutup MR** then closes it in GitLab. - **Rilis:** on a release proposal, confirm or change the tag number. ### Commands ```bash npm run review -- # one review in the terminal, then follow-up questions npm run hub -- run # the Hub: poll and work until stopped npm run hub -- add # make any MR an ajuan without labelling it npm run hub -- ask "question" # ask as if mentioned in the thread npm run hub -- recheck # review the same commit again after the rubric changed npm run hub -- status # ajuan, verdicts, tokens, queued events npm run hub -- check-bot | check-merge # who each token is and its role (read-only) npm run hub -- telegram-setup # list chats that wrote to the bot npm run hub -- telegram-test # send one test message ``` In Docker, prefix with `docker compose run --rm hub node src/hub-cli.ts …` (or `src/cli.ts review …`). ## Options ### `hub.json` | Key | | |---|---| | `mode` | `shadow` writes comments to a local outbox; `live` posts them as the bot. | | `projects` | GitLab projects to watch, `group/repo`. | | `label` | The label that makes an MR an ajuan, usually `labuh`. | | `pollSeconds` | How often to poll GitLab. | | `botUsername` | The reviewer bot's username, to ignore its own notes. | | `deployBy` | Per project and target branch, `"tag"` when that branch deploys from release tags: `{"group/repo": {"production": "tag"}}`. Default: deploys on merge. | | `gas.mode`, `gas.graceSeconds` | `dry` or `live`; seconds to undo an action. | | `notify` | `telegramChatId`, `boardUrl` for links, `remindHours`. | | `devops` | `{"users": ["gitlab-user"], "rules": ["R9", "R13"]}`: who owns deploy setup. A `bad` or `todo` finding that cites one of `rules` (default R9, R13) or points at a CI file, Dockerfile, compose file or manifest tags them, once until the deploy findings go away. | ### `board.json` | Key | | |---|---| | `host`, `port`, `publicUrl` | Where the board listens and the address people use. | | `gitlabClientId` | The OAuth application's id. | | `approvers` | GitLab usernames that may act. Everyone else with access to a watched project reads. | | `lanes` | Lanes and the target branches that belong to them. | | `doneHours` | How long docked boats stay in Beres at most. | ### `reviewer.json` | Key | | |---|---| | `name` | The reviewer's name everywhere (comments, mentions, board). | | `codexBin`, `model`, `effort` | The Codex binary and the model it uses. | | `rubric` | The rubric file; `rubric/rubric.md` is a starting point. Each rule has an id the reviewer cites. | | `budgetTokensPerAjuan` | Past this, the ajuan asks for a manual review. | | `knowledge` | Optional team notes the reviewer may read: `root`, the folders to `read`, folders to `deny`. Mount them read-only. | | `server` | `{"url": "ws://reviewer:4820"}` to use the reviewer container; leave it out to run Codex on this machine with its own read-only sandbox. | ### Environment `LABUH_HOME` (configuration and state; default the checkout), `GITLAB_TOKEN`, `LABUH_BOT_TOKEN`, `LABUH_MERGE_TOKEN`, `LABUH_TELEGRAM_TOKEN`, `LABUH_OAUTH_SECRET`, and `LABUH_REVIEWER_TOKEN` or `LABUH_REVIEWER_TOKEN_FILE` for the reviewer container. ## Security and privacy - Three GitLab identities with separate tokens; the merge token is used only after an approver acts. Tokens are read from the environment and never stored, logged or printed. - The reviewer runs apart from every credential. In Docker it is its own container: no GitLab token, read-only root and checkouts, no capabilities, reachable only with a token the Hub holds. On a laptop it is Codex's read-only sandbox with no network. Either way, every command it asks to run goes to the Hub, which refuses programs outside a read-only list and any path outside the checkout, its work folder and the knowledge folders. - MR content is treated as untrusted input; verdicts are advice, the approver decides. - The board keeps no GitLab token after sign-in, only which watched projects the user can read. ## Limitations - gitlab.com only; one reviewer per hub; polling, no webhooks yet. - Linked MRs (a frontend that needs its backend first) are not tracked yet. - Labuh does not run post-deploy commands; the reviewer lists them for a person. ## Developing ```bash npm test ``` [docs/SPEC.md](docs/SPEC.md) holds the decisions and milestones. ## License [AGPL-3.0](LICENSE).