Overview
| Comment: | Key expiry, what is left with its age, keys from a command (#74) |
|---|---|
| Timelines: | family | ancestors | descendants | both | auth-5 |
| Files: | files | file ages | folders |
| SHA3-256: |
340fc2d952a2244242bd01bdbc3a3217 |
| User & Date: | dmestas on 2026-11-24 19:02:50.511 |
| Other Links: | branch diff | manifest | tags |
/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.
Context
|
2026-11-24
| ||
| 19:12 | Settings test lists keyExpiryWarnDays check-in: 2235576c3c user: dmestas tags: auth-5 | |
| 19:02 | Key expiry, what is left with its age, keys from a command (#74) check-in: 340fc2d952 user: dmestas tags: auth-5 | |
| 18:25 | Create new branch named "auth-5" check-in: 5d564e2228 user: dmestas tags: auth-5 | |
Changes
Modified CHANGELOG.md
from [a8c73ef644]
to [9b2113f828].
[diff]
Modified Makefile
from [dca538dc47]
to [735c8f465c].
[diff]
Modified docs/manual/auth.md
from [2f984e363b]
to [73de244c8f].
[diff]
Modified docs/manual/named-keys.md
from [da731b7dce]
to [3dd50c7a10].
[diff]
Modified docs/reference/cli.md
from [9ffa0610d6]
to [3b51cd2920].
[diff]
Modified docs/reference/rpc-commands.md
from [f04734f356]
to [3123e14c1f].
[diff]
Modified docs/reference/settings.md
from [8f9d3f20e5]
to [ee65704399].
[diff]
Modified src/cred.c
from [e595dfbe0e]
to [8b72c06c91].
[diff]
Modified src/cred.h
from [de993f2d39]
to [ee6b0d2198].
[diff]
Modified src/keyprobe.c
from [f1abff8442]
to [626fdebf8d].
[diff]
Modified src/main.c
from [0e05966000]
to [480038666f].
[diff]
Modified src/platform.c
from [00de636437]
to [c2ae1bd2a3].
[diff]
Modified src/platform.h
from [190e8f25d7]
to [6a88f16950].
[diff]
Modified src/provider_chat.c
from [117e559460]
to [198d3bc198].
[diff]
Modified src/provider_http.c
from [c87228b6f3]
to [b4e8ee6064].
[diff]
Modified src/settings.c
from [730227074f]
to [8584387f49].
[diff]
Modified src/tui/app.c
from [27330de84c]
to [380cfebd6a].
[diff]
Modified src/userdb.c
from [016e57d051]
to [b09696d152].
[diff]
Added test/pic/keyexpiry.sh version [f4d773ee3f].
Modified test/pic/rpc.sh
from [eb31380447]
to [6f1faa5a41].
[diff]
Modified test/tui/auth.sh
from [46eb7cc934]
to [46e04f3488].
[diff]