@githolon/dsl 0.119.11 → 0.119.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dart/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.70.12
2
+
3
+ - Reconcile a completed round's outstanding work and copy repairs before folding application sync status, so a successful reconnect clears the aggregate pending state immediately. Add opt-in session and aggregate sync trace provenance.
4
+ - Keep application sync pending while background follows, stream queues or preparation remain outstanding; release that state on their final report without requiring another session event.
5
+ - Keep pending-commit counts available from retained local history when the network link is closed; do not turn missing custody into a zero count.
6
+
7
+ Run event-triggered application projection refreshes in the shared background scheduling context. Preserve cross-workspace updates and initial visible-read priority without repeatedly delaying native sync.
8
+
1
9
  ## 0.70.11
2
10
 
3
11
  - A pack tidy that fails after a sync no longer shows the application as still preparing: the read index a sync owes is reported under its own read cause, and a SYNC report is custody upkeep alone (CAP-952).
@@ -0,0 +1,11 @@
1
+ import 'dart:async';
2
+
3
+ final Object _background = Object();
4
+
5
+ /// Marks automatic application work for the host scheduler. This does not
6
+ /// change authorization, results or sync evidence; user requests keep priority.
7
+ Future<T> nomosRunInBackground<T>(Future<T> Function() body) =>
8
+ runZoned(body, zoneValues: {_background: true});
9
+
10
+ /// Inherited through awaited continuations and stream callbacks in this zone.
11
+ bool get nomosInBackground => Zone.current[_background] == true;
@@ -1,3 +1,4 @@
1
+ import 'background_work.dart' show nomosRunInBackground;
1
2
  import 'application_status.dart' show ApplicationStatus;
2
3
  import 'nms_generated_runtime.dart' show NomosSession, SyncStatus;
3
4
  import 'workspace_open_progress.dart' show ApplicationWorkspaceOpenProgress;
@@ -75,7 +76,7 @@ final class NmsPeerApplicationStreamView implements NmsPeerApplicationStreams {
75
76
  var reading = false;
76
77
  var reread = false;
77
78
 
78
- Future<void> refresh() async {
79
+ Future<void> refresh({bool automatic = false}) async {
79
80
  if (reading) {
80
81
  reread = true;
81
82
  return;
@@ -84,18 +85,22 @@ final class NmsPeerApplicationStreamView implements NmsPeerApplicationStreams {
84
85
  do {
85
86
  reread = false;
86
87
  try {
87
- final value = await read();
88
+ final value =
89
+ await (automatic ? nomosRunInBackground(read) : read());
88
90
  if (!events.isClosed) events.add(value);
89
91
  } catch (error, stackTrace) {
90
92
  if (!events.isClosed) events.addError(error, stackTrace);
91
93
  }
94
+ // A change coalesced during the initial visible read is automatic
95
+ // too; it must not inherit that first read's user priority.
96
+ automatic = true;
92
97
  } while (reread && !events.isClosed);
93
98
  reading = false;
94
99
  }
95
100
 
96
101
  final subscriptions = changes
97
102
  .map((stream) => stream.listen(
98
- (_) => refresh(),
103
+ (_) => refresh(automatic: true),
99
104
  onError: events.addError,
100
105
  ))
101
106
  .toList(growable: false);
@@ -971,10 +971,6 @@ class DartReception {
971
971
  }
972
972
  }
973
973
  final observedAt = DateTime.now();
974
- _eventPlane._updateScopedStatus(
975
- session,
976
- (current) => reduceSyncCompletion(current, completed, observedAt),
977
- );
978
974
  // A round may "complete" over a damaged copy (nothing pulled, head unchanged) while its
979
975
  // kernel cannot read a commit of it; that is reported as a separate failure. Either says
980
976
  // the copy is being repaired, and a refetch that replaced it says it is repaired.
@@ -997,6 +993,23 @@ class DartReception {
997
993
  at: observedAt, detail: nmsOwedWorkDetail(result));
998
994
  }
999
995
  }
996
+ // Reconcile the round's owed-work/repair facts BEFORE reducing and folding
997
+ // its result. Otherwise a released session becomes idle after the fold,
998
+ // leaving the application syncing until some unrelated event (CAP-791).
999
+ _eventPlane._updateScopedStatus(
1000
+ session,
1001
+ (current) => reduceSyncCompletion(current, completed, observedAt),
1002
+ );
1003
+ if (NomosTrace.enabled) {
1004
+ final status = session == null
1005
+ ? syncStatuses.applicationStatus
1006
+ : syncStatuses.statusFor(session);
1007
+ NomosTrace.emit('dart', 'sync.completed',
1008
+ 'session=$session reason=${completed.reason} '
1009
+ 'phase=${status.phase.name} live=${status.live} '
1010
+ 'owed=${syncStatuses.unsharedWork.length} '
1011
+ 'aggregate=${syncStatuses.applicationStatus.phase.name}');
1012
+ }
1000
1013
  return;
1001
1014
  }
1002
1015
  if (event.hasLawChanged()) {