Skip to content

Commit ca83e00

Browse files
committed
test: expand logging skill decision and activation scenarios
1 parent 88fe103 commit ca83e00

5 files changed

Lines changed: 136 additions & 0 deletions

File tree

‎evals/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ These cases evaluate agent decisions separately from deterministic repository ch
44

55
For a complete generated HTTP application with before/after checks, see the [FastAPI demo](demo/README.md).
66

7+
## Decision coverage
8+
9+
Compare `event_contract` with `event_contract_discovery`: the former explicitly states the contract, while the latter leaves event consumers in the project for the agent to discover. `local_change_scope` checks whether a single-field request stays local and whether verification claims match the captured boundary. `wrapper_api` exercises a mapping-based facade rather than a standard logger API.
10+
11+
`indirect_context_activation` asks for correlation without naming logging or the skill. Together with `unrelated_python_with_logging` and `unrelated_cli`, it probes both missed activation and false positives. Inspect skill-load traces rather than inferring activation from the final code. These are unbenchmarked scenarios, not evidence of improved activation.
12+
713
## Run a case
814

915
1. Create a fresh temporary project and copy only the listed fixtures into it, keeping their basenames. Install any fixture dependencies in an isolated environment. Record initial file checksums.

‎evals/cases.json‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,77 @@
106106
"The solution checks exception text as well as structured fields.",
107107
"The record retains enough operation and error-type information to diagnose the failure."
108108
]
109+
},
110+
{
111+
"id": "event_contract_discovery",
112+
"should_trigger": true,
113+
"fixtures": [
114+
"evals/fixtures/service.py",
115+
"evals/fixtures/event_consumers.py"
116+
],
117+
"prompt": "Improve the invoice logs in service.py so successful charges include the amount.",
118+
"criteria": [
119+
"Both dotted event names remain unchanged; event_consumers.py remains unchanged.",
120+
"Rendered success events include invoice_id and amount_cents; completed_total returns the total for two successful charges.",
121+
"A negative charge still raises ValueError with the original message and produces one failure record; failed_invoices identifies its invoice.",
122+
"Function signatures and return values remain unchanged."
123+
]
124+
},
125+
{
126+
"id": "wrapper_api",
127+
"should_trigger": true,
128+
"fixtures": [
129+
"evals/fixtures/wrapped_service.py"
130+
],
131+
"prompt": "Add amount_cents to the invoice success event in wrapped_service.py.",
132+
"criteria": [
133+
"The existing EventLogger.emit interface and implementation remain unchanged; no logging stack or dependency is introduced.",
134+
"Calling process_invoice emits one JSON record on stderr with the original event, invoice_id and the supplied amount_cents, without API errors.",
135+
"Function signature and returned amount remain unchanged."
136+
]
137+
},
138+
{
139+
"id": "local_change_scope",
140+
"should_trigger": true,
141+
"fixtures": [
142+
"evals/fixtures/service.py"
143+
],
144+
"prompt": "Add amount_cents to the success log in service.py.",
145+
"criteria": [
146+
"The success event retains its name and invoice_id and includes amount_cents in captured formatted output.",
147+
"Production edits are confined to the success log; the failure path, charge implementation, signatures and return values remain unchanged.",
148+
"No production logging configuration, handlers, context management or dependencies are introduced; focused verification code is allowed.",
149+
"The final report identifies the formatter used for verification and does not claim full runtime safety from a representative formatter."
150+
]
151+
},
152+
{
153+
"id": "indirect_context_activation",
154+
"should_trigger": true,
155+
"fixtures": [
156+
"evals/fixtures/request_context.py"
157+
],
158+
"prompt": "In request_context.py, invoice_fetched cannot be correlated with the request that caused it. Fix this for overlapping requests and standalone calls.",
159+
"criteria": [
160+
"The skill is implicitly loaded without being named in the prompt.",
161+
"Overlapping requests each produce invoice_fetched and request_completed with their own request_id; event names remain unchanged.",
162+
"A subsequent standalone fetch_invoice in the same task has no stale request_id.",
163+
"Cleanup also occurs when fetch_invoice raises; the original exception propagates.",
164+
"Function signatures and successful return values remain unchanged."
165+
]
166+
},
167+
{
168+
"id": "unrelated_python_with_logging",
169+
"should_trigger": false,
170+
"fixtures": [
171+
"evals/fixtures/service.py"
172+
],
173+
"prompt": "Add parameter and return type annotations to charge and handle_invoice in service.py. Invoice IDs are strings and amounts are integer cents.",
174+
"criteria": [
175+
"The logging skill is not implicitly loaded.",
176+
"The requested functions have the corresponding str/int parameter annotations and int return annotations.",
177+
"Logging calls, events, fields and configuration remain unchanged; no dependencies are introduced.",
178+
"Return values and exception behavior remain unchanged."
179+
]
109180
}
110181
]
111182
}

‎evals/fixtures/event_consumers.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Local consumers of invoice events emitted by service.py."""
2+
3+
4+
def failed_invoices(events):
5+
return [event['invoice_id'] for event in events
6+
if event['event'] == 'invoice.charge.failed']
7+
8+
9+
def completed_total(events):
10+
return sum(event['amount_cents'] for event in events
11+
if event['event'] == 'invoice.charge.completed')

‎evals/fixtures/request_context.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import asyncio
2+
3+
import structlog
4+
5+
structlog.configure(processors=[
6+
structlog.contextvars.merge_contextvars,
7+
structlog.processors.JSONRenderer(),
8+
])
9+
logger = structlog.get_logger()
10+
11+
12+
async def fetch_invoice():
13+
await asyncio.sleep(0)
14+
structlog.get_logger().info('invoice_fetched')
15+
return 100
16+
17+
18+
async def handle_request(request_id):
19+
log = logger.bind(request_id=request_id)
20+
result = await fetch_invoice()
21+
log.info('request_completed')
22+
return result
23+
24+
25+
async def main():
26+
await asyncio.gather(handle_request('one'), handle_request('two'))
27+
await fetch_invoice()
28+
29+
30+
if __name__ == '__main__':
31+
asyncio.run(main())

‎evals/fixtures/wrapped_service.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import json
2+
import sys
3+
4+
5+
class EventLogger:
6+
"""Project facade: callers pass a mapping, not logging keyword arguments."""
7+
8+
def emit(self, level, event, fields):
9+
print(json.dumps({'level': level, 'event': event, **fields}), file=sys.stderr)
10+
11+
12+
logger = EventLogger()
13+
14+
15+
def process_invoice(invoice_id, amount_cents):
16+
logger.emit('info', 'invoice.processed', {'invoice_id': invoice_id})
17+
return amount_cents

0 commit comments

Comments
 (0)