diff --git a/CLAUDE.md b/CLAUDE.md index 50ff7e3..f0d4869 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,6 +43,33 @@ minimum surpyval is in `pyproject.toml` (0.28 as of 0.19). level, and the probabilities a forecast is made of (expected failures and costs over a window from a state, and their distribution). +- **Maintenance and money are layered.** Each question has one home, + and the layers above call the ones below rather than repeat them: + - `repyability.value`: money. Discounting (one convention, continuous + at a rate per unit of the clock the money falls on; a yearly rate + converted in one place), escalation and real rates, + `ValueSchedule`, the cost categories and the cash-flow table. + - `repyability.maintenance`: a unit's plan and the single part's + maths. `UnitPlan` (its life, repairs, tasks, `Prices`, and its own + `salvage`, `escalation` and `retire_at`; a spec dict is its + shorthand), the policies, and `NonRepairable`'s methods. The + age-replacement EAC has one definition (`_options.cycle_eac`), + which a diagram's component takes too. A plan is valued alone + through its one-node diagram (`UnitPlan.diagram()`): there is no + second single-unit route. + - `repyability.schedule`: the calendar. Rules, duty plans and + `CalendarContext`, which gives an analysis its calendar and each + unit its duty plan. The duty plan belongs to the analysis, not to + the plan or the diagram. + - `RepairableRBD`: only what belongs to the system. Its structure, + system downtime and value, crews, spares, the site's shutdowns and + common-cause groups. A node takes a `UnitPlan` (or its spec), and a + life can be any model with a life's functions, a `NonRepairableRBD` + included. + + What is still duplicated is listed in the maintenance README's + "Layers" section, so that it goes rather than spreads. + - **Model behaviour belongs in surpyval too.** When a surpyval model misbehaves (its draws, means, densities or save format), raise an issue in derrynknife/surpyval rather than only working around it here. Keep any diff --git a/repyability/maintenance/README.md b/repyability/maintenance/README.md index 7a60d18..324ca17 100644 --- a/repyability/maintenance/README.md +++ b/repyability/maintenance/README.md @@ -22,6 +22,27 @@ plan (UC-19, UC-21, UC-44, UC-46, UC-57 and the others with a `discount_rate`) and the calendar's in `repyability/schedule/README.md` all go through it. +## Layers + +Which module answers which question (the layering in `CLAUDE.md`, +Architecture): + +| Question | Where | Use cases | +|---|---|---| +| What is an amount at a time worth now; how do prices grow; what is the cash-flow table? | `repyability.value` | UC-19, UC-57 | +| What is one unit's plan (life, repairs, tasks, prices, salvage, growth, retirement)? | `repyability.maintenance.UnitPlan` | UC-63 | +| What is that plan worth alone, its cash flows, spread, plan against actual, long-run cost and best interval? | `UnitPlan`'s methods, each through its one-node diagram | UC-65 | +| A single part's policies (age, block, calendar, opportunities, next replacement, slack, layered visits) | `NonRepairable` and the functions of this package | UC-5 to UC-18, UC-44, UC-45 | +| The discounted cost per year of age replacement | `_options.cycle_eac`, one definition for a part and a diagram's component | UC-44 | +| A unit whose life is a subassembly | a `NonRepairableRBD` as the life | UC-66 | +| What happens on dates: rules, duty plans, each unit's plan on the calendar | `repyability.schedule` (its README) | UC-10, UC-39, UC-64 there | +| What belongs to the system: structure, system downtime and value, crews, spares, site shutdowns, common-cause groups | `RepairableRBD` | UC-21, UC-23, UC-46, UC-59 | + +Not yet single: +- a site's shutdowns are both the diagram's `shutdowns=` dicts and `Opportunities`/`ShutdownPolicy`; +- the calendar's present values (`failures_by_period`) still bracket their discounting where the diagram's are exact; +- a nested `RepairableRBD`'s costs are not counted in its parent. + ## The use cases, by number | # | The question here, in model time | State | @@ -2448,9 +2469,9 @@ shutdowns instead). **What was learned.** The spec's keys already were a unit's plan; what the plan adds is a name for each task and its clock, and one place a unit's maintenance is written down. Salvage, a unit's own escalation and -retirement are still the analyses' arguments (`expected_npv(salvage=, -retire_at=, escalation=)`), not the plan's: they join it when a plan is -valued alone. +retirement were the analyses' arguments (`expected_npv(salvage=, +retire_at=, escalation=)`); they joined the plan when a plan was valued +alone (UC-65). ### UC-65: "What is this pump's plan worth alone over eight years at 7%, and its cash flows by year?" diff --git a/repyability/schedule/README.md b/repyability/schedule/README.md index 156b855..a60ac4c 100644 --- a/repyability/schedule/README.md +++ b/repyability/schedule/README.md @@ -21,6 +21,24 @@ moved out with the calendar side in October 2026, and return here under their own numbers with the answers recorded for them. The use cases in model time (UC-1, UC-5 to UC-27) stay in `repyability/maintenance/README.md`. +## Layers + +This module is the calendar layer (`CLAUDE.md`, Architecture). It turns +dates into model time and back, and it says what each unit's duty is. +It leaves money to `repyability.value`, a unit's plan to +`repyability.maintenance` and the system to `RepairableRBD`: + +| Question | Where | Use cases | +|---|---|---| +| Which dates does a rule give? | `Recurrence` (its `dates`) | UC-2, UC-3, UC-4 | +| How many operating hours by when? | `DutyPlan`, `UsageForecast` | UC-10 | +| The calendar an analysis runs on, and each unit's duty plan | `CalendarContext` (taken by `events_by_period` and by `UnitPlan`'s methods as `calendar=`) | UC-64 | +| A part's failures and costs by month | `failures_by_period` (a `NonRepairable`), or `UnitPlan.failures_by_period` (the diagram's engine) | UC-48 | +| A system's events and costs by month | `events_by_period` (a `RepairableRBD`) | UC-39, UC-64 | + +The duty plan belongs to the analysis: the same diagram or plan runs on +another site's calendar with other plans. + ## Conventions - **Dates are whole local dates** (a `datetime.date`, or ISO text such as