Initial commit: Grounded Flutter frontend

A to-do app that doesn't believe you — an enforcement layer rather than a
neutral ledger.

Architecture ported from Autoreceptives/Frontend/Receptive: stacked MVVM with
the mandatory 4-file screen pattern, one ParentViewModel owning the loading /
network / error overlays and the handleError decision tree, one AppDataManager
gateway, dio comms carrying the three identity headers, secure storage with
random-suffixed keys, and a single-chokepoint Navigator. Package root and Dart
package name are both Grounded; org is nya.

The enforcement engine, one unit per formula in utils/:

- DebtEngine      w(class) x severity(d) x decay(t), sublinear severity so old
                  misses cannot swamp the score; abandonment 2x with 30-day
                  decay immunity; late complete retains 30%
- StandingEngine  Good -> Warned -> Grounded -> Lockdown, derived not set;
                  Grounded replaces home with the overdue queue
- CapacityEngine  blocks over-scheduling against p50 of historically completed
                  minutes, with a learned per-category estimation multiplier
- IntegrityEngine session integrity, weekly volume, plyometric contact ceiling
                  and enforced recovery gaps
- ExcuseAnalyser  on-device excuse clustering plus the confrontation copy
- GuardrailEngine distress detection and rationed amnesty
- ToneEngine      all enforcement copy, so the tone cap lives in one place

CommitmentEvent is append-only and is the source of truth rather than the
status field, which is what makes honest history and excuse analysis possible.

Goals contain commitments via parentId, and a task can be run from a
full-screen runner that derives elapsed time from wall-clock so screen-off
cannot lose time. Backgrounding pauses the clock and is counted. The runner is
mirrored into an ongoing notification, with alarm-class full-screen intents
reserved for non-negotiables.

Design language, fonts, icon and native splash are in place; Mason bricks are
retargeted to this project and verified end-to-end.

flutter analyze lib/ reports no errors.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mfu2gQLSFN21YRBcU2NrTt
This commit is contained in:
alvocool
2026-07-27 09:11:17 +03:00
commit 16bff634b5
315 changed files with 19132 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
/// What the user can realistically absorb, learned from history rather than
/// asserted. Drives the capacity block at plan time.
class CapacityProfile {
/// p50 of historically completed minutes, keyed by weekday (1 = Monday).
Map<int, double> completedMinutesByWeekday;
/// Per-category estimation multiplier — you say 30min, you take 70min -> 2.3.
Map<String, double> estimationMultipliers;
CapacityProfile({
Map<int, double>? completedMinutesByWeekday,
Map<String, double>? estimationMultipliers,
}) : completedMinutesByWeekday = completedMinutesByWeekday ?? <int, double>{},
estimationMultipliers = estimationMultipliers ?? <String, double>{};
factory CapacityProfile.fromJson(Map<String, dynamic> json) {
final Map<int, double> minutes = <int, double>{};
if (json['completedMinutesByWeekday'] != null) {
(json['completedMinutesByWeekday'] as Map<String, dynamic>)
.forEach((key, value) {
minutes[int.tryParse(key) ?? 1] = (value ?? 0).toDouble();
});
}
final Map<String, double> multipliers = <String, double>{};
if (json['estimationMultipliers'] != null) {
(json['estimationMultipliers'] as Map<String, dynamic>)
.forEach((key, value) {
multipliers[key] = (value ?? 1).toDouble();
});
}
return CapacityProfile(
completedMinutesByWeekday: minutes,
estimationMultipliers: multipliers,
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['completedMinutesByWeekday'] = completedMinutesByWeekday
.map((key, value) => MapEntry(key.toString(), value));
data['estimationMultipliers'] = estimationMultipliers;
return data;
}
/// The learned multiplier for a category, defaulting to honest 1.0 until
/// there is enough history to say otherwise.
double multiplierFor(String category) {
return estimationMultipliers[category] ?? 1.0;
}
/// The p50 of what actually gets done on this weekday.
double capacityFor(int weekday) {
return completedMinutesByWeekday[weekday] ?? 0;
}
}

View File

@@ -0,0 +1,44 @@
/// The disciplinary weight class of a commitment. Central, not cosmetic — the
/// class decides debt weight, deferability and escalation harshness.
enum CommitmentClass {
/// Never auto-deferrable, heaviest debt weight, hardest escalation.
NonNegotiable,
/// Normal weight, limited deferrals.
Standard,
/// Nice-to-have, no debt on miss, auto-archives.
Elective,
}
/// Debt weight w(class) from the debt formula.
double classWeight(CommitmentClass value) {
switch (value) {
case CommitmentClass.NonNegotiable:
return 5.0;
case CommitmentClass.Standard:
return 2.0;
case CommitmentClass.Elective:
return 0.0;
}
}
String classLabel(CommitmentClass value) {
switch (value) {
case CommitmentClass.NonNegotiable:
return "Non-negotiable";
case CommitmentClass.Standard:
return "Standard";
case CommitmentClass.Elective:
return "Elective";
}
}
CommitmentClass getCommitmentClass(String? name) {
for (CommitmentClass value in CommitmentClass.values) {
if (value.name == name) {
return value;
}
}
return CommitmentClass.Standard;
}

View File

@@ -0,0 +1,18 @@
enum CommitmentStatus {
Open,
Completed,
LateCompleted,
Overdue,
Deferred,
Abandoned,
Archived,
}
CommitmentStatus getCommitmentStatus(String? name) {
for (CommitmentStatus value in CommitmentStatus.values) {
if (value.name == name) {
return value;
}
}
return CommitmentStatus.Open;
}

View File

@@ -0,0 +1,10 @@
enum CommitmentType { TASK, SESSION, HABIT }
CommitmentType getCommitmentType(String? name) {
for (CommitmentType value in CommitmentType.values) {
if (value.name == name) {
return value;
}
}
return CommitmentType.TASK;
}

View File

@@ -0,0 +1,7 @@
class DialogData {
String title;
String description;
DialogData(this.title, this.description);
}

View File

@@ -0,0 +1,10 @@
enum EnergyCost { Low, Medium, High }
EnergyCost getEnergyCost(String? name) {
for (EnergyCost value in EnergyCost.values) {
if (value.name == name) {
return value;
}
}
return EnergyCost.Medium;
}

View File

@@ -0,0 +1,11 @@
/// Notification escalation ladder. Disappointment outperforms anger.
enum EscalationTier { Reminder, Nudge, Nag, Disappointed, Cold }
EscalationTier getEscalationTier(String? name) {
for (EscalationTier value in EscalationTier.values) {
if (value.name == name) {
return value;
}
}
return EscalationTier.Reminder;
}

View File

@@ -0,0 +1,20 @@
/// Append-only commitment event log. The status field is never the source of
/// truth — this log is.
enum EventType {
CREATED,
COMPLETED,
LATE,
DEFERRED,
MISSED,
ABANDONED,
AMNESTY,
}
EventType getEventType(String? name) {
for (EventType value in EventType.values) {
if (value.name == name) {
return value;
}
}
return EventType.CREATED;
}

View File

@@ -0,0 +1,27 @@
/// The device + session identity carried on every request. `name` and `id` are
/// stored pre-encrypted and become the `what` / `whom` headers.
class MeDescription {
String id;
String name;
String token;
MeDescription({required this.id, required this.name, required this.token});
factory MeDescription.fromJson(Map<String, dynamic> json) {
return MeDescription(
id: json['id'] ?? "",
name: json['name'] ?? "",
token: json['token'] ?? "",
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['token'] = token;
return data;
}
}

View File

@@ -0,0 +1 @@
enum NavigatorType { justOpen, openFully, replaceCurrent, makeNewMain }

View File

@@ -0,0 +1 @@
enum NotificationType { info, success, error, warning }

View File

@@ -0,0 +1,7 @@
class Pair {
String key;
dynamic value;
Pair(this.key, this.value);
}

View File

@@ -0,0 +1,42 @@
/// Progression rules that actually apply to bodyweight training, where adding
/// plates is not the lever.
enum ProgressionRule {
/// 3x8 -> 3x12, then a harder variation.
Reps,
/// Incline push-up -> flat -> decline -> archer -> one-arm.
Leverage,
/// Slower tempo, longer holds, same reps.
TimeUnderTension,
/// Same work, less rest.
Density,
/// Added external load.
Load,
}
String progressionLabel(ProgressionRule value) {
switch (value) {
case ProgressionRule.Reps:
return "Rep progression";
case ProgressionRule.Leverage:
return "Leverage progression";
case ProgressionRule.TimeUnderTension:
return "Time under tension";
case ProgressionRule.Density:
return "Density";
case ProgressionRule.Load:
return "Load";
}
}
ProgressionRule getProgressionRule(String? name) {
for (ProgressionRule value in ProgressionRule.values) {
if (value.name == name) {
return value;
}
}
return ProgressionRule.Reps;
}

View File

@@ -0,0 +1,46 @@
/// The anti-cheat layer. Chosen per commitment at creation time.
enum ProofType {
/// Plain checkbox — for trivia only.
Honour,
/// Camera-only, no gallery import, timestamp + optional GPS embedded.
Photo,
/// Foreground session of >= X minutes; backgrounding pauses it.
Timer,
/// Geofence dwell via passive location.
Location,
/// Health platform confirms a workout occurred in the window.
Health,
/// An accountability partner taps to confirm.
Witness,
}
String proofLabel(ProofType value) {
switch (value) {
case ProofType.Honour:
return "Honour";
case ProofType.Photo:
return "Photo";
case ProofType.Timer:
return "Timer";
case ProofType.Location:
return "Location";
case ProofType.Health:
return "Health";
case ProofType.Witness:
return "Witness";
}
}
ProofType getProofType(String? name) {
for (ProofType value in ProofType.values) {
if (value.name == name) {
return value;
}
}
return ProofType.Honour;
}

View File

@@ -0,0 +1,35 @@
/// The current disciplinary state. Derived from debt, drives what the app
/// permits: Good -> Warned -> Grounded -> Lockdown.
enum Standing { Good, Warned, Grounded, Lockdown }
String standingLabel(Standing value) {
switch (value) {
case Standing.Good:
return "Good standing";
case Standing.Warned:
return "Warned";
case Standing.Grounded:
return "Grounded";
case Standing.Lockdown:
return "Lockdown";
}
}
/// Whether the user is allowed to create new commitments in this standing.
bool canAddCommitments(Standing value) {
return value == Standing.Good || value == Standing.Warned;
}
/// Whether elective commitments are permitted in this standing.
bool canAddElectives(Standing value) {
return value == Standing.Good;
}
Standing getStanding(String? name) {
for (Standing value in Standing.values) {
if (value.name == name) {
return value;
}
}
return Standing.Good;
}

View File

@@ -0,0 +1,6 @@
enum TextType {
Bold,
Light,
Regular,
Medium,
}

View File

@@ -0,0 +1,34 @@
class Token {
String accessToken;
String refreshToken;
String tokenType;
int expiresIn;
String scope;
Token(this.accessToken, this.refreshToken, this.tokenType, this.expiresIn,
this.scope);
factory Token.fromJsonMap(Map<String, dynamic> json) {
return Token(
json['access_token'] ?? "",
json['refresh_token'] ?? "",
json['token_type'] ?? "",
json['expires_in'] ?? 0,
json['scope'] ?? "",
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['access_token'] = accessToken;
data['refresh_token'] = refreshToken;
data['token_type'] = tokenType;
data['expires_in'] = expiresIn;
data['scope'] = scope;
return data;
}
}

View File

@@ -0,0 +1,23 @@
/// The tone slider. Hard-capped: no copy ever attacks the user's worth, only
/// their behaviour.
enum ToneLevel { Firm, Strict, DrillSergeant }
String toneLabel(ToneLevel value) {
switch (value) {
case ToneLevel.Firm:
return "Firm";
case ToneLevel.Strict:
return "Strict";
case ToneLevel.DrillSergeant:
return "Drill Sergeant";
}
}
ToneLevel getToneLevel(String? name) {
for (ToneLevel value in ToneLevel.values) {
if (value.name == name) {
return value;
}
}
return ToneLevel.Strict;
}

View File

@@ -0,0 +1,57 @@
import 'Standing.dart';
import 'ToneLevel.dart';
class UserDetails {
String pic;
String name;
String timezone;
ToneLevel tone;
Standing standing;
double debtScore;
int amnestyTokens;
bool sickMode;
UserDetails({
required this.pic,
required this.name,
this.timezone = "Africa/Nairobi",
this.tone = ToneLevel.Strict,
this.standing = Standing.Good,
this.debtScore = 0,
this.amnestyTokens = 0,
this.sickMode = false,
});
factory UserDetails.fromJson(Map<String, dynamic> json) {
return UserDetails(
pic: json['pic'] ?? "",
name: json['name'] ?? "",
timezone: json['timezone'] ?? "Africa/Nairobi",
tone: getToneLevel(json['tone']),
standing: getStanding(json['standing']),
debtScore: (json['debtScore'] ?? 0).toDouble(),
amnestyTokens: json['amnestyTokens'] ?? 0,
sickMode: json['sickMode'] ?? false,
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['pic'] = pic;
data['name'] = name;
data['timezone'] = timezone;
data['tone'] = tone.name;
data['standing'] = standing.name;
data['debtScore'] = debtScore;
data['amnestyTokens'] = amnestyTokens;
data['sickMode'] = sickMode;
return data;
}
}