Overview
| Artifact ID: | 64407a410f18216fb2f34bb01913f059fa025b689af5912e35548b3764dd9a3c |
|---|---|
| Page Name: | checkin/340fc2d952a2244242bd01bdbc3a32178cd8758953a39dbcf42d36c455e240d0 |
| Date: | 2026-11-24 19:03:12 |
| Original User: | dmestas |
| Mimetype: | text/x-markdown |
Content
/auth step 5 (#74): expiry, what is left with its age, keys from a command
Expiry
- New table
picu_credential_meta(name, expires_ms, expiry_source, value_hash, rotated_ms), keyed by the credential's health name. It is removed with the key, and cleared when the key gets a new value (pic_cred_login_as, a command key's new output). - Sources: OpenRouter's free check (
$.data.expires_at, throughpic_key_health.expires_ms), recorded asprovider; otherwiserecordedfrompic auth expires P[:L] DATE|Nd|never,--expiresonauth login --api-keyandauth import, RPCset_credential_expiry, oradd_credential'sexpires_at. A date alone means the end of that day, UTC. - Warnings, controlled by
keyExpiryWarnDays(default 7):-pandaskprint one stderr line for the key the request uses.- The TUI footer shows a red "! expires in N days".
- The /auth row puts the expiry first and is red once expired;
erecords a new date.
- The request still goes past the date, since a recorded date can be wrong. This differs from the proposal, which asks before sending.
pic auth status --expiring DAYSexits 1 when a key in use expires within DAYS.get_credentialsaddsexpires_at,days_left,expiry_source,expiredandrotated_at.
What is left
get_credentialscarriesleft {kind money|none, amount, currency, source check|reply, as_of, stale}.- /auth adds the reading's age ("checked 12 min ago", or "last known" after a day).
- Not done: reading rate-limit and ChatGPT plan headers from replies (the proposal's
rateandplan_windowkinds).
Keys from a command
- A new credential kind,
command. userdb's CHECK is widened and the table rebuilt once, the same waycredential_kindsadded oauth. pic auth login P [--as L] --command 'CMD'seals the command. No key is stored.- It runs through a new platform hook,
key_command: /bin/sh -c, first line of stdout, a 10-second limit, and the first line of stderr on failure. The value is held in memory for 5 minutes. - On a 401 or 403,
pic_cred_rerunruns the command again. A new value is sent once more; the same value is a real refusal. - A changed value (salted hash) forgets the key's health and expiry, and records
rotated_at. - A failing command stops the request with one line, with no fallback.
- RPC cannot add one.
Offline
Free checks already skip when offline is on; a test now covers it. Key commands run locally.
Tests
- New
test/pic/keyexpiry.sh(dev only). - An expiry case in test/tui/auth.sh.
- rpc.sh's settings count is now 37.
Tier: core (cred.c, platform.c/.h, userdb.c, provider_http.c), bundled (provider_chat.c, keyprobe.c), root (main.c), client (tui); no new file. Clock: vendor (expiry fields), os (the command). Record: picu_credential_meta; picu_credential kind command. Default: none recorded.