contentSignature method
Cheap fingerprint of what the agent can read: labels + text previews in tree order. Equal signatures across two reads mean nothing readable moved.
Implementation
String contentSignature() {
var hash = 0;
void mix(String s) {
for (final c in s.codeUnits) {
hash = (hash * 31 + c) & 0x7fffffff;
}
}
var count = 0;
for (final n in root.walk()) {
if (n.isOffstage) continue;
count++;
mix(n.label);
mix(n.textPreview ?? '');
}
return '$count:$hash';
}