Sibar
Interactive Demo

Demo Scenario: An agent attempted to modify core authentication logic. Review the execution trace and cryptographic receipt below.

Context

Notes: send explicit done state and optimistic toggle

4 files+22-22
-18,10โ†’+18,14
1818 return response.json();
1919 }
2020
21-export async function toggleNote(id: number): Promise<Note> {
21+export async function toggleNote(id: number, done: boolean): Promise<void> {
2222 const response = await fetch(`${API_URL}/notes/${id}/toggle`, {
2323 method: 'PATCH',
24+ headers: { 'Content-Type': 'application/json' },
25+ body: JSON.stringify({ done }),
2426 });
2527 if (!response.ok) {
2628 throw new Error('Failed to toggle note');
2729 }
28- return response.json();
2930 }
-37,11โ†’+37,22
3737 }
3838 };
3939
40- const handleToggle = async (id: number) => {
40+ const handleToggle = async (id: number, nextDone: boolean) => {
41+ setNotes((prev) =>
42+ prev.map((note) =>
43+ note.id === id ? { ...note, done: nextDone } : note
44+ )
45+ );
4146 try {
42- await toggleNote(id);
43- loadNotes();
47+ await toggleNote(id, nextDone);
4448 } catch (err) {
4549 setError('Failed to toggle note');
50+ loadNotes();
4651 }
4752 };
-74,7โ†’+85,7
7485 <label>
7586 <input
7687 type="checkbox"
77- checked={note.done}
78- onChange={() => handleToggle(note.id)}
88+ checked={note.done}
89+ onChange={() => handleToggle(note.id, !note.done)}
7990 />
8091 Done
8192 </label>
-10,6โ†’+10,10
1010 pass
1111
1212
13+class NoteToggle(BaseModel):
14+ done: bool
15+
16+
1317 class Note(NoteBase):
1418 id: int
-3,7โ†’+3,7
33 from fastapi.middleware.cors import CORSMiddleware
44 from typing import List
55 from contextlib import asynccontextmanager
66
7-from models import Note, NoteCreate
7+from models import Note, NoteCreate, NoteToggle
88 from database import init_db, get_db_connection
-47,20โ†’+47,14
4747 return Note(
4848 id=row["id"],
4949 title=row["title"],
5050 content=row["content"],
5151 done=bool(row["done"]),
5252 )
5353
5454
55-@app.patch("/notes/{note_id}/toggle", response_model=Note)
56-async def toggle_note(note_id: int):
55+@app.patch("/notes/{note_id}/toggle", status_code=204)
56+async def toggle_note(note_id: int, payload: NoteToggle):
5757 with get_db_connection() as conn:
58- cursor = conn.execute(
59- "SELECT id, title, content, done FROM notes WHERE id = ?", (note_id,)
60- )
61- row = cursor.fetchone()
62- if not row:
63- raise HTTPException(status_code=404, detail="Note not found")
64-
65- new_done = not bool(row["done"])
66- conn.execute("UPDATE notes SET done = ? WHERE id = ?", (int(new_done), note_id))
58+ conn.execute("UPDATE notes SET done = ? WHERE id = ?", (int(payload.done), note_id))
6759 conn.commit()
68- return Note(
69- id=row["id"], title=row["title"], content=row["content"], done=new_done
70- )
60+ return None

MERGE GATE

Status: CLOSED

This change cannot be merged until all conditions are met.

MERGE CONDITIONS

[โ€”]Questions answered
[โ€”]Owner declared
[โ€”]Risk acknowledged
[โ€”]Verdict allows merge

Decision Checkpoint

PR

Notes: send explicit done state and optimistic toggle

4 Archivos+22-22

Senales detectadas

api_contract ยท optimistic_ui ยท state_transition ยท validation ยท error_handling