9.4 KiB
Staged Changes Impact Review — Commit Decision Support
Goal
The user asked for a review of the currently staged changes to determine whether any functionality is lost compared to previous commits, and whether it is safe to commit.
Scope
- Base commit:
dfef0de(HEADofmainat review time). - Staged tree: the 16 paths listed by
git diff --cached. - Focus: public API surface preservation, behaviour preservation, and compliance with the performance-protection rules in
AGENTS.md.
Staged Files
.kilo/plans/4k-multilayer-psd-performance-regression.md
AGENTS.md
build.id
hcie-composite/src/tiled.rs
hcie-egui-app/crates/hcie-gui-egui/src/app/mod.rs
hcie-egui-app/crates/hcie-gui-egui/src/canvas/mod.rs
hcie-egui-app/crates/hcie-gui-egui/src/canvas/render.rs
hcie-engine-api/src/layer_property_ops.rs (new)
hcie-engine-api/src/lib.rs
hcie-engine-api/src/partial_composite.rs (new)
hcie-engine-api/src/stroke_brush.rs (new)
hcie-engine-api/src/stroke_cache.rs (new)
hcie-engine-api/tests/performance_stroke_4k.rs (new)
hcie-tile/src/lib.rs
logs/functional_regression_report.txt
unlock.sh
1. Public API Surface
The Engine public API in hcie-engine-api was extracted from the single monolithic lib.rs into four new internal modules (layer_property_ops, partial_composite, stroke_brush, stroke_cache). The modules are declared as mod, not pub mod, so the only public surface remains the items exported from lib.rs.
Comparison of public symbols (pub fn / pub struct / pub enum / pub use) between HEAD and the staged tree shows that the same set of public methods is still available, with one exception:
capture_canvas_png(&mut self) -> Option<String>is removed.- Search across the Rust source tree shows no live caller of this method (it only exists in the legacy backup tree
hcie-engine-api-orig/src_locked/lib.rs).
Therefore, no used public API is lost. The removed function appears to be dead code.
2. Behaviour / Feature Loss Analysis
2.1 hcie-engine-api/src/lib.rs refactor
- Large functions (
render_composite_region,get_composite_pixels,begin_stroke,end_stroke, stroke helpers, layer property setters) were moved into dedicated modules. - No logic changes observed in the moved code other than the performance improvements documented below.
Engine::newnow initializes the new fieldbelow_cache_dirty: true, which is consistent with starting from a clean state.
2.2 hcie-engine-api/src/stroke_cache.rs
begin_stroke/end_strokekeep the existingactive_stroke_maskpooling,stroke_beforeundo snapshot, andlast_stroke_boundssub-rect snapshot logic.- Introduces
rebuild_below_cache_if_needed, which reuses the existingbelow_cachebuffer when the active layer index and dimensions match. - This is an extension of the existing
below_cachemechanism, not a removal.
2.3 hcie-engine-api/src/partial_composite.rs
render_composite_regionandget_composite_pixelsstill follow the same sequence:- render dirty vector layers,
- apply dirty effects/styles,
- sync dirty tiles,
- composite into scratch/full buffer.
- The
composite_scratchbuffer is still pooled and reused. below_cachereuse now guarded bybelow_cache_dirty.
2.4 hcie-engine-api/src/layer_property_ops.rs
- Property changes that do not alter pixel data (
opacity,visibility,blend_mode,parent,move_layer,clipping_mask,set_active_layer, etc.) now:- set
document.composite_dirty = true, - set
document.dirty_bounds = full_canvas, - set
self.below_cache_dirty = true, - and no longer clear
tile_layers.
- set
- This directly implements the AGENTS.md rule "Tile cache over-clear removal".
- Structural changes (
add_layer,delete_layer,add_group,add_raw_layer,clear_all_layers,undo,redo,jump_to_history) still cleartile_layers, which is correct because the layer count/content changes.
Risk note: set_layer_parent previously called self.tile_layers.clear(); self.pre_tile_all_layers(). The new code keeps the tile cache. This is safe only if the compositor (hcie-composite/src/tiled.rs) evaluates parent/clip hierarchy at composite time. The base_indices pre-computation in tiled.rs confirms that clip/parent logic is applied during compositing, so tile pixel data does not need to be rebuilt.
2.5 hcie-composite/src/tiled.rs
- Adds
SEQUENTIAL_PIXEL_THRESHOLDand uses a sequential row loop for small dirty regions. Matches the AGENTS.md rule "Small-region sequential compositing". - Adds effects-cache reuse (
layer.effects_cache) before callingapply_layer_effects. Matches the AGENTS.md rule "Effects cache reuse". - Helper functions (
blend_adjustment_pixel,blend_tile_pixel,blend_dense_pixel) are pure refactoring; the blend math is unchanged.
2.6 hcie-tile/src/lib.rs
update_tiles_in_regionnow writes only the intersecting sub-rectangle into an existing tile instead of replacing the whole tile. Matches the AGENTS.md rule "Incremental tile update".- Empty tiles are dropped only after verifying no remaining content.
- Logic is more conservative than the previous version (less data discarded), so no pixel content should be lost.
2.7 GUI changes
hcie-egui-app/crates/hcie-gui-egui/src/canvas/render.rs: addsSelectionEdgeCacheandextract_selection_edges. The previous inline edge-extraction loop is replaced by a cached version that is keyed by the mask buffer pointer/length. No engine API change; pure GUI optimisation.hcie-egui-app/crates/hcie-gui-egui/src/canvas/mod.rs: pointer-event downsampling for brush strokes (only forwards events when distance exceeds a spacing threshold). GUI-side performance improvement.hcie-egui-app/crates/hcie-gui-egui/src/app/mod.rs: addsselection_edge_cachefield and resets it when the document is replaced.
These changes do not touch engine API usage except for passing &mut selection_edge_cache to the overlay renderer.
2.8 Documentation / metadata
AGENTS.mdrewritten for v4 terminology and expanded with the performance-protection table. No code impact.build.id,unlock.sh,logs/functional_regression_report.txt: metadata/build helper updates.- New plan file:
.kilo/plans/4k-multilayer-psd-performance-regression.md.
3. Potential Risks / Open Items
-
below_cache_dirtyconsistency. The new flag is set totrueinEngine::newand on every non-structural property change. It is reset tofalseafter a successful cache build or when no cache is needed. This logic appears consistent, but because it is new state, any missed setter that should invalidate it could cause stale composites. The staged code invalidates it in all observed property setters. -
Effects cache path in
tiled.rs. Whenlayer.effects_cacheexists and matches layer dimensions, the compositor usescached.rendered.clone(). This introduces an extra buffer clone. The AGENTS.md rule states this is intended to avoid re-running the expensive effects pipeline. The clone cost is expected to be lower thanapply_layer_effects, but this should be verified with the performance test. -
GUI downsampling. The pointer-event spacing in
canvas/mod.rsmay subtly change the density of brush stamps for fast movements. This is a GUI-side change and does not affect engine correctness, but it could affect perceived stroke quality for some brush styles.
4. Performance-Protection Compliance
Mechanism from AGENTS.md |
Status in staged changes |
|---|---|
active_stroke_mask pooling |
Preserved in stroke_cache.rs |
composite_scratch pooling |
Preserved in partial_composite.rs |
below_cache + below_cache_dirty |
Extended with explicit below_cache_dirty flag |
Conditional effects_dirty set |
Preserved in stroke_brush.rs |
| Tile cache over-clear removal | Implemented in layer_property_ops.rs |
| Small-region sequential compositing | Implemented in hcie-composite/src/tiled.rs |
| Effects cache reuse | Implemented in hcie-composite/src/tiled.rs |
| Incremental tile update | Implemented in hcie-tile/src/lib.rs |
5. Recommended Validation Before Commit
Because this is a plan-only review and no build/test commands were executed, the following tests should pass before the user commits:
# Core engine regression tests
cargo test -p hcie-composite
cargo test -p hcie-tile
cargo test -p hcie-engine-api --test visual_regression
# Performance smoke test (non-gating, but useful for before/after numbers)
cargo test -p hcie-engine-api --test performance_stroke_4k -- --nocapture
# Ensure the workspace still compiles
cargo check -p hcie-engine-api
cargo check -p hcie-egui-app/crates/hcie-gui-egui
6. Conclusion
- No used public API is removed. The only removed symbol,
capture_canvas_png, is dead code in the current tree. - No obvious feature loss. The changes are structural refactoring plus performance improvements.
- Performance-protection rules are honoured, not bypassed. Several rules are newly implemented or strengthened.
- Commit recommendation: Proceed, after running the regression tests above and confirming a clean build.
- If the tests fail, the failures should be fixed before committing; the pre-commit hook already blocks commits that touch high-risk crates without manual review.