Merge branch 'codex/simp-drop-assembled-section-order' into codex/simp-drop-unused-schema-default
This commit is contained in:
@@ -196,31 +196,18 @@ export function foldSurface(events: readonly SessionEvent[]): SurfaceFoldResult
|
|||||||
export class SurfaceManager {
|
export class SurfaceManager {
|
||||||
/** Incremental state shared with the complete surface fold. */
|
/** Incremental state shared with the complete surface fold. */
|
||||||
private _state = createFoldState()
|
private _state = createFoldState()
|
||||||
/** The last processed seq. -1 forces a full rebuild on first access. */
|
/** The last processed seq. -1 forces the initial full fold. */
|
||||||
private _lastProcessedSeq = -1
|
private _lastProcessedSeq = -1
|
||||||
|
|
||||||
constructor(private log: readonly SessionEvent[]) {}
|
constructor(private log: readonly SessionEvent[]) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset to unprocessed state. Call after the log has been replaced
|
* The surface's rewrite generation, bumped by every folded `replace` op. A
|
||||||
* wholesale (e.g. after Session seed). Not needed for normal appends —
|
* replace is the ONE operation that rewrites the surface non-monotonically,
|
||||||
* those are picked up incrementally.
|
* so an incremental consumer of {@link nodes} (the session's derived-message
|
||||||
*/
|
* cache) compares this between visits — an unchanged generation guarantees
|
||||||
invalidate(): void {
|
* every unseen node is a pure tail append; a changed one means its view must
|
||||||
this._lastProcessedSeq = -1
|
* rebuild.
|
||||||
// A wholesale rebuild is a rewrite: bump the generation so incremental
|
|
||||||
// consumers (the session's derived-message cache) discard their view.
|
|
||||||
this._state = createFoldState(this._state.replaceGeneration + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The surface's rewrite generation: bumped by every folded `replace` op and
|
|
||||||
* by {@link invalidate}. A replace is the ONE operation that rewrites the
|
|
||||||
* surface non-monotonically, so an incremental consumer of {@link nodes}
|
|
||||||
* (the session's derived-message cache) compares this between visits — an
|
|
||||||
* unchanged generation guarantees every node it has not seen is a pure tail
|
|
||||||
* append; a changed one means its view must rebuild. Monotonic: it never
|
|
||||||
* moves backwards, so comparisons cannot be fooled by a re-fold.
|
|
||||||
*/
|
*/
|
||||||
get replaceGeneration(): number {
|
get replaceGeneration(): number {
|
||||||
if (this._lastProcessedSeq < this.log.length - 1) this._processDelta()
|
if (this._lastProcessedSeq < this.log.length - 1) this._processDelta()
|
||||||
|
|||||||
Reference in New Issue
Block a user