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:
129
frontend/lib/Grounded/about/external/data/Commitment.dart
vendored
Normal file
129
frontend/lib/Grounded/about/external/data/Commitment.dart
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import '../../internal/application/CommitmentClass.dart';
|
||||
import '../../internal/application/CommitmentStatus.dart';
|
||||
import '../../internal/application/CommitmentType.dart';
|
||||
import '../../internal/application/EnergyCost.dart';
|
||||
import '../../internal/application/ProofType.dart';
|
||||
|
||||
/// Something the user said they would do. A due *window*, not a due date —
|
||||
/// "Mon 06:00-08:00" beats "Monday", because a window can actually close.
|
||||
class Commitment {
|
||||
String? id;
|
||||
|
||||
CommitmentType type;
|
||||
|
||||
CommitmentClass commitmentClass;
|
||||
|
||||
String title;
|
||||
|
||||
String category;
|
||||
|
||||
DateTime? dueStart;
|
||||
|
||||
DateTime? dueEnd;
|
||||
|
||||
int estMinutes;
|
||||
|
||||
EnergyCost energy;
|
||||
|
||||
ProofType proofType;
|
||||
|
||||
/// Minimum foreground minutes when proofType is Timer.
|
||||
int proofTimerMinutes;
|
||||
|
||||
String rrule;
|
||||
|
||||
String? parentId;
|
||||
|
||||
CommitmentStatus status;
|
||||
|
||||
int deferralCount;
|
||||
|
||||
Commitment({
|
||||
this.id,
|
||||
this.type = CommitmentType.TASK,
|
||||
this.commitmentClass = CommitmentClass.Standard,
|
||||
this.title = "",
|
||||
this.category = "",
|
||||
this.dueStart,
|
||||
this.dueEnd,
|
||||
this.estMinutes = 0,
|
||||
this.energy = EnergyCost.Medium,
|
||||
this.proofType = ProofType.Honour,
|
||||
this.proofTimerMinutes = 0,
|
||||
this.rrule = "",
|
||||
this.parentId,
|
||||
this.status = CommitmentStatus.Open,
|
||||
this.deferralCount = 0,
|
||||
});
|
||||
|
||||
factory Commitment.fromJson(Map<String, dynamic> json) {
|
||||
return Commitment(
|
||||
id: json['id'],
|
||||
type: getCommitmentType(json['type']),
|
||||
commitmentClass: getCommitmentClass(json['commitmentClass']),
|
||||
title: json['title'] ?? "",
|
||||
category: json['category'] ?? "",
|
||||
dueStart: DateTime.tryParse(json['dueStart'] ?? ""),
|
||||
dueEnd: DateTime.tryParse(json['dueEnd'] ?? ""),
|
||||
estMinutes: json['estMinutes'] ?? 0,
|
||||
energy: getEnergyCost(json['energy']),
|
||||
proofType: getProofType(json['proofType']),
|
||||
proofTimerMinutes: json['proofTimerMinutes'] ?? 0,
|
||||
rrule: json['rrule'] ?? "",
|
||||
parentId: json['parentId'],
|
||||
status: getCommitmentStatus(json['status']),
|
||||
deferralCount: json['deferralCount'] ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['type'] = type.name;
|
||||
data['commitmentClass'] = commitmentClass.name;
|
||||
data['title'] = title;
|
||||
data['category'] = category;
|
||||
data['dueStart'] = dueStart?.toIso8601String();
|
||||
data['dueEnd'] = dueEnd?.toIso8601String();
|
||||
data['estMinutes'] = estMinutes;
|
||||
data['energy'] = energy.name;
|
||||
data['proofType'] = proofType.name;
|
||||
data['proofTimerMinutes'] = proofTimerMinutes;
|
||||
data['rrule'] = rrule;
|
||||
data['parentId'] = parentId;
|
||||
data['status'] = status.name;
|
||||
data['deferralCount'] = deferralCount;
|
||||
return data;
|
||||
}
|
||||
|
||||
/// The window has closed. A commitment goes Overdue at close — it never
|
||||
/// silently rolls over to today.
|
||||
bool get windowClosed {
|
||||
if (dueEnd == null) {
|
||||
return false;
|
||||
}
|
||||
return DateTime.now().isAfter(dueEnd!);
|
||||
}
|
||||
|
||||
/// Whole days past the close of the window; 0 while still open.
|
||||
int get daysOverdue {
|
||||
if (dueEnd == null || !windowClosed) {
|
||||
return 0;
|
||||
}
|
||||
return DateTime.now().difference(dueEnd!).inDays;
|
||||
}
|
||||
|
||||
/// Whether completing right now would count as a late complete rather than a
|
||||
/// clean one. Late is recorded distinctly and never reduces debt to zero.
|
||||
bool get wouldBeLate {
|
||||
return windowClosed;
|
||||
}
|
||||
|
||||
/// Non-negotiables are never deferrable, at any count.
|
||||
bool deferrableUnder(int maxDeferrals) {
|
||||
if (commitmentClass == CommitmentClass.NonNegotiable) {
|
||||
return false;
|
||||
}
|
||||
return deferralCount < maxDeferrals;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user