Skip to content

Commit 97ded87

Browse files
AnneKoziolekclaude
andcommitted
Update documentation for native bytecode interception
README.md: - Add native bytecode interception as a constraint collection approach (DUP+void-record strategy, --interception flag) - Update project structure to include interception files (InterceptionPathUtils, PathConstraintAPI, GalettePathConstraintBridge) - Add native interception section to Architecture Components - Update Limitations (filtering needs refinement) and Future Work - Add --interception to Quick Start examples CLASS_ORIGINS.md: - Add COCOPATH_INTERCEPTION origin category - Document InterceptionPathUtils, PathConstraintAPI, GalettePathConstraintBridge, and GaletteAgent modifications Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 53f865c commit 97ded87

2 files changed

Lines changed: 77 additions & 35 deletions

File tree

CLASS_ORIGINS.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@ This document records the architectural history of CocoPath by classifying each
1111
| **KNARR_ORIGINAL** | Original Knarr class from [gmu-swe/knarr](https://github.com/gmu-swe/knarr) (uses Phosphor imports) |
1212
| **KNARR_GALETTE** | New class integrating Knarr concepts with Galette APIs (replaces Phosphor with Galette) |
1313
| **COCOPATH_VITRUVIUS** | New class for Vitruvius reactions tracking use case |
14+
| **COCOPATH_INTERCEPTION** | New class for native bytecode interception of comparisons |
1415

1516
---
1617

1718
## galette-agent Module
1819

20+
### edu.neu.ccs.prl.galette (public API)
21+
| Class | Origin | Notes |
22+
|-------|--------|-------|
23+
| PathConstraintAPI.java | COCOPATH_INTERCEPTION | Reflection-based access to interception constraints |
24+
25+
### edu.neu.ccs.prl.galette.interception
26+
| Class | Origin | Notes |
27+
|-------|--------|-------|
28+
| InterceptionPathUtils.java | COCOPATH_INTERCEPTION | Thread-safe constraint recording; in non-module package for bootclasspath loading |
29+
1930
### edu.neu.ccs.prl.galette.internal.agent
2031
| Class | Origin | Notes |
2132
|-------|--------|-------|
22-
| GaletteAgent.java | GALETTE_ORIGINAL | JVM agent entry point |
33+
| GaletteAgent.java | GALETTE_ORIGINAL (modified) | Added ComparisonInterceptionTransformer as second-pass bytecode transformer |
2334

2435
### edu.neu.ccs.prl.galette.internal.patch
2536
| Class | Origin | Notes |
@@ -212,6 +223,7 @@ All test classes are **GALETTE_ORIGINAL**.
212223
| **StringSymbolicTracker.java** | **KNARR_GALETTE** | String symbolic tracking |
213224
| **SymbolicComparison.java** | **COCOPATH_VITRUVIUS** | Vitruvius-specific constraint collection |
214225
| **Z3ConstraintSolver.java** | **KNARR_GALETTE** | Z3 SMT solver integration |
226+
| **GalettePathConstraintBridge.java** | **COCOPATH_INTERCEPTION** | Bridges native interception constraints to Green expressions |
215227

216228
### edu.neu.ccs.prl.galette.concolic.knarr.compat
217229
| Class | Origin | Notes |

README.md

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,54 +63,82 @@ The framework provides **concolic execution** (combined concrete + symbolic exec
6363
- **Key Classes**:
6464
- `GaletteSymbolicator` - Creates and manages symbolic values with tag reuse
6565
- `PathExplorer` - Orchestrates systematic path exploration
66-
- `PathUtils` - Manages path conditions and constraints
67-
- `SymbolicComparison` - Records constraints from Vitruvius reactions
66+
- `PathUtils` - Manages path conditions and constraints (incl. native interception merge)
67+
- `GalettePathConstraintBridge` - Bridges native interception constraints to Green expressions
68+
- `SymbolicComparison` - Records constraints from Vitruvius reactions (explicit mode)
6869
- `Z3ConstraintSolver` - Interfaces with Z3 for constraint solving
6970

71+
#### Native Bytecode Interception (galette-agent)
72+
- **Purpose**: Automatic constraint collection from comparison bytecodes
73+
- **Location**: `galette-agent/src/main/java/edu/neu/ccs/prl/galette/`
74+
- **Key Classes**:
75+
- `GaletteAgent.ComparisonInterceptionTransformer` - Second-pass bytecode transformer
76+
- `InterceptionPathUtils` - Thread-safe constraint recording (non-module package)
77+
- `PathConstraintAPI` - Reflection-based access to interception constraints
78+
7079
#### Vitruvius Integration
7180
- **Purpose**: Provides real-world model transformation scenarios
7281
- **Example**: AMALTHEA ↔ ASCET model synchronization
7382
- **Location**: `amalthea-acset-integration/`
7483
- Consistency preservation rules require user decisions that cannot be resolved automatically
7584

76-
### Constraint Collection Approach
85+
### Constraint Collection Approaches
86+
87+
CoCoPath supports two constraint collection modes:
7788

78-
CoCoPath employs a **CPR-level constraint registration mechanism** that makes decision semantics explicit at the transformation logic level:
89+
#### 1. Explicit Constraint Registration (default)
90+
Reactions explicitly call constraint recording methods:
91+
1. **Symbolic Variable Registration**: `GaletteSymbolicator.getOrMakeSymbolicInt()` creates/reuses symbolic tags
92+
2. **Constraint Recording**: `SymbolicComparison.symbolicVitruviusChoice()` records path constraints
93+
3. **Tag Reuse**: Qualified names enable tag reuse across iterations
7994

80-
1. **Symbolic Variable Registration**: Vitruvius reactions call `GaletteSymbolicator.getOrMakeSymbolicInt()` to create or reuse symbolic tags
81-
2. **Constraint Recording**: Reactions invoke `SymbolicComparison.symbolicVitruviusChoice()` to record path constraints
82-
3. **Tag Reuse**: Qualified names (e.g., "CreateAscetTaskRoutine:execute:userChoice_forTask_task1") enable tag reuse across iterations
95+
#### 2. Native Bytecode Interception (`--interception` flag)
96+
Automatically intercepts comparison bytecodes in reaction classes without explicit constraint calls:
97+
1. A second-pass `ClassFileTransformer` observes `IF_ICMP*` and `IFEQ/IFLT/IFGE/IFGT/IFLE/IFNE` bytecodes
98+
2. Uses a **DUP + void-record** strategy: duplicates comparison operands, records them via `InterceptionPathUtils.recordIcmp()`, then executes the original comparison unchanged
99+
3. Constraints are bridged to Green expressions via `GalettePathConstraintBridge`
100+
4. `PathUtils.getCurPCWithNativeConstraints()` merges native constraints with any explicit constraints
83101

84-
This approach prioritizes framework compatibility and reliability over full automation, avoiding bytecode verification issues while maintaining systematic path exploration capabilities.
102+
This approach preserves the original bytecode stack layout (no frame invalidation) and avoids classloader deadlocks by using `ClassWriter(cr, 0)` without frame recomputation.
103+
104+
Run with:
105+
```bash
106+
./run-symbolic-execution-adapted.sh --brake --interception
107+
```
85108

86109
## Project Structure
87110

88111
```
89112
CocoPath/
90-
├── knarr-runtime/
91-
│ ├── src/main/java/
92-
│ │ └── edu/neu/ccs/prl/galette/
93-
│ │ ├── concolic/knarr/runtime/
94-
│ │ │ ├── GaletteSymbolicator.java # Symbolic value creation with tag reuse
95-
│ │ │ ├── PathExplorer.java # Systematic path exploration
96-
│ │ │ ├── PathUtils.java # Path constraint management
97-
│ │ │ ├── SymbolicComparison.java # Constraint recording from reactions
98-
│ │ │ └── Z3ConstraintSolver.java # Z3 SMT solver integration
99-
│ │ └── vitruvius/
100-
│ │ ├── AutomaticVitruvPathExploration.java # Single-variable exploration
101-
│ │ └── AutomaticVitruvMultiVarPathExploration.java # Multi-variable exploration
102-
│ └── run-symbolic-execution-adapted.sh # Execution scripts
103-
104-
├── amalthea-acset-integration/ # AMALTHEA-ASCET case study
105-
│ ├── vsum/src/main/java/.../Test.java # Model transformation entry point
106-
│ └── consistency/src/main/reactions/ # Consistency preservation rules
113+
├── galette-agent/ # Galette bytecode instrumentation agent
114+
│ └── src/main/java/edu/neu/ccs/prl/galette/
115+
│ ├── PathConstraintAPI.java # Public API for interception constraints
116+
│ ├── interception/
117+
│ │ └── InterceptionPathUtils.java # Constraint recording (non-module package)
118+
│ └── internal/
119+
│ ├── agent/GaletteAgent.java # Agent entry + interception transformer
120+
│ ├── patch/Patcher.java # JAR patching for jlink
121+
│ └── transform/GaletteTransformer.java # First-pass bytecode transformer
107122
108-
├── tinybrake-integration/ # BrakeDisc-ControlSystem case study
109-
│ ├── model/ # BrakeSystem / ControlSystem metamodels
110-
│ ├── consistency/src/main/reactions/ # CPRs for brake-to-control mapping
111-
│ └── vsum/ # VSUM configuration and test entry points
123+
├── knarr-runtime/ # Symbolic execution runtime
124+
│ ├── src/main/java/edu/neu/ccs/prl/galette/
125+
│ │ ├── concolic/knarr/runtime/
126+
│ │ │ ├── GaletteSymbolicator.java # Symbolic value creation with tag reuse
127+
│ │ │ ├── GalettePathConstraintBridge.java # Native constraint → Green expression bridge
128+
│ │ │ ├── PathExplorer.java # Systematic path exploration
129+
│ │ │ ├── PathUtils.java # Path constraint management
130+
│ │ │ ├── SymbolicComparison.java # Explicit constraint recording
131+
│ │ │ └── Z3ConstraintSolver.java # Z3 SMT solver integration
132+
│ │ └── vitruvius/
133+
│ │ └── AutomaticBrakePathExploration.java # Brake case study exploration
134+
│ ├── src/test/java/.../
135+
│ │ ├── NativeInterceptionExplorationTest.java # End-to-end interception test
136+
│ │ └── testexamples/SimpleReaction.java # Test reaction for interception
137+
│ └── run-symbolic-execution-adapted.sh # Main execution script
112138
113-
└── README.md # This file
139+
├── amalthea-acset-integration/ # AMALTHEA-ASCET case study
140+
├── tinybrake-integration/ # BrakeDisc-ControlSystem case study
141+
└── README.md
114142
```
115143

116144
## Running CoCoPath
@@ -163,7 +191,8 @@ cd knarr-runtime
163191
./run-symbolic-execution-adapted.sh --external # Full Vitruvius transformations (external Amalthea-acset repo)
164192
./run-symbolic-execution-adapted.sh --multivar # Multi-variable AMALTHEA exploration (25 paths)
165193
./run-symbolic-execution-adapted.sh --brake # BrakeDisc-ControlSystem, single disc (10 paths)
166-
./run-symbolic-execution-adapted.sh --brake-multivar # BrakeDisc-ControlSystem, two discs
194+
./run-symbolic-execution-adapted.sh --brake --interception # Same, with native bytecode interception
195+
./run-symbolic-execution-adapted.sh --brake-multivar # BrakeDisc-ControlSystem, two discs
167196
```
168197

169198
**Windows:**
@@ -407,14 +436,15 @@ Based on the ECMFA-20 paper evaluation:
407436

408437
## Limitations
409438

410-
- **Manual Constraint Registration**: Requires explicit constraint recording in CPRs (future work: automatic weaving)
439+
- **Native Interception Filtering**: The `--interception` mode currently captures all comparisons in `mir/` classes (including framework bookkeeping), producing more constraints than needed. Constraint filtering needs refinement to only retain comparisons involving symbolic variables.
440+
- **Domain Constraints**: Must be manually specified based on domain knowledge
411441
- **Third-party Libraries**: Cannot track decisions in external code
412442
- **Runtime Overhead**: Dynamic taint tracking introduces performance cost
413-
- **Domain Constraints**: Must be manually specified based on domain knowledge
443+
- **jlink Compatibility**: The `galette-instrument` module must be built from a clean `galette-agent` (without interception modifications). The runtime agent adds interception support separately.
414444

415445
## Future Work
416446

417-
- Bytecode-level constraint extraction for full automation
447+
- Improve native interception constraint filtering to match explicit registration accuracy (10 vs 5 paths currently)
418448
- Support for additional transformation frameworks beyond Vitruvius
419449
- Optimization of taint tracking overhead
420450
- Integration with model verification techniques

0 commit comments

Comments
 (0)