Skip to content

Commit 7efac92

Browse files
committed
fix(v10.2): Memory ownership fix for gen_cmd + spec format cleanup
- gen_cmd.zig: Don't free source that spec now owns via source_content - spec.deinit() will handle cleanup - Fixes use-after-free bug - batch_processing.vibee: Fix indentation in implementation blocks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 64a3ed2 commit 7efac92

2 files changed

Lines changed: 34 additions & 25 deletions

File tree

specs/tri/batch_processing.vibee

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ behaviors:
3636
when: New chat completion request received
3737
then: Add to request queue, return immediately
3838
implementation: |
39-
pub fn enqueue_request(self: *@This(), req: BatchRequest) !void {
40-
// Add to request queue with timestamp
41-
_ = self;
42-
_ = req;
43-
// In real implementation: queue.append(req) with mutex lock
44-
// For now: simple stub that compiles
45-
}
39+
pub fn enqueue_request(self: *@This(), req: BatchRequest) !void {
40+
// Add to request queue with timestamp
41+
_ = self;
42+
_ = req;
43+
// In real implementation: queue.append(req) with mutex lock
44+
// For now: simple stub that compiles
45+
}
46+
47+
4648

4749

4850

@@ -51,12 +53,14 @@ behaviors:
5153
when: Batch timeout or max_batch_size reached
5254
then: Return array of BatchRequest up to max_batch_size
5355
implementation: |
54-
pub fn dequeue_batch(self: *@This()) []BatchRequest {
55-
// Return batch of up to max_batch_size requests
56-
_ = self;
57-
// In real implementation: return queue items[0..max_batch_size]
58-
return &[_]BatchRequest{};
59-
}
56+
pub fn dequeue_batch(self: *@This()) []BatchRequest {
57+
// Return batch of up to max_batch_size requests
58+
_ = self;
59+
// In real implementation: return queue items[0..max_batch_size]
60+
return &[_]BatchRequest{};
61+
}
62+
63+
6064

6165

6266

@@ -70,11 +74,13 @@ behaviors:
7074
when: Generation complete
7175
then: Send HTTP response to client
7276
implementation: |
73-
pub fn send_response(resp: BatchResponse) !void {
74-
// Send HTTP response with JSON body
75-
_ = resp;
76-
// In real implementation: write to connection stream
77-
}
77+
pub fn send_response(resp: BatchResponse) !void {
78+
// Send HTTP response with JSON body
79+
_ = resp;
80+
// In real implementation: write to connection stream
81+
}
82+
83+
7884

7985

8086

@@ -88,11 +94,13 @@ behaviors:
8894
when: Configuration update requested
8995
then: Update batching parameters
9096
implementation: |
91-
pub fn configure_batching(self: *@This(), config: BatchConfig) void {
92-
// Update batching parameters
93-
_ = config;
94-
self.max_batch_size = 4; // Default
95-
// In real implementation: self.config = config
96-
}
97+
pub fn configure_batching(self: *@This(), config: BatchConfig) void {
98+
// Update batching parameters
99+
_ = config;
100+
self.max_batch_size = 4; // Default
101+
// In real implementation: self.config = config
102+
}
103+
104+
97105

98106

src/vibeec/gen_cmd.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ fn generateCode(allocator: std.mem.Allocator, input_path: []const u8, output_pat
229229
defer file.close();
230230

231231
const source = try file.readToEndAlloc(allocator, 1024 * 1024);
232-
defer allocator.free(source);
232+
// Note: source is now owned by the spec via spec.source_content
233+
// Don't free here - spec.deinit() will handle it
233234

234235
var parser = vibee_parser.VibeeParser.init(allocator, source);
235236
var spec = try parser.parse();

0 commit comments

Comments
 (0)