From f95abc77a178a36c82d4955d6fe6356949b68610 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 00:10:58 +0000 Subject: [PATCH] Compliance over time, round three: milestones, active deficiencies by firm and urgency, accountability One card per milestone with its result. Deficiencies grouped by firm (or all together), ranked Overdue / Will miss / On course, with owner, size, age, pace and closing date. One accountability row per firm with the plan's own escalation step. Series format 0.3: optional plan.escalation and rule byRole. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01PYjDnEAE2YjM6FXu9VUKu8 --- compliance/FORMAT.md | 17 +- compliance/build_example.py | 14 +- compliance/example-school.json | 711 ++++++++++++++++++++++++++++----- compliance/index.html | 125 +++++- compliance/series.js | 7 +- compliance/test/test_page.js | 6 +- 6 files changed, 755 insertions(+), 125 deletions(-) diff --git a/compliance/FORMAT.md b/compliance/FORMAT.md index 80f52d7..6f1aef1 100644 --- a/compliance/FORMAT.md +++ b/compliance/FORMAT.md @@ -6,7 +6,7 @@ results are shown over time, and fixes the contract so that **a different plan n The page at `/compliance/` contains no project name, no goal, no firm, no rule and no milestone. It reads all of them from one file. A VIM Flex page, or any other screen, can read the same file and follow the same rules. -- Format name: `openbep-compliance-series`, version `0.2` (draft). 0.2 adds three optional counts per role; a 0.1 file still loads. +- Format name: `openbep-compliance-series`, version `0.3` (draft). 0.2 added three optional counts per role; 0.3 adds the plan's escalation steps and the owner of a failing rule, both optional. Older files still load. - Example: [example-school.json](example-school.json), simulated, written by `build_example.py`. - Validator: [series.js](series.js), `validateSeries(doc)` returns a list of problems in plain words. The page runs it on every file and refuses a file that fails, with the reasons. @@ -40,6 +40,7 @@ plan milestones[] { id, name, date, targetPercent } in date order holidays[] { name, from, to } weeks inside are not counted roles[] { code, role, firm, document, from } from = null, or the date the role joins + escalation[] the plan's steps when a firm misses milestones in a row, in order (optional, 0.3) model { server, project, source, schedule, cadenceDays (7 when absent) } valueChecks[] { id, goal, label } rules[] { id, goal, label, limit, unit, limitText, direction } @@ -51,7 +52,7 @@ versions[] in order byRole { CODE: { elements, required, met, uploaded, elementsAdded, valuesFixed, valuesBroken, wrong, newRequired, newMet } } the last three are optional (0.2) valueChecks { checkId: { CODE: [required, met] } } adds up to byRole - rules { ruleId: { value, pass } } + rules { ruleId: { value, pass, byRole } } byRole = failing elements per role (optional, 0.3) ``` - **required** = the number of values the plan asks for at the milestone in force (elements × the parameters @@ -80,12 +81,22 @@ versions[] in order | Model rules | pass or fail as the checker says; never averaged into a percentage | | Gate | passes when overall compliance ≥ target and every model rule passes | | Gap | per value check and role: target × required − met, largest first | +| Milestone result | judged on the last version checked on or before the milestone date: passed when the gate passes | +| Deficiency | one per value check and role below the target, one per failing model rule | +| Open since | first version of the current unbroken run of that deficiency | +| Closes at this pace | size ÷ pace of the last four working periods, counted forward skipping holidays | +| Urgency | Overdue: open through a milestone it should have met. Will miss: closes after the milestone, or never. On course: closes in time. | +| Step set by the plan | milestones a firm missed in a row on its own elements, read against `plan.escalation` | | New elements arrive filled | newMet ÷ newRequired over the last four working periods | ## What every screen shows the same way 1. The gate: would this version pass the milestone, and which conditions fail. Then the summary: overall - compliance, model rules met, forecast, versions checked. Then the largest gaps, by check and by firm. + compliance, model rules met, forecast, versions checked. + Then one card per milestone: date, target, result, failing rules, firms below the target. + Then the active deficiencies, grouped by firm or all together, most urgent first, each with its owner, + size, age, pace and closing date. Then one accountability row per firm: milestones met and missed, + missed in a row, the plan's step, what is open now. 2. Overall compliance over time, with the stepped target, milestones, holidays and unchecked versions; the same chart in values shows what the plan requires against what is filled. 3. One row per role: compliance, wrong and empty, pace, how clean new elements arrive, needed pace, uploads. diff --git a/compliance/build_example.py b/compliance/build_example.py index ba20b4a..85d0593 100644 --- a/compliance/build_example.py +++ b/compliance/build_example.py @@ -102,6 +102,11 @@ def lerp(points, x): # Of the values required on elements added this week, the share that arrives filled. A firm that models # clean keeps this high; a firm that models first and fills later does not. CLEAN = {'ARCH': .82, 'STRUCT': .93, 'MECH': .44, 'CON': .66} +# Whose elements fail each count rule (share of the failing elements). A rule with no entry belongs to the whole model. +RULE_OWNERS = {'clashes': {'MECH': .6, 'STRUCT': .25, 'ARCH': .15}, 'warnings': {'ARCH': .55, 'MECH': .35, 'STRUCT': .1}, + 'dup-mark': {'ARCH': .7, 'MECH': .3}, 'worksets-exist': {'MECH': 1}, 'dup-levels': {'STRUCT': 1}} +# What the plan says happens when a firm misses milestones in a row (same steps as the Scorecard's example). +ESCALATION = ['Recovery plan within 10 working days', 'Formal notice under the contract', 'Milestone not accepted and its payment held until the gap is closed'] # Weeks a role uploaded nothing new. The federated version keeps that role's previous model. NO_UPLOAD = { 'ARCH': {'2027-04-16', '2027-04-30', '2027-05-07'}, @@ -188,13 +193,18 @@ def rule_values(day, i): for ru in RULES: val = rv[ru['id']] v['rules'][ru['id']] = {'value': val, 'pass': val >= ru['limit'] if ru['direction'] == 'higherIsBetter' else val <= ru['limit']} + sh = {c: w for c, w in RULE_OWNERS.get(ru['id'], {}).items() if state.get(c)} + if sh and val: # whose elements fail the rule + tot_w = sum(sh.values()); parts = {c: int(val * w / tot_w) for c, w in sh.items()} + parts[max(sh, key=sh.get)] += val - sum(parts.values()) + v['rules'][ru['id']]['byRole'] = {c: n for c, n in parts.items() if n} versions.append(v) doc = { - 'format': 'openbep-compliance-series', 'formatVersion': '0.2', 'example': True, + 'format': 'openbep-compliance-series', 'formatVersion': '0.3', 'example': True, 'note': 'SIMULATED. Invented numbers for a made-up school project. No real model, firm or VIM Server was measured. Written by compliance/build_example.py.', 'plan': {'name': 'Example: Primary school renovation and extension', 'owner': 'School service centre (example)', 'delivery': 'Design-bid-build', - 'goals': GOALS, 'milestones': MILESTONES, 'holidays': HOLIDAYS, 'roles': ROLES}, + 'goals': GOALS, 'milestones': MILESTONES, 'holidays': HOLIDAYS, 'roles': ROLES, 'escalation': ESCALATION}, 'model': {'server': 'VIM Server (simulated)', 'project': 'Primary school (example)', 'source': 'SCH-FEDERATED.vim', 'schedule': 'One version every Friday, built from the Revit models each firm uploaded that week.'}, 'valueChecks': [{k: v for k, v in vc.items() if k in ('id', 'goal', 'label')} for vc in VALUE_CHECKS], diff --git a/compliance/example-school.json b/compliance/example-school.json index ee32798..ffce241 100644 --- a/compliance/example-school.json +++ b/compliance/example-school.json @@ -1,6 +1,6 @@ { "format": "openbep-compliance-series", - "formatVersion": "0.2", + "formatVersion": "0.3", "example": true, "note": "SIMULATED. Invented numbers for a made-up school project. No real model, firm or VIM Server was measured. Written by compliance/build_example.py.", "plan": { @@ -102,6 +102,11 @@ "document": "SCH-CON.rvt", "from": "2027-09-24" } + ], + "escalation": [ + "Recovery plan within 10 working days", + "Formal notice under the contract", + "Milestone not accepted and its payment held until the gap is closed" ] }, "model": { @@ -365,15 +370,26 @@ }, "warnings": { "value": 614, - "pass": true + "pass": true, + "byRole": { + "ARCH": 339, + "MECH": 214, + "STRUCT": 61 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 2, - "pass": false + "pass": false, + "byRole": { + "MECH": 2 + } }, "dup-levels": { "value": 0, @@ -536,15 +552,26 @@ }, "warnings": { "value": 654, - "pass": true + "pass": true, + "byRole": { + "ARCH": 361, + "MECH": 228, + "STRUCT": 65 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 2, - "pass": false + "pass": false, + "byRole": { + "MECH": 2 + } }, "dup-levels": { "value": 0, @@ -708,15 +735,26 @@ }, "warnings": { "value": 677, - "pass": true + "pass": true, + "byRole": { + "ARCH": 374, + "MECH": 236, + "STRUCT": 67 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 2, - "pass": false + "pass": false, + "byRole": { + "MECH": 2 + } }, "dup-levels": { "value": 0, @@ -879,15 +917,26 @@ }, "warnings": { "value": 704, - "pass": true + "pass": true, + "byRole": { + "ARCH": 388, + "MECH": 246, + "STRUCT": 70 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 2, - "pass": false + "pass": false, + "byRole": { + "MECH": 2 + } }, "dup-levels": { "value": 0, @@ -1050,11 +1099,19 @@ }, "warnings": { "value": 733, - "pass": true + "pass": true, + "byRole": { + "ARCH": 404, + "MECH": 256, + "STRUCT": 73 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 0, @@ -1221,11 +1278,19 @@ }, "warnings": { "value": 774, - "pass": true + "pass": true, + "byRole": { + "ARCH": 427, + "MECH": 270, + "STRUCT": 77 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 0, @@ -1393,11 +1458,19 @@ }, "warnings": { "value": 819, - "pass": true + "pass": true, + "byRole": { + "ARCH": 452, + "MECH": 286, + "STRUCT": 81 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 0, @@ -1564,11 +1637,19 @@ }, "warnings": { "value": 834, - "pass": true + "pass": true, + "byRole": { + "ARCH": 460, + "MECH": 291, + "STRUCT": 83 + } }, "dup-mark": { "value": 3, - "pass": false + "pass": false, + "byRole": { + "ARCH": 3 + } }, "worksets-exist": { "value": 0, @@ -1736,7 +1817,12 @@ }, "warnings": { "value": 879, - "pass": true + "pass": true, + "byRole": { + "ARCH": 485, + "MECH": 307, + "STRUCT": 87 + } }, "dup-mark": { "value": 0, @@ -1903,11 +1989,21 @@ }, "clashes": { "value": 21, - "pass": true + "pass": true, + "byRole": { + "MECH": 13, + "STRUCT": 5, + "ARCH": 3 + } }, "warnings": { "value": 914, - "pass": true + "pass": true, + "byRole": { + "ARCH": 504, + "MECH": 319, + "STRUCT": 91 + } }, "dup-mark": { "value": 0, @@ -2075,11 +2171,21 @@ }, "clashes": { "value": 42, - "pass": false + "pass": false, + "byRole": { + "MECH": 26, + "STRUCT": 10, + "ARCH": 6 + } }, "warnings": { "value": 936, - "pass": true + "pass": true, + "byRole": { + "ARCH": 516, + "MECH": 327, + "STRUCT": 93 + } }, "dup-mark": { "value": 0, @@ -2247,11 +2353,21 @@ }, "clashes": { "value": 67, - "pass": false + "pass": false, + "byRole": { + "MECH": 41, + "STRUCT": 16, + "ARCH": 10 + } }, "warnings": { "value": 979, - "pass": true + "pass": true, + "byRole": { + "ARCH": 540, + "MECH": 342, + "STRUCT": 97 + } }, "dup-mark": { "value": 0, @@ -2419,11 +2535,21 @@ }, "clashes": { "value": 73, - "pass": false + "pass": false, + "byRole": { + "MECH": 45, + "STRUCT": 18, + "ARCH": 10 + } }, "warnings": { "value": 1014, - "pass": true + "pass": true, + "byRole": { + "ARCH": 559, + "MECH": 354, + "STRUCT": 101 + } }, "dup-mark": { "value": 0, @@ -2590,11 +2716,21 @@ }, "clashes": { "value": 84, - "pass": false + "pass": false, + "byRole": { + "MECH": 51, + "STRUCT": 21, + "ARCH": 12 + } }, "warnings": { "value": 1068, - "pass": true + "pass": true, + "byRole": { + "ARCH": 589, + "MECH": 373, + "STRUCT": 106 + } }, "dup-mark": { "value": 0, @@ -2761,11 +2897,21 @@ }, "clashes": { "value": 92, - "pass": false + "pass": false, + "byRole": { + "MECH": 56, + "STRUCT": 23, + "ARCH": 13 + } }, "warnings": { "value": 1107, - "pass": true + "pass": true, + "byRole": { + "ARCH": 610, + "MECH": 387, + "STRUCT": 110 + } }, "dup-mark": { "value": 0, @@ -2777,7 +2923,10 @@ }, "dup-levels": { "value": 1, - "pass": false + "pass": false, + "byRole": { + "STRUCT": 1 + } } } }, @@ -2932,11 +3081,21 @@ }, "clashes": { "value": 100, - "pass": false + "pass": false, + "byRole": { + "MECH": 60, + "STRUCT": 25, + "ARCH": 15 + } }, "warnings": { "value": 1166, - "pass": true + "pass": true, + "byRole": { + "ARCH": 642, + "MECH": 408, + "STRUCT": 116 + } }, "dup-mark": { "value": 0, @@ -2948,7 +3107,10 @@ }, "dup-levels": { "value": 1, - "pass": false + "pass": false, + "byRole": { + "STRUCT": 1 + } } } }, @@ -3103,11 +3265,21 @@ }, "clashes": { "value": 109, - "pass": false + "pass": false, + "byRole": { + "MECH": 66, + "STRUCT": 27, + "ARCH": 16 + } }, "warnings": { "value": 1191, - "pass": true + "pass": true, + "byRole": { + "ARCH": 656, + "MECH": 416, + "STRUCT": 119 + } }, "dup-mark": { "value": 0, @@ -3274,11 +3446,21 @@ }, "clashes": { "value": 116, - "pass": false + "pass": false, + "byRole": { + "MECH": 70, + "STRUCT": 29, + "ARCH": 17 + } }, "warnings": { "value": 1245, - "pass": true + "pass": true, + "byRole": { + "ARCH": 686, + "MECH": 435, + "STRUCT": 124 + } }, "dup-mark": { "value": 0, @@ -3460,11 +3642,21 @@ }, "clashes": { "value": 99, - "pass": false + "pass": false, + "byRole": { + "MECH": 61, + "STRUCT": 24, + "ARCH": 14 + } }, "warnings": { "value": 1323, - "pass": true + "pass": true, + "byRole": { + "ARCH": 728, + "MECH": 463, + "STRUCT": 132 + } }, "dup-mark": { "value": 0, @@ -3632,11 +3824,21 @@ }, "clashes": { "value": 88, - "pass": false + "pass": false, + "byRole": { + "MECH": 53, + "STRUCT": 22, + "ARCH": 13 + } }, "warnings": { "value": 1387, - "pass": true + "pass": true, + "byRole": { + "ARCH": 764, + "MECH": 485, + "STRUCT": 138 + } }, "dup-mark": { "value": 0, @@ -3804,15 +4006,29 @@ }, "clashes": { "value": 75, - "pass": false + "pass": false, + "byRole": { + "MECH": 46, + "STRUCT": 18, + "ARCH": 11 + } }, "warnings": { "value": 1423, - "pass": true + "pass": true, + "byRole": { + "ARCH": 783, + "MECH": 498, + "STRUCT": 142 + } }, "dup-mark": { "value": 22, - "pass": false + "pass": false, + "byRole": { + "ARCH": 16, + "MECH": 6 + } }, "worksets-exist": { "value": 0, @@ -3976,15 +4192,29 @@ }, "clashes": { "value": 65, - "pass": false + "pass": false, + "byRole": { + "MECH": 40, + "STRUCT": 16, + "ARCH": 9 + } }, "warnings": { "value": 1581, - "pass": false + "pass": false, + "byRole": { + "ARCH": 870, + "MECH": 553, + "STRUCT": 158 + } }, "dup-mark": { "value": 25, - "pass": false + "pass": false, + "byRole": { + "ARCH": 18, + "MECH": 7 + } }, "worksets-exist": { "value": 0, @@ -4148,15 +4378,29 @@ }, "clashes": { "value": 50, - "pass": false + "pass": false, + "byRole": { + "MECH": 31, + "STRUCT": 12, + "ARCH": 7 + } }, "warnings": { "value": 1739, - "pass": false + "pass": false, + "byRole": { + "ARCH": 958, + "MECH": 608, + "STRUCT": 173 + } }, "dup-mark": { "value": 28, - "pass": false + "pass": false, + "byRole": { + "ARCH": 20, + "MECH": 8 + } }, "worksets-exist": { "value": 0, @@ -4320,15 +4564,29 @@ }, "clashes": { "value": 38, - "pass": false + "pass": false, + "byRole": { + "MECH": 24, + "STRUCT": 9, + "ARCH": 5 + } }, "warnings": { "value": 1883, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1036, + "MECH": 659, + "STRUCT": 188 + } }, "dup-mark": { "value": 31, - "pass": false + "pass": false, + "byRole": { + "ARCH": 22, + "MECH": 9 + } }, "worksets-exist": { "value": 0, @@ -4492,15 +4750,29 @@ }, "clashes": { "value": 44, - "pass": false + "pass": false, + "byRole": { + "MECH": 27, + "STRUCT": 11, + "ARCH": 6 + } }, "warnings": { "value": 1881, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1035, + "MECH": 658, + "STRUCT": 188 + } }, "dup-mark": { "value": 23, - "pass": false + "pass": false, + "byRole": { + "ARCH": 17, + "MECH": 6 + } }, "worksets-exist": { "value": 0, @@ -4663,15 +4935,29 @@ }, "clashes": { "value": 45, - "pass": false + "pass": false, + "byRole": { + "MECH": 28, + "STRUCT": 11, + "ARCH": 6 + } }, "warnings": { "value": 1860, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1023, + "MECH": 651, + "STRUCT": 186 + } }, "dup-mark": { "value": 14, - "pass": false + "pass": false, + "byRole": { + "ARCH": 10, + "MECH": 4 + } }, "worksets-exist": { "value": 0, @@ -4835,15 +5121,29 @@ }, "clashes": { "value": 52, - "pass": false + "pass": false, + "byRole": { + "MECH": 32, + "STRUCT": 13, + "ARCH": 7 + } }, "warnings": { "value": 1823, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1003, + "MECH": 638, + "STRUCT": 182 + } }, "dup-mark": { "value": 6, - "pass": false + "pass": false, + "byRole": { + "ARCH": 5, + "MECH": 1 + } }, "worksets-exist": { "value": 0, @@ -5006,11 +5306,21 @@ }, "clashes": { "value": 60, - "pass": false + "pass": false, + "byRole": { + "MECH": 36, + "STRUCT": 15, + "ARCH": 9 + } }, "warnings": { "value": 1789, - "pass": false + "pass": false, + "byRole": { + "ARCH": 985, + "MECH": 626, + "STRUCT": 178 + } }, "dup-mark": { "value": 0, @@ -5177,11 +5487,21 @@ }, "clashes": { "value": 50, - "pass": false + "pass": false, + "byRole": { + "MECH": 31, + "STRUCT": 12, + "ARCH": 7 + } }, "warnings": { "value": 1768, - "pass": false + "pass": false, + "byRole": { + "ARCH": 974, + "MECH": 618, + "STRUCT": 176 + } }, "dup-mark": { "value": 0, @@ -5349,11 +5669,21 @@ }, "clashes": { "value": 39, - "pass": false + "pass": false, + "byRole": { + "MECH": 25, + "STRUCT": 9, + "ARCH": 5 + } }, "warnings": { "value": 1657, - "pass": false + "pass": false, + "byRole": { + "ARCH": 913, + "MECH": 579, + "STRUCT": 165 + } }, "dup-mark": { "value": 0, @@ -5520,11 +5850,21 @@ }, "clashes": { "value": 29, - "pass": false + "pass": false, + "byRole": { + "MECH": 18, + "STRUCT": 7, + "ARCH": 4 + } }, "warnings": { "value": 1533, - "pass": false + "pass": false, + "byRole": { + "ARCH": 844, + "MECH": 536, + "STRUCT": 153 + } }, "dup-mark": { "value": 0, @@ -5692,11 +6032,21 @@ }, "clashes": { "value": 18, - "pass": true + "pass": true, + "byRole": { + "MECH": 12, + "STRUCT": 4, + "ARCH": 2 + } }, "warnings": { "value": 1425, - "pass": true + "pass": true, + "byRole": { + "ARCH": 785, + "MECH": 498, + "STRUCT": 142 + } }, "dup-mark": { "value": 0, @@ -5864,11 +6214,21 @@ }, "clashes": { "value": 13, - "pass": true + "pass": true, + "byRole": { + "MECH": 9, + "STRUCT": 3, + "ARCH": 1 + } }, "warnings": { "value": 1311, - "pass": true + "pass": true, + "byRole": { + "ARCH": 722, + "MECH": 458, + "STRUCT": 131 + } }, "dup-mark": { "value": 0, @@ -6036,11 +6396,21 @@ }, "clashes": { "value": 20, - "pass": true + "pass": true, + "byRole": { + "MECH": 12, + "STRUCT": 5, + "ARCH": 3 + } }, "warnings": { "value": 1306, - "pass": true + "pass": true, + "byRole": { + "ARCH": 719, + "MECH": 457, + "STRUCT": 130 + } }, "dup-mark": { "value": 0, @@ -6241,11 +6611,21 @@ }, "clashes": { "value": 27, - "pass": false + "pass": false, + "byRole": { + "MECH": 17, + "STRUCT": 6, + "ARCH": 4 + } }, "warnings": { "value": 1286, - "pass": true + "pass": true, + "byRole": { + "ARCH": 708, + "MECH": 450, + "STRUCT": 128 + } }, "dup-mark": { "value": 0, @@ -6445,11 +6825,21 @@ }, "clashes": { "value": 31, - "pass": false + "pass": false, + "byRole": { + "MECH": 20, + "STRUCT": 7, + "ARCH": 4 + } }, "warnings": { "value": 1270, - "pass": true + "pass": true, + "byRole": { + "ARCH": 699, + "MECH": 444, + "STRUCT": 127 + } }, "dup-mark": { "value": 0, @@ -6649,15 +7039,29 @@ }, "clashes": { "value": 36, - "pass": false + "pass": false, + "byRole": { + "MECH": 22, + "STRUCT": 9, + "ARCH": 5 + } }, "warnings": { "value": 1256, - "pass": true + "pass": true, + "byRole": { + "ARCH": 692, + "MECH": 439, + "STRUCT": 125 + } }, "dup-mark": { "value": 14, - "pass": false + "pass": false, + "byRole": { + "ARCH": 10, + "MECH": 4 + } }, "worksets-exist": { "value": 0, @@ -6853,15 +7257,29 @@ }, "clashes": { "value": 35, - "pass": false + "pass": false, + "byRole": { + "MECH": 22, + "STRUCT": 8, + "ARCH": 5 + } }, "warnings": { "value": 1242, - "pass": true + "pass": true, + "byRole": { + "ARCH": 684, + "MECH": 434, + "STRUCT": 124 + } }, "dup-mark": { "value": 11, - "pass": false + "pass": false, + "byRole": { + "ARCH": 8, + "MECH": 3 + } }, "worksets-exist": { "value": 0, @@ -7058,15 +7476,29 @@ }, "clashes": { "value": 27, - "pass": false + "pass": false, + "byRole": { + "MECH": 17, + "STRUCT": 6, + "ARCH": 4 + } }, "warnings": { "value": 1232, - "pass": true + "pass": true, + "byRole": { + "ARCH": 678, + "MECH": 431, + "STRUCT": 123 + } }, "dup-mark": { "value": 8, - "pass": false + "pass": false, + "byRole": { + "ARCH": 6, + "MECH": 2 + } }, "worksets-exist": { "value": 0, @@ -7262,15 +7694,29 @@ }, "clashes": { "value": 24, - "pass": true + "pass": true, + "byRole": { + "MECH": 15, + "STRUCT": 6, + "ARCH": 3 + } }, "warnings": { "value": 1235, - "pass": true + "pass": true, + "byRole": { + "ARCH": 680, + "MECH": 432, + "STRUCT": 123 + } }, "dup-mark": { "value": 5, - "pass": false + "pass": false, + "byRole": { + "ARCH": 4, + "MECH": 1 + } }, "worksets-exist": { "value": 0, @@ -7467,15 +7913,28 @@ }, "clashes": { "value": 21, - "pass": true + "pass": true, + "byRole": { + "MECH": 13, + "STRUCT": 5, + "ARCH": 3 + } }, "warnings": { "value": 1227, - "pass": true + "pass": true, + "byRole": { + "ARCH": 676, + "MECH": 429, + "STRUCT": 122 + } }, "dup-mark": { "value": 2, - "pass": false + "pass": false, + "byRole": { + "ARCH": 2 + } }, "worksets-exist": { "value": 0, @@ -7671,15 +8130,28 @@ }, "clashes": { "value": 14, - "pass": true + "pass": true, + "byRole": { + "MECH": 9, + "STRUCT": 3, + "ARCH": 2 + } }, "warnings": { "value": 1201, - "pass": true + "pass": true, + "byRole": { + "ARCH": 661, + "MECH": 420, + "STRUCT": 120 + } }, "dup-mark": { "value": 1, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1 + } }, "worksets-exist": { "value": 0, @@ -7876,15 +8348,28 @@ }, "clashes": { "value": 13, - "pass": true + "pass": true, + "byRole": { + "MECH": 9, + "STRUCT": 3, + "ARCH": 1 + } }, "warnings": { "value": 1197, - "pass": true + "pass": true, + "byRole": { + "ARCH": 660, + "MECH": 418, + "STRUCT": 119 + } }, "dup-mark": { "value": 1, - "pass": false + "pass": false, + "byRole": { + "ARCH": 1 + } }, "worksets-exist": { "value": 0, @@ -8081,11 +8566,21 @@ }, "clashes": { "value": 9, - "pass": true + "pass": true, + "byRole": { + "MECH": 6, + "STRUCT": 2, + "ARCH": 1 + } }, "warnings": { "value": 1187, - "pass": true + "pass": true, + "byRole": { + "ARCH": 654, + "MECH": 415, + "STRUCT": 118 + } }, "dup-mark": { "value": 0, diff --git a/compliance/index.html b/compliance/index.html index 2e306d8..139af67 100644 --- a/compliance/index.html +++ b/compliance/index.html @@ -164,6 +164,18 @@ .chg ul{margin:6px 0 0;padding-left:18px} .chg li{margin:3px 0} .mslist{margin:8px 0 0;padding-left:22px;font-size:12px;color:var(--muted);display:flex;flex-wrap:wrap;gap:2px 22px}.mslist b{color:var(--ink);font-weight:500} +.msgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:12px} +.msc{background:var(--surface);border:1px solid var(--line);border-top:4px solid var(--line2);border-radius:var(--r-md);padding:12px 14px;display:flex;flex-direction:column;gap:6px;min-width:0} +.msc.pass{border-top-color:var(--good)}.msc.miss{border-top-color:var(--bad)}.msc.now{border-top-color:var(--accent)} +.msc .mn{display:flex;gap:8px;align-items:baseline}.msc .mn i{font-style:normal;font-family:var(--mono);font-size:12px;border:1px solid var(--line2);border-radius:50%;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;flex:none} +.msc .md{font-size:12px;color:var(--muted)} +.msc .mv{font-size:22px;font-weight:700}.msc .mv small{font-size:13px;font-weight:400;color:var(--muted)} +.msc ul{list-style:none;margin:0;padding:0;font-size:12px;display:flex;flex-direction:column;gap:3px} +.msc .who{display:flex;flex-wrap:wrap;gap:4px;align-items:center;font-size:12px} +.msc .btn{align-self:flex-start;margin-top:auto} +.fblock{margin-bottom:14px;min-width:0}.fh{display:flex;flex-wrap:wrap;gap:6px 16px;align-items:center;justify-content:space-between;padding:8px 2px}.fh .md{color:var(--muted);font-size:12px}.fs{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;font-size:13px} +.rules{margin:8px 0 0;padding-left:18px;font-size:13px;color:var(--muted);max-width:100ch}.rules li{margin:2px 0}.rules b{color:var(--ink)} +td small.sm{display:block;color:var(--muted);font-size:12px} .seg{display:inline-flex}.seg .btn{border-radius:0;margin-left:-1px}.seg .btn:first-child{border-radius:var(--r-sm) 0 0 var(--r-sm);margin-left:0}.seg .btn:last-child{border-radius:0 var(--r-sm) var(--r-sm) 0} .gate{margin-top:14px;padding:12px 16px;border:1px solid var(--line);border-left:5px solid var(--faint);border-radius:var(--r-md);background:var(--surface);display:grid;grid-template-columns:minmax(0,1fr);gap:6px} .gate.pass{border-left-color:var(--good)}.gate.fail{border-left-color:var(--bad)} @@ -239,9 +251,21 @@
+
+

Major milestones

What the model had to reach at each milestone, and what it reached. Seen from the version selected above.
+
+
+
-

Where the gap is

The largest shortfalls against the milestone target, by check and by firm. Closing these moves the overall number most.
-
+

Active deficiencies

+
+
+
    +
    + +
    +

    Accountability

    Each firm's record against the milestones, what it has open now, and the step the plan sets.
    +
    @@ -292,6 +316,9 @@

    How the numbers are worked out

  • The gate at the top is one answer: would this version pass the milestone? It lists the plan's own conditions, the target and each model rule, and which ones fail.
  • Wrong or empty: a required value that does not meet the plan is either empty or holds something that is not a real value (a placeholder such as "TBD", or a value outside the allowed list). The two need different fixes, so they are counted apart.
  • New elements arrive filled: of the values required on elements a firm added in its last four working weeks, the share that was already filled. A firm that fills as it models stays high; a firm that models first and fills later does not, and its backlog grows.
  • +
  • Milestones: a milestone is judged on the last version checked on or before its date. It passes when overall compliance reaches its target and every model rule passes.
  • +
  • Deficiencies: one line for each value check of a firm that is below the target, and one for each failing model rule. "Open since" is the first version of the current unbroken run. "Closes at this pace" projects the last four working weeks forward, skipping holidays.
  • +
  • Step set by the plan: counted in milestones a firm missed in a row on its own elements. The steps are the plan's own wording; this page adds none. With no steps in the plan, the column is left out.
  • Holidays: weeks inside the agreed holidays in the plan have no version and are left out of every count, as on the Scorecard. They never count as a slow week.
  • A gap is never a zero: a version that could not be checked keeps its place with the reason, and the line breaks there.
  • Where the data would come from: one version per week on VIM Server, each built from the Revit models the firms uploaded, checked against the requirement file the BEP Builder exports. The example file is example-school.json, written by compliance/build_example.py.
  • @@ -376,6 +403,8 @@

    How the numbers are worked out

    const setMode=m=>{mode=m;$('#modeP').setAttribute('aria-pressed',m==='p');$('#modeV').setAttribute('aria-pressed',m==='v');drawOverall()}; $('#modeP').onclick=()=>setMode('p');$('#modeV').onclick=()=>setMode('v');setMode('p'); $('#printBtn').onclick=()=>print(); + const setGroup=g=>{group=g;$('#grpF').setAttribute('aria-pressed',g==='f');$('#grpU').setAttribute('aria-pressed',g==='u');if(D&&V) gaps()}; + $('#grpF').onclick=()=>setGroup('f');$('#grpU').onclick=()=>setGroup('u'); showFirms=false;$('#firmsBtn').setAttribute('aria-pressed','false');$('#firmsBtn').textContent='Show each firm'; $('#cmpV').onchange=e=>{cmp=+e.target.value;render()}; $('#firmsBtn').onclick=e=>{showFirms=!showFirms;e.currentTarget.setAttribute('aria-pressed',showFirms);e.currentTarget.textContent=showFirms?'Hide each firm':'Show each firm';drawOverall()}; @@ -390,7 +419,7 @@

    How the numbers are worked out

    function urlState(){const u=new URLSearchParams(location.search);u.set('v',V[sel].order);if(cmp>=0&&cmp!==prevChecked(sel)) u.set('cmp',V[cmp].order);else u.delete('cmp');if(F) u.set('firm',F);else u.delete('firm');history.replaceState(null,'','?'+u); $('#printHead').textContent=`${D.plan.name} · ${V[sel].label}, ${dLong(dayOf(V[sel]))}${F?' · '+F+' only':''}${D.example?' · EXAMPLE DATA, SIMULATED':''}`} -function render(){urlState();gate();gaps();tiles();drawOverall();overallTable();pace();strip();goals();changed();matrix()} +function render(){urlState();gate();milestones();gaps();tiles();drawOverall();overallTable();pace();strip();goals();changed();matrix()} /* ---------- gate and gaps ---------- */ function gate(){ @@ -402,12 +431,92 @@

    How the numbers are worked out

    const head=bad?`${due?'Does not pass':'Would not pass today'}: ${bad} of ${conds.length} conditions fail`:`${due?'Passes':'Would pass today'}: all ${conds.length} conditions met`; el.innerHTML=`
    ${bad?'✕':'✓'} ${esc(m.name)}: ${head}
    Due ${dLong(m.date)}${due?'':`, ${left} working week${left===1?'':'s'} from this version`}. The gate is the plan's own target and model rules, nothing added by this page.${F?' Model rules apply to the whole model, not to one firm.':''}
      ${conds.map(c=>`
    • ${c.ok?'✓':'✕'}${c.t}: ${c.val}
    • `).join('')}
    `; } +/* ---------- milestones, deficiencies, accountability ---------- */ +// The version that stands for a milestone: the last checked one while it was in force, on or before its date. +function msVer(m){let k=-1;V.forEach((v,i)=>{if(checked(v)&&v.milestone===m.id&&dayOf(v)<=m.date) k=i});return k} +const now=()=>dayOf(V[sel]); +const msPassed=m=>m.date<=now()&&msVer(m)>=0&&msVer(m)<=sel; // deadline reached, as seen from the selected version +const vcPair=(v,id,c)=>checked(v)&&v.valueChecks[id]&&v.valueChecks[id][c]||null; +const ruleMine=(x,c)=>!c||!x.byRole||x.byRole[c]>0; +function addWeeks(iso,n){let d=iso,k=0;while(k{ + const k=msVer(m),passed=msPassed(m),isCur=m.id===cur.id,u=passed?V[k]:isCur?V[sel]:null; + let cls='',st,body=''; + if(u){const o=overall(u),rules=D.rules.map(r=>({r,x:u.rules[r.id]})),failR=rules.filter(q=>!q.x.pass),short=CODES.filter(c=>u.byRole[c]&&roleP(u,c)=m.targetPercent&&!failR.length; + if(passed){cls=ok?'pass':'miss';st=ok?'✓ Passed':'✕ Missed'} + else{cls='now';const left=workingWeeks(now(),m.date);st=`${ok?'✓ Would pass today':'! Would not pass today'} due in ${left} working week${left===1?'':'s'}`} + body=`
    ${pct(o)} against ${m.targetPercent} %${passed?', at '+esc(u.label):''}
    +
      ${D.rules.length?`
    • Model rules met: ${rules.length-failR.length} of ${rules.length}
    • `:''}${failR.map(q=>`
    • ✕ ${esc(q.r.label)}: ${rv(q.r,q.x.value)} ${esc(q.r.limitText)}
    • `).join('')}
    + ${short.length?`
    Below the target: ${short.map(c=>`${esc(c)} ${pct(roleP(u,c),0)}`).join('')}
    `:o!=null?'
    Every firm at or above the target.
    ':''} + ${passed&&k!==sel?``:''}`; + }else{st='Not started';body=`
    Target ${m.targetPercent} %. The plan asks for more values per element from the day after the milestone before it.
    `} + return `
    ${i+1}

    ${esc(m.name)}

    ${dLong(m.date)}
    ${st}
    ${body}
    `}).join(''); + $('#msCards').querySelectorAll('[data-i]').forEach(b=>b.onclick=()=>select(+b.dataset.i)); +} +// Every open deficiency at the selected version: a value check of one firm below the target, or a failing model rule. +function deficiencies(){ + const v=V[sel],m=msOf(v),left=workingWeeks(now(),m.date),j=back(sel,4),wk=j>=0?Math.max(1,workingWeeks(dayOf(V[j]),now())):0,past=MS.filter(msPassed).filter(x=>msVer(x){ // failAt(i): is it open at version i + let s0=sel;for(let i=sel-1;i>=0;i--){if(!checked(V[i])) continue;if(failAt(i)) s0=i;else break} + d.since=s0;d.weeks=workingWeeks(dayOf(V[s0]),now()); + d.missed=past.filter(x=>msVer(x)>=s0&&msVer(x)<=sel&&failAt(msVer(x))&&(x.id!==m.id||left===0)); + d.urg=d.missed.length?0:(d.closeW==null||d.closeW>left)?1:2; + d.closes=d.closeW==null?null:addWeeks(now(),Math.ceil(d.closeW));out.push(d)}; + for(const vc of D.valueChecks) for(const c of CODES){if(F&&c!==F) continue;const p=vcPair(v,vc.id,c);if(!p) continue; + const shortBy=Math.ceil(m.targetPercent/100*p[0]-p[1]);if(shortBy<=0) continue; + const pb=j>=0?vcPair(V[j],vc.id,c):null,pace=pb?(p[1]-pb[1])/wk:null; + finish({kind:'v',label:vc.label,goal:vc.goal,owners:[c],size:`${fmt(shortBy)} values short`,sub:`${pct(100*p[1]/p[0])} filled, target ${m.targetPercent} %`,n:shortBy,pace,need:left>0?shortBy/left:null,closeW:pace>0?shortBy/pace:null}, + i=>{const q=vcPair(V[i],vc.id,c);return !!q&&q[1]=0?V[j].rules[r.id]:null,toward=r.direction==='lowerIsBetter'?-1:1,dist=Math.abs(x.value-r.limit),pace=xb?toward*(x.value-xb.value)/wk:null; + finish({kind:'r',label:r.label,goal:r.goal,owners:x.byRole?Object.keys(x.byRole).filter(c=>x.byRole[c]>0):[],by:x.byRole,size:rv(r,x.value),sub:esc(r.limitText),n:Infinity,pace,need:left>0?dist/left:null,closeW:pace>0?dist/pace:null,unit:r.unit==='%'?'pt':''}, + i=>!V[i].rules[r.id].pass)} + return out.sort((a,b)=>a.urg-b.urg||b.n-a.n||b.weeks-a.weeks); +} +let group='f'; +const URG=[['bad','✕ Overdue'],['warn','! Will miss the milestone'],['good','✓ On course']]; function gaps(){ - const v=V[sel],m=msOf(v),rows=[]; - for(const vc of D.valueChecks) for(const [c,[q,mm]] of Object.entries(v.valueChecks[vc.id]||{})){if(F&&c!==F) continue;const shortBy=Math.ceil(m.targetPercent/100*q-mm);if(shortBy>0) rows.push({vc,c,q,mm,shortBy})} - rows.sort((a,b)=>b.shortBy-a.shortBy); - const all=rows.reduce((a,r)=>a+r.shortBy,0),top=rows.slice(0,6); - $('#gaps').innerHTML=top.length?`${top.map(r=>``).join('')}
    CheckFirmGoalFilledShort of the ${m.targetPercent} % targetShare of the whole gap
    ${esc(r.vc.label)}${esc(r.c)}${esc((D.plan.goals.find(g=>g.id===r.vc.goal)||{}).name||'')}${pct(100*r.mm/r.q)}${fmt(r.shortBy)} values${pct(100*r.shortBy/all,0)}
    ${rows.length>top.length?`

    ${rows.length-top.length} smaller shortfall${rows.length-top.length===1?'':'s'} not listed.

    `:''}`:`

    Every check of ${F?esc(F):'every firm'} meets the ${m.targetPercent} % target at this version.

    `; + const v=V[sel],m=msOf(v),ds=deficiencies(),n=[0,1,2].map(k=>ds.filter(d=>d.urg===k).length); + $('#defSum').textContent=ds.length?`${ds.length} open at ${v.label}${F?' for '+F:''}: ${n[0]} overdue, ${n[1]} will miss ${m.name}, ${n[2]} on course.`:''; + const pv=(d,x)=>x==null?'–':d.kind==='r'&&d.unit==='pt'?x.toFixed(2)+' pt':fmt(x); + const row=d=>`${URG[d.urg][1]}${d.missed.length?`missed at ${d.missed.map(x=>esc(x.name)).join(', ')}`:''} + ${esc(d.label)}${d.kind==='r'?'Model rule':'Required values'} · ${esc((D.plan.goals.find(g=>g.id===d.goal)||{}).name||'')} + ${d.owners.length?d.owners.map(c=>`${esc(c)}${d.by?' '+fmt(d.by[c]):''}`).join(' '):'Whole model'} + ${d.size}${d.sub} + ${esc(V[d.since].label)}, ${dShort(dayOf(V[d.since]))}${d.weeks} working week${d.weeks===1?'':'s'} + ${d.pace==null?'–':(d.pace>0?'':d.pace<0?'−':'')+pv(d,Math.abs(d.pace))}${d.need==null?'due now':'needs '+pv(d,d.need)} + ${d.closes?dShort(d.closes)+(d.closes.slice(0,4)!==now().slice(0,4)?', '+d.closes.slice(0,4):''):d.pace==null?'Not enough versions yet':'Not at this pace'}`; + const head='UrgencyDeficiencyOwnerSizeOpen sincePace per weekCloses at this pace'; + const tbl=(list,cap)=>{const top=list.slice(0,cap),rest=list.slice(cap);return `
    ${head}${top.map(row).join('')}
    ${rest.length?`
    Show ${rest.length} more
    ${head}${rest.map(row).join('')}
    `:''}
    `}; + const none=`

    Nothing open: every check of ${F?esc(F):'every firm'} meets the ${m.targetPercent} % target and every model rule passes at this version.

    `; + if(!ds.length) $('#gaps').innerHTML=none; + else if(group==='u') $('#gaps').innerHTML=tbl(ds,8); + else{ // one block per firm, the firm with the most urgent load first; a rule owned by two firms shows under both + const blocks=ROLES.filter(r=>v.byRole[r.code]&&(!F||r.code===F)).map(ro=>{const c=ro.code,mine=ds.filter(d=>d.owners.includes(c)).map(d=>d.by?{...d,owners:[c]}:d),k=[0,1,2].map(q=>mine.filter(d=>d.urg===q).length);return {ro,c,mine,k,p:roleP(v,c)}}) + .sort((a,b)=>b.k[0]-a.k[0]||b.k[1]-a.k[1]||b.mine.length-a.mine.length); + const whole=ds.filter(d=>!d.owners.length); + $('#gaps').innerHTML=blocks.map(b=>`
    ${esc(b.c)} ${esc(b.ro.role)} ${esc(b.ro.firm||'')}Own compliance ${pct(b.p)} against ${m.targetPercent} %${b.mine.length} open${b.k[0]?`✕ ${b.k[0]} overdue`:''}${b.k[1]?`! ${b.k[1]} will miss`:''}${b.k[2]?`✓ ${b.k[2]} on course`:''}
    ${b.mine.length?tbl(b.mine,5):'

    Nothing open for this firm at this version.

    '}
    `).join('') + +(whole.length?`
    Whole model rules the checker does not split by firm
    ${tbl(whole,5)}
    `:''); + } + $('#defKey').innerHTML=`
  • Overdue: still open after a milestone it should have met.
  • Will miss the milestone: at the pace of the last four working weeks it closes after ${esc(m.name)} (${dShort(m.date)}), or not at all.
  • On course: at that pace it closes in time.
  • Owner: the firm whose elements carry the deficiency. For a model rule, the number beside the code is how many of its elements fail.
  • `; + accountability(ds); +} +function accountability(ds){ + const v=V[sel],esc2=D.plan.escalation||[],past=MS.filter(msPassed); + const rows=ROLES.filter(r=>v.byRole[r.code]).map(ro=>{const c=ro.code; + const rec=past.map(x=>{const u=V[msVer(x)];return u.byRole[c]?{x,ok:roleP(u,c)>=x.targetPercent,p:roleP(u,c)}:null}).filter(Boolean); + let run=0;for(let i=rec.length-1;i>=0&&!rec[i].ok;i--) run++; + const mine=ds.filter(d=>d.owners.includes(c)),k=[0,1,2].map(q=>mine.filter(d=>d.urg===q).length),old=mine.slice().sort((a,b)=>b.weeks-a.weeks)[0]; + const step=!esc2.length?null:run===0?'No step: last milestone met':`Step ${Math.min(run,esc2.length)}: ${esc(esc2[Math.min(run,esc2.length)-1])}`; + return `
    ${esc(c)} ${esc(ro.role)}${esc(ro.firm||'')}
    + ${rec.length?`${rec.filter(q=>q.ok).length} of ${rec.length}${rec.filter(q=>!q.ok).map(q=>`Missed ${esc(q.x.name)}: ${pct(q.p,0)} against ${q.x.targetPercent} %`).join('')}`:'None due yet'} + ${run} + ${esc2.length?`${run?`${step}`:step}`:''} + ${mine.length?`${mine.length}${k[0]} overdue · ${k[1]} will miss · ${k[2]} on course`:'✓ Nothing open'} + ${old?`${esc(old.label)}${old.weeks} working week${old.weeks===1?'':'s'}, since ${esc(V[old.since].label)}`:'–'}`}).join(''); + $('#acc').innerHTML=`${esc2.length?'':''}${rows}
    FirmMilestones metMissed in a rowStep set by the planOpen nowOldest open
    `; } /* ---------- tiles ---------- */ diff --git a/compliance/series.js b/compliance/series.js index c6972bd..0252d66 100644 --- a/compliance/series.js +++ b/compliance/series.js @@ -13,7 +13,7 @@ const need = (ok, msg) => { if (!ok) e.push(msg); return ok; }; if (!need(d && typeof d === 'object', 'The file is not a JSON object.')) return e; need(d.format === 'openbep-compliance-series', 'format must be "openbep-compliance-series".'); - need(typeof d.formatVersion === 'string' && /^0\./.test(d.formatVersion), 'formatVersion must be 0.x (this page reads 0.1 and 0.2).'); + need(typeof d.formatVersion === 'string' && /^0\./.test(d.formatVersion), 'formatVersion must be 0.x (this page reads 0.1 to 0.3).'); const p = d.plan || {}; need(typeof p.name === 'string' && p.name, 'plan.name is missing.'); const goals = Array.isArray(p.goals) ? p.goals : [], ms = Array.isArray(p.milestones) ? p.milestones : [], roles = Array.isArray(p.roles) ? p.roles : []; @@ -24,6 +24,7 @@ goals.forEach((g, i) => { need(g.id && g.name, `plan.goals[${i}] needs id and name.`); need(!gid.has(g.id), `Goal id "${g.id}" is used twice.`); gid.add(g.id); need(!g.uses || Array.isArray(g.uses), `plan.goals[${i}].uses must be a list.`); }); ms.forEach((m, i) => { need(m.id && m.name, `plan.milestones[${i}] needs id and name.`); need(isDate(m.date), `Milestone "${m.name}" needs a date (YYYY-MM-DD).`); need(isNum(m.targetPercent) && m.targetPercent >= 0 && m.targetPercent <= 100, `Milestone "${m.name}" needs targetPercent between 0 and 100.`); if (i) need(m.date >= ms[i - 1].date, 'plan.milestones must be in date order.'); mid.add(m.id); }); roles.forEach((r, i) => { need(r.code && r.role, `plan.roles[${i}] needs code and role.`); need(!codes.has(r.code), `Role code "${r.code}" is used twice.`); codes.add(r.code); need(r.from == null || isDate(r.from), `Role ${r.code}: from must be a date or null.`); }); + if (p.escalation != null) need(Array.isArray(p.escalation) && p.escalation.every(x => typeof x === 'string' && x), 'plan.escalation must be a list of steps, in order.'); (p.holidays || []).forEach((h, i) => need(isDate(h.from) && isDate(h.to) && h.to >= h.from, `plan.holidays[${i}] needs from and to dates, in order.`)); const vcs = Array.isArray(d.valueChecks) ? d.valueChecks : [], rules = Array.isArray(d.rules) ? d.rules : []; const vid = new Set(), rid = new Set(); @@ -62,7 +63,9 @@ } } for (const [c, r] of Object.entries(br)) if (sums[c]) need(sums[c][0] === r.required && sums[c][1] === r.met, `${L}, ${c}: the value checks add up to ${sums[c][1]} of ${sums[c][0]}, but byRole says ${r.met} of ${r.required}.`); - for (const id of rid) { const x = (v.rules || {})[id]; need(x && isNum(x.value) && typeof x.pass === 'boolean', `${L}: rule "${id}" needs value and pass.`); } + for (const id of rid) { const x = (v.rules || {})[id]; need(x && isNum(x.value) && typeof x.pass === 'boolean', `${L}: rule "${id}" needs value and pass.`); + // Optional since 0.3: whose elements fail the rule. + if (x && x.byRole != null) need(typeof x.byRole === 'object' && Object.entries(x.byRole).every(([c, n]) => codes.has(c) && isNum(n) && n >= 0), `${L}: rule "${id}" byRole must give a count per role code.`); } }); need(nChecked, 'No version was checked.'); return e; diff --git a/compliance/test/test_page.js b/compliance/test/test_page.js index c37654e..b10ac7f 100644 --- a/compliance/test/test_page.js +++ b/compliance/test/test_page.js @@ -16,6 +16,7 @@ function keepRoles(d, codes) { if (v.state !== 'checked') continue; for (const c of Object.keys(v.byRole)) if (!codes.includes(c)) delete v.byRole[c]; for (const per of Object.values(v.valueChecks)) for (const c of Object.keys(per)) if (!codes.includes(c)) delete per[c]; + for (const x of Object.values(v.rules)) if (x.byRole) for (const c of Object.keys(x.byRole)) if (!codes.includes(c)) delete x.byRole[c]; } return d; } @@ -26,6 +27,7 @@ function renameRoles(d, map) { if (v.state !== 'checked') continue; v.byRole = Object.fromEntries(Object.entries(v.byRole).map(([c, x]) => [map[c], x])); for (const k of Object.keys(v.valueChecks)) v.valueChecks[k] = Object.fromEntries(Object.entries(v.valueChecks[k]).map(([c, x]) => [map[c], x])); + for (const x of Object.values(v.rules)) if (x.byRole) x.byRole = Object.fromEntries(Object.entries(x.byRole).map(([c, n]) => [map[c], n])); } return d; } @@ -33,7 +35,7 @@ const fixtures = {}; fixtures.example = ex; { // Two firms, goals renamed, one goal with nothing checkable, holidays removed. const d = keepRoles(clone(ex), ['ARCH', 'MECH']); - d.example = false; d.plan.name = 'Test: two firms'; d.plan.holidays = []; + d.example = false; d.plan.name = 'Test: two firms'; d.plan.holidays = []; delete d.plan.escalation; d.plan.goals = d.plan.goals.map((g, i) => ({ ...g, name: 'Goal number ' + (i + 1) + ' with a long name that must wrap and never be cut' })); d.plan.goals.push({ id: 'carbon', name: 'Energy and carbon targets', uses: ['Energy analysis'] }); fixtures.two = d; @@ -97,7 +99,7 @@ const server = http.createServer((req, res) => { // Round two: one firm only, the values chart, and a link that reopens the same view. const code = Object.keys(last.byRole)[0]; await page.selectOption('#selV', String(d.versions.indexOf(last))); await page.selectOption('#firmF', code); await page.click('#modeV'); await page.waitForTimeout(50); - const r2 = await page.evaluate(() => ({ gate: !!document.querySelector('#gate .gate'), gaps: !!document.querySelector('#gaps').textContent.trim(), url: location.search, scope: !!document.querySelector('#chOverall .scope'), wide: document.documentElement.scrollWidth > innerWidth + 1 })); + const r2 = await page.evaluate(() => ({ gate: !!document.querySelector('#gate .gate'), gaps: !!document.querySelector('#gaps').textContent.trim() && document.querySelectorAll('#msCards .msc').length > 0 && document.querySelectorAll('#acc tbody tr').length > 0, url: location.search, scope: !!document.querySelector('#chOverall .scope'), wide: document.documentElement.scrollWidth > innerWidth + 1 })); ok(!errs.length && r2.gate && r2.gaps && r2.scope && !r2.wide, `${k} @${width}: firm filter, gate, gaps and values chart ${errs.join(' ')}`); ok(new URLSearchParams(r2.url).get('firm') === code && new URLSearchParams(r2.url).get('v') === String(last.order), `${k} @${width}: the address keeps version and firm (${r2.url})`); await page.goto(`http://127.0.0.1:${port}/compliance/${r2.url}`); await page.waitForSelector('#tiles .tile');