TenantAtlas/apps/platform/.pnpm-store/v10/files/97/bbf126b71a7341507267714429391fa1cd1599bb5dc0ec0eb52522d75252f40268ef0731e4ce7edaf52ab31dc248bcc7c69bc027b86bb8e00ea3d20d30fdd4
ahmido 1fec9c6f9d
Some checks failed
Main Confidence / confidence (push) Failing after 45s
feat: compress governance operator outcomes (#253)
## Summary
- introduce surface-aware compressed governance outcomes and reuse the shared truth/explanation seams for operator-first summaries
- apply the compressed outcome hierarchy across baseline, evidence, review, review-pack, canonical review/evidence, and artifact-oriented operation-run surfaces
- expand spec 214 fixtures and Pest coverage, and fix tenant-panel route assertions by generating explicit tenant-panel URLs in the affected Filament tests

## Validation
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- focused governance compression suite from `specs/214-governance-outcome-compression/quickstart.md` passed (`68` tests, `445` assertions)
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryItemResourceTest.php tests/Feature/Filament/BackupSetUiEnforcementTest.php tests/Feature/Filament/RestoreRunUiEnforcementTest.php` passed (`18` tests, `81` assertions)

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #253
2026-04-19 12:30:36 +00:00

63 lines
2.2 KiB
Plaintext

import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { createOperatorSubscriber } from './OperatorSubscriber';
/**
* A basic scan operation. This is used for `scan` and `reduce`.
* @param accumulator The accumulator to use
* @param seed The seed value for the state to accumulate
* @param hasSeed Whether or not a seed was provided
* @param emitOnNext Whether or not to emit the state on next
* @param emitBeforeComplete Whether or not to emit the before completion
*/
export function scanInternals<V, A, S>(
accumulator: (acc: V | A | S, value: V, index: number) => A,
seed: S,
hasSeed: boolean,
emitOnNext: boolean,
emitBeforeComplete?: undefined | true
) {
return (source: Observable<V>, subscriber: Subscriber<any>) => {
// Whether or not we have state yet. This will only be
// false before the first value arrives if we didn't get
// a seed value.
let hasState = hasSeed;
// The state that we're tracking, starting with the seed,
// if there is one, and then updated by the return value
// from the accumulator on each emission.
let state: any = seed;
// An index to pass to the accumulator function.
let index = 0;
// Subscribe to our source. All errors and completions are passed through.
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
// Always increment the index.
const i = index++;
// Set the state
state = hasState
? // We already have state, so we can get the new state from the accumulator
accumulator(state, value, i)
: // We didn't have state yet, a seed value was not provided, so
// we set the state to the first value, and mark that we have state now
((hasState = true), value);
// Maybe send it to the consumer.
emitOnNext && subscriber.next(state);
},
// If an onComplete was given, call it, otherwise
// just pass through the complete notification to the consumer.
emitBeforeComplete &&
(() => {
hasState && subscriber.next(state);
subscriber.complete();
})
)
);
};
}