Logging

The rule: every change adds logs. If your change does something, decides something or can fail, it writes a record of it. A change with no new log line or audit event is not done.

Why: AI agents review what the assistant did (Audit and reports). They can only fix what they can see.

Where logs go today

The server has no logging library. It writes in four places:

PlaceWhat goes thereCode
audit_events tableThings that happened: a job fired, a place crossed, a phone batch came incrate::audit::event(app, "kind", json!({...})) in src/audit.rs
model_calls tableEach model step: model, profile, request, reply, tokens, timecrate::audit::record(...), called from src/engine.rs
actions tableEach tool call, its arguments, result and the gate's decisionengine::log_action and engine::finish_action
stderrStart-up, config problems, a service that is downeprintln!, read with journalctl (Deploy)

All four are per account, inside the account's encrypted database (stderr aside). All but stderr pass through util::scrub.

Which one to use

What to log

KindLog it whenExample kind name
ActionThe assistant does something on its ownjob.fired, travel.alert
ErrorSomething fails, even if you retrydetect.gym with error
DecisionThe code picks one path over another, like skip or senddetect.leave_home with notice: false
Model callAny model callmodel_calls row
TimingSomething can be slow: a model call, a sync, a sweepms field
Data inA batch arrives from the phonephone.location with kept, skipped

Log skips, not just sends. "Did not send because quiet hours" is what a reviewer needs most.

Kind names and fields

crate::audit::event(app, "detect.gym", json!({ "visit": visit, "logged": false, "notice": sent }));

Levels

audit_events has no level. The kind and the fields say what matters. Use these words in eprintln! lines:

LevelUse for
errorThe server cannot do its job: start-up failed, database locked
warnA part is off but the rest works: search by meaning off, retry later
infoA normal, rare event: the database was moved, a token was made

No debug spam. A line that fires every second is noise; count it instead.

Never log

util::scrub masks known secrets and common key shapes. It is a safety net, not a licence. Do not log a secret and hope scrub catches it.

The app

The Android app has no logs today: no Log.d calls. That is a gap. Rules for new app code:

Ties to the audit trail

Logs written with audit::event show up in the review pack (GET /v1/audit/review). So a good kind name and clear fields make the review pack better. The planned Full activity log builds on this same table.

Check