feat: initial F∆I Law-Heatmap Phase 0 scaffold

First end-to-end-buildable cut of the pflicht-/graph-basierte
Wirkungsanalyse von Rechtsnormen, running on Ch∆In. Demo runs
without external dependencies and without a hub connection so
the methodology + UI stack can be reviewed before any Verbands-
Kooperation or Beirats-Validierung kicks in.

Tree layout

  MACHBARKEITSSTUDIE.md       v0.3 — pflicht-basierte Methodik,
                              4-Tier-Evidenz, 8 law*-Module
                              auf Ch∆In statt der alten F∆I-
                              Plattform.
  RUN.md                      one-page how-to-run.
  flows/durchstich-gewo-14.yaml
                              vertical Phase-0 flow: pull →
                              normalize → duties → citations →
                              cohort → skm → frust → benefit →
                              attribution → system.approval.
  app/                        Flutter macOS client, design
                              language pulled from fai_web
                              (ink #08090A, paper #F4F3EF,
                              petrol signal #2E8F9E). Mock
                              repository ships five fixture
                              norms with real source URLs and a
                              permanent T4 demo-banner so no
                              figure can be mistaken for a
                              validated one.

Module repos (separate, see chain-modules*/):

  text-akoma-normalize, text-deontic-extract, graph-citation-
  extract, text-readability-score, stats-cohort-size, graph-
  shapley-attribution, econ-skm-score, law-benefit-score.

What runs today

  - flutter analyze: 0 issues
  - flutter test: 2/2 (landing + nav-to-shell smoke)
  - flutter build macos (via app/build-macos.sh) and ad-hoc
    codesign, app launches and the Dart VM service comes up
  - native cargo test green on every module
  - cargo build --release --target wasm32-wasip2 produces a
    130 KiB artefact for text-akoma-normalize

What is deliberately mock / stub

  - gRPC wire from the client to a chain serve hub (Repository
    abstraction is in place; live impl is the next step)
  - NKR Bürokratiekosten-Datenbank ingestion (for the canonical
    h-Werte that close out the Engpass per Studie §6.7)
  - DESTATIS GENESIS-API adapter for stats.cohort_size

License: Apache-2.0. Author/contact in MACHBARKEITSSTUDIE.md.
Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
flemming-it 2026-06-18 11:26:28 +02:00
commit 8ee6a294a1
64 changed files with 5641 additions and 0 deletions

144
app/lib/data/models.dart Normal file
View file

@ -0,0 +1,144 @@
// Domain model for the FI Law-Heatmap client.
//
// These types are the lingua franca between the (eventually
// gRPC-fed) repository and the UI. Names mirror the Studie's
// §5.3 data model.
/// Evidence tier of the lowest-tier ingredient in a value.
/// Per Studie §6.7: "Regel der niedrigsten Stufe" any composed
/// figure carries the tier of its weakest input.
enum EvidenceTier {
/// Official / peer-reviewed: NKR, DESTATIS, ifo, ZEW.
t1,
/// Verbands-Erhebung: DIHK, BDI, ZDH, IHK.
t2,
/// Eigene strukturierte Erhebung (Phase 2/3).
t3,
/// Qualitatives Signal pain indicator only, never magnitude.
t4,
}
extension EvidenceTierLabel on EvidenceTier {
String get short => switch (this) {
EvidenceTier.t1 => 'T1',
EvidenceTier.t2 => 'T2',
EvidenceTier.t3 => 'T3',
EvidenceTier.t4 => 'T4',
};
String get description => switch (this) {
EvidenceTier.t1 => 'amtlich / peer-reviewed',
EvidenceTier.t2 => 'Verband',
EvidenceTier.t3 => 'eigene Erhebung',
EvidenceTier.t4 => 'qualitatives Signal',
};
}
/// A citable source never an LLM, always a public document or
/// dataset reference. UI surfaces these next to every figure.
class Source {
const Source({
required this.label,
required this.url,
required this.tier,
this.note,
});
final String label;
final String url;
final EvidenceTier tier;
final String? note;
}
/// One atomic obligation (Pflicht) extracted from a norm.
/// Tuple shape matches Studie §6.3.
class Duty {
const Duty({
required this.modality,
required this.addressee,
required this.action,
required this.frequency,
required this.sourceNorm,
this.authority,
this.consequence,
});
final String modality; // OBLIGATION | PROHIBITION |
final String addressee;
final String action;
final String frequency;
final String sourceNorm;
final String? authority;
final String? consequence;
}
/// One norm version a versioned legal text identified by its
/// (synthetic for now) ELI/CELEX.
class Norm {
const Norm({
required this.eli,
required this.title,
required this.jurabk,
required this.paragraph,
required this.standDate,
required this.sourceUrl,
required this.sourceSha256,
});
final String eli;
final String title;
final String jurabk;
final String paragraph;
final DateTime standDate;
final String sourceUrl;
final String sourceSha256;
}
/// A heatmap point: one norm with its computed scores.
/// Axes mirror §6 in the study.
class Evaluation {
const Evaluation({
required this.norm,
required this.skmEurPerYear,
required this.benefitScore,
required this.affectedCount,
required this.frustScore,
required this.tierLowest,
required this.duties,
required this.sources,
required this.auditEventId,
this.notes,
});
final Norm norm;
/// Yearly bureaucracy cost across the addressee population.
/// /year, computed via SKM (`P × F × T × h`).
final double skmEurPerYear;
/// 05, composite of seven dimensions
/// (safety / market / legal-certainty / EU-harmony / ).
final double benefitScore;
/// Number of addressees (KMU, Bürger, etc.). UI uses this for
/// heatmap point size.
final int affectedCount;
/// 010, composite of readability + Verweistiefe + Akteurs-
/// pluralität + Norm-Volatilität.
final double frustScore;
/// Lowest tier among all ingredients of any displayed figure.
final EvidenceTier tierLowest;
final List<Duty> duties;
final List<Source> sources;
/// Pointer into the ChIn audit log (SQLite event_log row).
final String auditEventId;
final String? notes;
}