agentleFS
EvilFreelancerEvilFreelancer/zaezd/.cursor/rules/composer-core.mdc

zaezd / rules

Cursor rule1 starsChanged 3 months agoMITView on GitHub

Deterministic trip rules for dates, feasibility, price and packages

The file

We split this composer-core.mdc into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every dropped event is reported with a reason and its link, including the ones that were fine but fell past the cap.

    line 56
  2. Distinctive:

    When the venue was geocoded precisely, rank by straight-line distance to it.

    line 63
  3. Distinctive:

    Every tie is broken down to a stable secondary key and, in the last resort, to the variant identifier, so the same input always yields the …

    line 127
  4. Distinctive:

    If two rules pick the same variant, emit fewer cards rather than duplicates.

    line 136

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
composer-core.mdc
---
description: "Deterministic trip rules for dates, feasibility, price and packages"
globs: src/composer/**/*.ts
alwaysApply: false
---


# Composer core: the deterministic rules

`src/composer/` holds the only part of the product that is allowed to decide numbers.
It is pure: no network, no file system, no `Date.now()`. The current date arrives as an
argument. This is what makes three identical requests produce three identical answers,
which a language model demonstrably does not (three live runs of one request gave 3, 2 and
2 nights and a 1.5x hotel price spread; `specs/10-proverka.md`).

## Stay dates, `dates.ts`

```
check-in day:
  starts_at known and start time <  12:00  -> start_date minus one day
  starts_at known and start time >= 12:00  -> start_date
  starts_at is null                        -> start_date minus one day (cautious)

check-out day:
  end_date plus one day, if the event ends after 18:00 or the end time is unknown
  otherwise end_date

nights = check-out day minus check-in day
```

**confcal has no event end time.** Verified against the live catalogue: an event carries
`start_date`, `end_date` and `starts_at` and nothing else about time. The second branch of
the check-out rule is therefore unreachable on real data and the check-out day is always
`end_date` plus one. The 18:00 branch stays in the function because a source may appear,
and it is covered by a unit test, not by a scenario on fixtures.

Nights are never negative. Zero nights is a legal answer and means a same-day trip to a
neighbouring city: assemble a package without a hotel but with a mandatory return leg the
same day. Never round zero up to one, that buys a night the traveller does not need. The
check-in day is the outbound travel date, the check-out day is the return travel date, and
both go into `search_hotels` verbatim as `check_in` and `check_out`.

## Event selection, `selection.ts`

Applied in order: drop `format: "online"` (they go to a separate "no travel needed" list),
drop offline events with no city at all (there is nowhere to send anyone), drop events in the
origin city, drop events outside the requested dates, drop events that can no longer be
reached, drop records that contradict themselves, sort by date proximity with the catalogue id
as the tie-break, keep at most five candidates, assemble only the first.

"Can no longer be reached" is judged on the arrival day from `dates.ts`, not on `start_date`:
an event opening tomorrow morning wants the traveller in town tonight and a hotel cannot be
booked for yesterday. The reference day arrives as an argument, never from the wall clock,
otherwise the tests rot on their own.

Every dropped event is reported with a reason and its link, including the ones that were fine
but fell past the cap. A silently truncated list reads as "that is all there is", which is a
different and false statement. One self-contradictory record is dropped on its own rather than
taking the whole catalogue down with it.

## Hotel ranking, `hotels.ts`

When the venue was geocoded precisely, rank by straight-line distance to it; the coordinates
of every hotel arrive in the listing. When it was not, rank by price and rating and suppress
the distance block entirely rather than ranking against a city centre and calling it
proximity.

## Coverage, `selection.ts`

The catalogue's own directory, reported without flattery: how many cities it lists, how many of
those have upcoming events, the busiest few, and how many upcoming events have no city at all.
Counts are claimed only for what was actually seen - a single page of a paginated directory
cannot say how many cities have events, and reporting a page figure as a catalogue figure
understates the coverage by whatever the page size happened to be.

## Feasibility, `feasibility.ts`

| Check | Rule | Effect |
|---|---|---|
| Makes the opening | `arrival_at` no later than `starts_at` minus 60 minutes | otherwise flagged, cannot be the primary package |
| Leaves after the end | return departure not before the event ends | otherwise flagged |
| Start time unknown | `starts_at === null` | relax the check and say so on the card |
| A time that will not parse | the string is there but is not a moment | same as absent: the variant cannot be primary |
| A time nobody supplied | no arrival, or no return departure | the variant cannot be primary; not knowing is not the same as arriving in time |

Compare instants, never rounded minutes: 59 minutes and 30 seconds rounds to 60 and sails
through the very check that exists to guarantee the hour. The offset in a timestamp is
mandatory, because `Date.parse` reads a naive one in the machine's own zone and the same trip
would be feasible on a server in Moscow and infeasible on one in Tokyo.

The buffer is reported as a number ("запас 4 ч 15 мин"), never as the word "успевает".

## Price, `pricing.ts`

```
total = outbound leg + return leg + hotel for the whole stay + event price (only if parsed)
```

- The return leg is mandatory. Without it the total is knowably wrong.
- The hotel price is `price_basis: "stay_total"`. **Never multiply it by the night count.**
- The event `price` from confcal is free text. Parse it or show it as text with an explicit
  note that it is excluded from the sum. Never guess a number.
- Render prices exactly as they arrive in the payload, with no rounding.
- Working days burnt: days in `[outbound departure day, return arrival day]` that are
  working days and on which the traveller is away or in transit during the 10:00-19:00
  working window. The range follows the actual legs, not the stay interval. Computed over
  the stay interval the number is identical for every variant, "Без отпуска" collapses into
  a copy of "Дешевле всего", and the card stops meaning anything. Over the legs a night
  train leaving at 23:15 on Friday does not burn Friday and a 14:00 flight does.
- The event price is often a lower bound ("от 7 000 ₽"). Parsed as a lower bound, the total
  is labelled a lower bound too, never presented as an exact sum.
- The marked set of working days arrives as data, one entry per day. Not as a lookup function:
  a callback lets a caller smuggle I/O or L2 state into a function this layer promises is pure,
  and nothing would catch it.

## Packages, `packages.ts`

L3 builds the cartesian product of outbound leg, return leg and hotel and hands it over;
`packages.ts` only chooses among the variants that passed feasibility:

```
"Дешевле всего"  = min(total)
"Без отпуска"    = min(working days burnt), ties broken by min(total)
"Быстрее всего"  = min(outbound duration + return duration)
```

Every tie is broken down to a stable secondary key and, in the last resort, to the variant
identifier, so the same input always yields the same card. A tie left to array order
destroys the determinism the whole layer exists for.

Narrow before choosing: feasible variants first, then the ones inside the budget, then the
three rules over what is left. Applied to the whole set, the cheapest card is routinely a trip
the traveller misses the opening on. If a narrowing step empties the pool, undo it and add a
note - a flagged screen beats an empty one.

If two rules pick the same variant, emit fewer cards rather than duplicates. If nothing fits
the budget, emit exactly one card, the cheapest, with an explicit overflow badge: three trips
the traveller cannot afford in three different ways is not an answer. An empty screen is never
an acceptable output. Two variants sharing an identifier are refused, because cards are looked
up by it.

## The composer never

- builds a trip for an online event;
- multiplies a hotel price by the number of nights;
- treats an empty transport-mode array as proof that the mode does not exist
  (`search_multitransport` allows partial per-mode failures);
- includes an unparsed event price in the sum;
- produces a precise venue marker from a venue it could not geocode;
- calls a link a cart when its `kind` says otherwise.

## Checkout labels, `checkout-labels.ts`

A pure table from the `kind` Tutu returned to the button text. An absent or unknown `kind`
maps to the most cautious label available, never to "Открыть корзину". Everything that talks
to Tutu lives in `build-checkout.ts` at L3.

## Orchestration, `build-trip.ts`

L3 only. Fans out with the budgets from `specs/04-kompozitor.md`: both transport searches in
parallel, hotels next, enrichment in parallel and optional. Caps: three concurrent trip
assemblies per process, one computed event per request, three geocoding calls per request.
Results stream to the client as they become ready; a card must not wait for the last
optional source.

## References

@architecture.mdc
@testing.mdc
@data-sources.mdc

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.