Skip to content
42 changes: 42 additions & 0 deletions .backlog/FIX-FAT-COW-STRANDED/PRD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# FIX-FAT-COW-STRANDED — an AI Fat Cow lifted off its FARP and hovered until it ran out of fuel

**Status:** 🟡 ready — analysis and decisions by the control session on 2026-11-24 (below, each with its reason). They are defaults, not questions: apply them unless the code or a measurement proves one wrong, and then say why in the PR.

Reported by Zip through VMCT, Campagne server, evening of 2026-11-22: "a Fat Cow took off again from where its FARP (CTLD Fat Cow 1) had been, and stopped in a hover until it ran out of fuel".

## What the log says

`dcs.log` of the Campagne server, 2026-11-22, UTC, filtered on "Fat Cow" (the file was overwritten at the 22:28 mission restart; these lines are all that is left):

- 15:12:07 cow `Fat Cow Hatay_AH-64D BLK.II_26 #1-1` lands in a clearing 105 m from the asked point.
- 15:25:05 scene `Fat Cow FARP#1` starts; 15:25:07 the cow is deployed, FARP `CTLD_FatCow_FARP_1`, 4,800 kg of fuel.
- 15:54:23 the FARP is packed (`packScene`, 5 objects destroyed); cow `packed`, 4,494 kg left.
- 15:54 → 21:16: no line from `CTLDFatCowManager`.
- 21:16:55 `WARN` cow `… #1-1` is no longer in the world, with no event: forgotten.

## Analysis (control session, from the code at `e2126be`)

- **It is an AI cow**, requested by the flight of the Apache `Hatay_AH-64D BLK.II_26` (the `Fat Cow <flight> #n` name of `requestAICow`). The piloted path of FEAT-FAT-COW-LEAVE-FARP (#286) is not involved. FIX-FAT-COW-AI-LANDING is merged (#278), not in progress.
- **What packed it at 15:54.** On an AI cow, `pack` is called by: the F10 orders **Take off** (orbit where it stands), **Hold here** (orbit over the requester), **Join us** (follow), **RTB** (land at home); the leader's take-off (`_onAITakeoff`, AI flights only, not this one); the orphan return (`_returnHome(cow, true)`, which logs "offered for take-over" — absent). So it was **one of the four F10 orders**, and none of them writes a log line. **Take off** fits the report best: it orbits at the cow's own position, 150 m AGL, 40 m/s — whether a DCS AI CH-47 flies that `Orbit` as a circle or sits in a hover is **not measured**.
- **Why it stayed up for 5 h 20 min.** A holding or following cow waits for the next order forever: nothing in the manager looks at its fuel. If the Apache player left, the orphan check should have sent it home — but that check runs **once, 2 s after** an `S_EVENT_PLAYER_LEAVE_UNIT` / `S_EVENT_DEAD`, and never again. If the client group still answers `getUnit(1)` at that instant, the cow is never sent home. Not measured either.
- **Why "no event".** The 10 s loop (`_forgetVanishedCows`) did its job: the unit vanished without `S_EVENT_DEAD` / `S_EVENT_CRASH` reaching the manager. What DCS fires for an AI helicopter that runs dry is not known; the defect is upstream (it should never have run dry).

## Implementation Decisions

1. **Log every order and every phase change of an AI cow** (`INFO`, cow name, order or phase, who gave it). Reason: the 5 h hole in the log made the cause unprovable; the next report must be readable.
2. **The orphan check also runs in the 10 s loop**, next to `_forgetVanishedCows`, not only 2 s after an event. Reason: one check at a fixed delay is a race against DCS removing the client unit; the loop already exists.
3. **Bingo fuel: a cow in the air with less than 25 % internal fuel (`Unit:getFuel()`) packs nothing, goes home (`_returnHome`) and tells its flight** ("The Fat Cow is low on fuel and returns home."). A constant, not a setting. Reason: whatever the order and whatever the player does, a cow must never fall out of the sky; 25 % of a CH-47 is enough to cross a map. The new text goes through `ctld.tr` and the four dictionaries.
4. **Measure, in the live check, the two premises above**: what an AI CH-47 does with the `Orbit` task of `_orbit` (circle or hover), and whether a client group still answers `getUnit(1)` 2 s after its player leaves (this one needs Zip in a slot). If the orbit is a hover, say so in the PR and propose the fix as a follow-up; do not change the orbit in this lot without the measurement.
- **No ADR.**

## Testing Decisions

- TDD in the existing Fat Cow spec: each order and phase change writes its line; a cow whose flight's group still exists at 2 s but is gone at the next loop tick is sent home; a cow in the air below 25 % goes home and the flight reads the message, a cow on the ground or above 25 % does not.
- Coverage ratchet only goes up; `busted tests/ci/`, luacheck, Lua 5.1 lint, the build, the i18n guard green.

## Tickets

- [01 log the orders and phases](tickets/01-log-orders-and-phases.md)
- [02 orphan check in the loop](tickets/02-orphan-check-in-the-loop.md)
- [03 bingo fuel](tickets/03-bingo-fuel.md)
- [04 live check](tickets/04-live-check.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 01 — Log the orders and phases of an AI cow

**Status:** 🟡 ready · **Type:** AFK

## Parent
[PRD](../PRD.md), decision 1.

## What to build
An `INFO` line for every F10 order given to an AI cow (Land here, Take off, Hold here, Join us, RTB, Release, Take over: cow name, order, requesting unit) and for every change of `cow.ai.phase` (old → new). One helper, called where the phase is set.

## Acceptance criteria
- [ ] Each order and each phase change writes exactly one line naming the cow.
- [ ] No line per loop tick (no noise when nothing changes).
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 02 — The orphan check also runs in the 10 s loop

**Status:** 🟡 ready · **Type:** AFK

## Parent
[PRD](../PRD.md), decision 2.

## What to build
`_sendHomeOrphans` is also called by the 10 s loop that calls `_forgetVanishedCows`, so a cow whose flight disappears is sent home even when the one-shot check 2 s after the event ran too early.

## Acceptance criteria
- [ ] A flight still present at the 2 s check and gone at the next loop tick: its cow goes home and is offered for take-over, once.
- [ ] A cow already returning is not sent home again.
13 changes: 13 additions & 0 deletions .backlog/FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 03 — Bingo fuel: a cow low on fuel goes home

**Status:** 🟡 ready · **Type:** AFK

## Parent
[PRD](../PRD.md), decision 3.

## What to build
In the 10 s loop, an AI cow in the air (`ctld.utils.inAir`) whose `getFuel()` is below 25 %, and not already returning, goes home through `_returnHome` and its flight reads "The Fat Cow is low on fuel and returns home." (new `ctld.tr` key, four dictionaries). Logged as `WARN` with the fuel fraction. Pilot guide EN+FR: one sentence on it. CHANGELOG *Fixed* entry.

## Acceptance criteria
- [ ] Holding, following or released cow in the air below 25 %: goes home, message once, log once.
- [ ] A cow on the ground, already returning, or at 25 % or more: unchanged.
28 changes: 28 additions & 0 deletions .backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 04 — Live check and the two measurements

**Status:** ✅ done 2026-11-24 · **Type:** HITL for (b) (Zip in a slot), AFK otherwise; Zip launches DCS, the session launches dcs-serve

## Parent
[PRD](../PRD.md), decision 4. Blocked by 01-03.

## What to build
On `Test_CTLDNEXT_01.miz`, over the DCS bridge:

- (a) An AI cow given **Take off**: record its speed and position over two minutes. Circle or hover?
- (b) With Zip in a helicopter slot that requested a cow: Zip leaves the slot; record whether his group still answers `getUnit(1)` at 2 s, 5 s, 10 s, and that the cow goes home.
- (c) Bingo: set the cow's fuel low (or wait with a reduced fuel load) and check it goes home with the message.
- (d) The orders and phases appear in `dcs.log`.

## Acceptance criteria
- [x] (a)-(d) recorded PASS/FAIL or as measured values, with the log lines.
- [x] If (a) is a hover, the PR says so and proposes the fix as a follow-up lot.
- [x] Nothing left in the mission afterwards.

## Measured, 2026-11-24 (`Test_CTLDNEXT_01.miz`, DCS bridge, build of this PR)

- **(a) PASS, circle, not a hover.** An AI CH-47 given *Take off* flew at 35.7-42.9 m/s (mean 39.7) over 120 s; its distance from the orbit point grew from 249 m to 1741 m at 120 s and 2077 m at 210 s, its heading turning about 1.2 deg/s: a circle of roughly 1.9 km radius. It burns fuel while it circles. No follow-up lot needed.
- **(b) The client group is gone at once.** Player leaves the slot: at the first sample (0.1 s) and at 2.1 s, 5.1 s and 10.1 s `Group.getByName` already returns nothing (`group=false`, `getUnit(1)=false`), and the cow is already `returning` and no longer registered to the flight. The 2 s check therefore does not race the removal in this setup (a first pass, whose sampler recorded nothing, logged the cow going home 3.1 s after the leave). The 10 s loop check stays as the safety net for the slower cases of the 2026-11-22 incident.
- **(c) PASS.** A CH-47 at 0.13 of its tanks, in the air, registered as the cow of a flight: the 10 s loop sent it home and its flight read "The Fat Cow is low on fuel and returns home." Log: `cow 'Bingo Cow-1' is low on fuel (0.13 of its tanks, phase following): sent home` (WARN), then `phase following -> returning`.
- **(d) PASS.** `dcs.log` shows `cow 'Fat Cow Stranded #1-1' order 'Take off' from 'Stranded-1'`, `phase following -> holding`, and for (b) `cow 'Fat Cow uh1 #3-1' lost flight 'uh1', offered for take-over`.

Nothing is left in the mission: the scenarios destroy their groups and forget their cows, and the player-leave handler is removed.
1 change: 1 addition & 0 deletions .backlog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ authored **per lot, when the lot is started** (not in batch).

| Lot | Status | Description | Branch |
|-----|--------|-------------|--------|
| [`FIX-FAT-COW-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | merged (PR #334) (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` |
| [`FIX-VMCT-REVIEW-FINDINGS`](FIX-VMCT-REVIEW-FINDINGS/PRD.md) | merged (PR #330) — 06 ✅ live scenario PASS 10/10 (2026-11-23) — 7 tickets (01 [parachuted troops keep their template](FIX-VMCT-REVIEW-FINDINGS/tickets/01-parachuted-troops-keep-their-template.md), 02 [inactive zones stay inactive](FIX-VMCT-REVIEW-FINDINGS/tickets/02-inactive-zones-stay-inactive.md), 03 [repair crates from the menu](FIX-VMCT-REVIEW-FINDINGS/tickets/03-repair-crates-from-the-menu.md), 04 [unique AA group name](FIX-VMCT-REVIEW-FINDINGS/tickets/04-unique-aa-group-name.md), 05 [player name in coalition messages](FIX-VMCT-REVIEW-FINDINGS/tickets/05-player-name-in-coalition-messages.md), 06 [live check](FIX-VMCT-REVIEW-FINDINGS/tickets/06-live-check.md), 07 [backlog housekeeping](FIX-VMCT-REVIEW-FINDINGS/tickets/07-backlog-housekeeping.md)) | Issues #322-#326 (VMCT review of `develop`, 2026-11-19): parachuted troops all land as "Soldier AK"; inactive troop/waypoint zones load active; the six "… Repair" crates cannot be requested from the menu; two AA systems of the same type spawned in the same second share a group name; FOB and SAM coalition messages name the unit instead of the player. | `fix/FIX-VMCT-REVIEW-FINDINGS` |
| [`FEAT-VMCT-V1-PARITY`](FEAT-VMCT-V1-PARITY/PRD.md) | merged (PR #329) — verified in game (live scenario 15/15, 2026-11-23) — 3 tickets (01 [spawned units player can drive](FEAT-VMCT-V1-PARITY/tickets/01-spawned-units-player-can-drive.md), 02 [link crates and groups in events](FEAT-VMCT-V1-PARITY/tickets/02-link-crates-and-groups-in-events.md), 03 [live check](FEAT-VMCT-V1-PARITY/tickets/03-live-check.md)) | Issues #327, #328 (VMCT): units spawned by a CTLD gesture are drivable again (new setting `spawnedUnitsPlayerCanDrive`, default `true` as in v1); unpack, rearm and repair events carry both the crates and the spawned group. | `feat/FEAT-VMCT-V1-PARITY` |

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Versioning follows [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Fixed — an AI Fat Cow no longer hovers until it runs dry (FIX-FAT-COW-STRANDED)

- Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order, then flew on for 5 h 20 min until it ran out of fuel and vanished, and the log had no line in between. Three changes:
**Bingo fuel**: an AI cow in the air with less than 25 % of its internal fuel (`Unit.getFuel`) goes home whatever it was told (holding, following or released; one that is landing lands), and its flight reads "The Fat Cow is low on fuel and returns home." (new text, four dictionaries). Logged as a `WARN` with the fuel fraction. The pilot guide says so, in English and French.
**Orphan check in the loop**: a cow whose flight is gone was sent home by a single check 2 s after the event, a race against DCS removing the client unit. The 10 s loop now runs the same check, so the cow goes home even when the one-shot ran too early.
**A readable log**: every F10 order given to an AI cow (Land here, Take off, Hold here, Join us, RTB, Release, Take over: cow, order, requesting unit) and every change of its phase writes one `INFO` line, none per loop tick.

---

## [2.1.0] — 2026-11-23
Expand Down
2 changes: 2 additions & 0 deletions docs/pilot/fat-cow.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Vous pouvez donc redécoller pour vous déplacer en stationnaire jusqu'à sa FAR

Une cow qui n'a plus rien n'ouvre pas de FARP : vous le lisez quand le délai s'écoule, avec le conseil de la renvoyer avec **Rentre à la base**.

Une cow en l'air qui a moins d'un quart de son carburant rentre toute seule à la base, quel que soit l'ordre reçu (en attente, en suivi ou libérée), et votre patrouille lit « La Fat Cow n'a presque plus de carburant et rentre à la base. »

**Statut Fat Cow** dit où est la cow de votre patrouille (phase, distance et relèvement), quand elle devrait vous rejoindre, et ce qu'elle contient encore, y compris avant qu'elle se soit posée.

**Demander une Fat Cow** ouvre la liste des lots, les mêmes que ceux d'une cow pilotée (Apache en tête, **Russes** et **Mixtes** un niveau plus bas) : choisissez ce dont votre patrouille a besoin.
Expand Down
2 changes: 2 additions & 0 deletions docs/pilot/fat-cow.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ So you can lift off to hover-taxi onto its FARP, or reposition, without the cow

A cow with nothing left opens no FARP: you are told when the delay runs out, with the advice to send it home with **RTB**.

A cow in the air with less than a quarter of its fuel left goes home by itself, whatever it was told (holding, following or released), and your flight reads "The Fat Cow is low on fuel and returns home."

**Fat Cow status** tells where your flight's cow is (phase, distance and bearing), when it should join, and what it still holds, before it has landed too.

**Request a Fat Cow** opens the list of loadouts, the same as a piloted cow's (Apache at the top, **Russian** and **Mixed** one level down): pick what your flight needs.
Expand Down
Loading