feat(approvals,audit): record the reviewer as the unchecked claim it is
The hub copies the reviewer string a client sends straight into decided_by (DecideApproval, ClearEventLog); nothing on the wire ties it to the authenticated caller. Studio filled it from the OS account, so an export read like non-repudiation while being an arbitrary client claim — the legal finding of the 2026-07-26 usertest panel. The real fix is hub-side (derive decided_by from CALLER_IDENTITY); that contract is written down in docs/reviewer-identity.md and needs a hub release. Until then Studio does the one thing it can do honestly and marks its own claim as a claim, inside the record: - data/reviewer_identity.dart is the single place that produces and reads the value; wire() is idempotent, so page and HubService may both normalise. Every write path funnels through HubService, so no surface can send a bare handle. - The inbox states before the decision who will be recorded, what that attribution is worth on this hub (from AuthStatus), and the literal string that lands in decided_by. An unreadable auth policy stays unreadable — never optimistic. - Reading back: a marked value shows its plain name plus an unchecked flag; an unmarked one (legacy row, CLI decision, or a future hub-derived identity) is not classified either way. - The audit wipe seeds the same kind of marked attribution into its chain.reset marker. When the hub starts deriving the value it overwrites the field and the prefix disappears by itself — no Studio release needed. Guards: reviewer_identity_test (the value) and approvals_reviewer_identity_test (every surface that writes or renders it, against the hermetic fake hub). Visual proof for both themes via the dialog-shot harness. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
415f8a7ddb
commit
ebc668d28d
15 changed files with 1129 additions and 41 deletions
|
|
@ -19,8 +19,11 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||
import 'package:chain_studio_flow_editor/src/l10n.dart';
|
||||
import 'package:chain_studio_flow_editor/src/widgets/missing_modules_badge.dart';
|
||||
|
||||
import 'package:chain_studio/data/hub.dart' show StoreItem;
|
||||
import 'package:chain_studio/data/hub.dart'
|
||||
show ApprovalRecord, StoreItem, ThemeModeValue;
|
||||
import 'package:chain_studio/data/reviewer_identity.dart';
|
||||
import 'package:chain_studio/l10n/app_localizations.dart';
|
||||
import 'package:chain_studio/main.dart';
|
||||
import 'package:chain_studio/pages/federation.dart';
|
||||
import 'package:chain_studio/widgets/chain_install_confirm.dart';
|
||||
|
||||
|
|
@ -200,4 +203,63 @@ void main() {
|
|||
await _shot(tester, '$name-dark');
|
||||
});
|
||||
}
|
||||
|
||||
// Reviewer identity on the approvals inbox — the strip that names
|
||||
// who the audit trail will record and says, in plain words, what
|
||||
// that attribution is worth on this hub. Captured in both themes
|
||||
// because the "not verified" pill and the literal recorded value
|
||||
// have to stay legible in each (release gate, project CLAUDE.md).
|
||||
for (final (themeName, mode) in [
|
||||
('light', ThemeModeValue.light),
|
||||
('dark', ThemeModeValue.dark),
|
||||
]) {
|
||||
testWidgets('approvals reviewer identity — $themeName', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
ReviewerIdentity.debugHandle = 'stefan@studio';
|
||||
addTearDown(() => ReviewerIdentity.debugHandle = null);
|
||||
final fake = installFakeHub();
|
||||
fake.approvals = [
|
||||
ApprovalRecord(
|
||||
id: 'apr-1',
|
||||
flowName: 'rechnung-klassifizieren',
|
||||
stepId: 'pruefen',
|
||||
prompt: 'Bitte die Klassifikation dieser Rechnung bestätigen.',
|
||||
payloadPreview: '{"label":"Rechnung","betrag":"128,40 EUR"}',
|
||||
createdAt: DateTime.utc(2026, 7, 26, 12, 0, 0),
|
||||
expiresAt: null,
|
||||
status: 'pending',
|
||||
decidedAt: null,
|
||||
decidedBy: '',
|
||||
reason: '',
|
||||
project: 'buergeramt',
|
||||
flowExecution: 'run-abc123',
|
||||
),
|
||||
];
|
||||
tester.view.physicalSize = const Size(1280, 900);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
addTearDown(tester.view.reset);
|
||||
// The real app shell, not a bare MaterialApp: the strip has to
|
||||
// be judged inside the Chain theme it ships in.
|
||||
await tester.pumpWidget(
|
||||
RepaintBoundary(
|
||||
key: _shotKey,
|
||||
child: StudioApp(initialThemeMode: mode, initialLocale: Locale('de')),
|
||||
),
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tap(find.byKey(const ValueKey('sidebar-item-approvals')));
|
||||
for (var i = 0; i < 12; i++) {
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
}
|
||||
await _shot(tester, 'approvals-reviewer-identity-$themeName');
|
||||
expect(find.text('Sie entscheiden als'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Wird gespeichert als: unverified:stefan@studio'),
|
||||
findsOneWidget,
|
||||
);
|
||||
// Long-lived timers: unmount before the harness tears down.
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump(const Duration(minutes: 1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue