Title: mcpx: one convention for renewing TTLs -- touch-on-read, not a renew endpoint per resource · Issue #1884 · developing-today/code · GitHub
Open Graph Title: mcpx: one convention for renewing TTLs -- touch-on-read, not a renew endpoint per resource · Issue #1884 · developing-today/code
X Title: mcpx: one convention for renewing TTLs -- touch-on-read, not a renew endpoint per resource · Issue #1884 · developing-today/code
Description: Relocated from dezren39/darwin-nix#87 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix...
Open Graph Description: Relocated from dezren39/darwin-nix#87 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue reference...
X Description: Relocated from dezren39/darwin-nix#87 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue refer...
Opengraph URL: https://github.com/developing-today/code/issues/1884
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: one convention for renewing TTLs -- touch-on-read, not a renew endpoint per resource","articleBody":"Relocated from dezren39/nix#87 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).\n\nParent: #174\n\n## Summary\n\nmcpx has at least seven TTLs across five subsystems, and **none of them can be renewed**. Every one is\nabsolute from creation, so a caller that is still working, still watching, or still waiting for a person\nloses the thing anyway. The fix should be one convention applied everywhere, not a `renew` endpoint per\nresource type.\n\n## Original notes\n\n> - elicit/prompt/session/attachment/mcp/etc renew ttl\n\n## Current state (what mcpx does today, with file refs)\n\n| resource | setting | default | how the deadline is computed | renewable |\n| --- | --- | --- | --- | --- |\n| elicitation question | `elicit.ttl` (a built-in default, **not** a registry setting -- see below) | **120s** | `ExpiresAt = Created + ttl` (`internal/elicit/elicit.go:206`; also `internal/daemon/hooks.go:145,198`) | no |\n| task result | `tasks.ttl`, per-task `ttl` in ms | 10m | `time.AfterFunc(ttl, …)` armed once at `Start` (`internal/tasks/tasks.go:104-147`) | no |\n| artifact | `artifacts.ttl`, per-put override | 24h | `Expires: now.Add(ttl)` (`internal/artifacts/artifacts.go:303-317`) | no |\n| interruptible call (`/v1/ask`) | `proto.askTTL` | 15m | absolute (`internal/settings/proto.go:66`) | no |\n| resumable request state | `proto.stateTTL` | 30m | absolute (`internal/settings/proto.go:72`) | no |\n| pool lease / session | `daemon.leaseTTL` | 30m | **idle** — \"after this long with no request the lease is forgotten\" (`internal/settings/wire.go:292-297`) | implicitly, by using it |\n| MCP session | `proto.sessionIdle` | 30m | idle | implicitly |\n| the daemon itself | `daemon.idleExit` / `autostart.idleExit` | 0s / 4h | idle, stamped at request *start*, and held off while any instance is live (`internal/daemon/server.go:344-368`) | implicitly |\n\nSo there are already **two families** in the codebase, with no rule about which a new resource joins:\n\n- **Absolute-from-creation**: elicit, tasks, artifacts, ask, proto state. Cannot be extended by anything.\n- **Idle / last-touch**: leases, MCP sessions, the daemon. Extended automatically by use, and nobody had\n to design a renewal API for them because *using the thing is the renewal*.\n\n**`elicit.ttl` is not a setting** (verified at 05c78b2). It is `elicit.ttl` in `internal/defaults/defaults.json:63`,\nread as `defaults.ElicitTTL` (`internal/defaults/defaults.go:350`); no registry entry declares it, so no config\nkey, `MCPX_*` variable or flag reaches it, and `docs/configuration.md` does not list it -- although\n`docs/protocol.md:255` presents it beside the `proto.*` settings. A person who needs longer than two minutes\ncannot configure it today. Declaring it is a prerequisite of this issue (and a #177-class promise/behaviour gap).\n\n**The daemon's idle clock ignores open streams.** `trackActivity` stamps the last-request time when a request\n*starts* (`server.go:344-353`), so a `/v1/events` SSE stream or a long `/mcp` stream that stays open is not\nactivity after its first byte; `shouldIdleExit` is held off only by live pooled instances (`:355-368`). That is\nthe fact #85 (an ssh `ControlMaster` holding a connection) and #86 (a browser tab holding `/v1/events`) turn on.\n\nThe `elicit.ttl = 120s` case is the sharpest. Two minutes is right for an agent that will answer\nimmediately and wrong for a person who walked away, and there is no way for a watching UI, a `mcpx elicit`\nsession or the opencode plugin to say \"still here\". `Request.TTLRemaining()` exists\n(`internal/elicit/elicit.go:108-109`), so the information is already exposed — only the ability to change\nit is missing. `tasks.ttl` has the same shape: the MCP spec's per-task `ttl` is retention of the *result*,\narmed at creation, so a long poll against `/v1/tasks/{id}/result` can outlive the retention of the thing it\nis polling for.\n\nNote also that `/v1/artifacts` and the per-put `TTL` override already demonstrate the pattern this issue\nrecommends generalising: a lifetime **parameter on the operation that already exists**, not a lifetime\nendpoint.\n\n## Approaches\n\n### Approach A — a `renew` operation per resource, least recommended\n\n`POST /v1/elicit/{id}/renew`, `/v1/tasks/{id}/renew`, `/v1/artifacts/{id}/renew`, `/v1/ask/{id}/renew`.\nThis is the shape the note implies and it is the one to avoid.\n\nWhy not: each new operation is a row in `internal/api/ops*.go`, and that table generates a route, an MCP\ntool, an OpenAPI operation, and a parity obligation for the CLI and the plugin — #76 is an existing issue\nabout exactly those obligations being missed. Four renew verbs is four of everything, forever, for a\nbehaviour that is the same behaviour four times. It also gets the semantics wrong in the common case:\nalmost every caller that wants to renew is *already polling* the resource, so the renewal is a second\nrequest carrying no information the first one did not already carry. And it leaves the original question\nunanswered — a caller that stops polling and stops renewing is indistinguishable from one that renewed and\nwent quiet, so the expiry still has to be idle-based underneath.\n\n### Approach B — a `ttl` / `extend` parameter on the existing operations\n\nAdd an optional `ttl` (and/or `extend`) parameter to the operations each resource already has:\n`GET /v1/elicit/{id}?extend=5m`, `POST /v1/tasks/{id}/…`, `POST /v1/artifacts` already has it. One\nconvention, no new endpoints, and it matches the `Param` machinery in the ops table exactly — adding a\nquery or body parameter is a one-line change per operation and the MCP tool, OpenAPI document and plugin\nclient all pick it up automatically.\n\nThis is most of the right answer and should ship for the cases where the caller genuinely knows a number:\nan agent that says \"this artifact is worth keeping for a week\", a UI that says \"this question is now in\nfront of a human, give it an hour\". The `artifacts` per-put override proves the ergonomics work.\n\nWhere it is not enough: it puts a side effect on `GET`. `GET /v1/elicit/{id}?extend=5m` is a mutating read,\nwhich breaks the one property the ops table currently uses to classify operations (`Mutating`,\n`Admin`, `Destructive` flags in `internal/api/ops.go`) and makes caching, retries and read-only policies\nwrong. Either the extension moves to a POST — and we are back towards A — or `GET` stops being safe. Both\nare worse than not needing the parameter at all in the common case.\n\n### Approach C — recommended: touch-on-read as the default, an explicit `ttl` parameter as the exception, one vocabulary for both\n\nRecommended, because it makes the common case need no API at all and gives the uncommon case one uniform\nparameter.\n\n**1. Make the default expiry idle, not absolute.** Every expiring resource keeps a `lastTouched`, updated\nby any operation that reads or acts on it. The deadline is `lastTouched + \u003cx>.ttl`. This is not a new idea\nin the codebase — it is precisely what `daemon.leaseTTL`, `proto.sessionIdle` and `daemon.idleExit` already\ndo, and the reason none of them ever needed a renew endpoint. Extending it to elicit, ask, proto state and\ntask results means: a UI polling a question keeps it alive; a client waiting on `/v1/tasks/{id}/result`\nkeeps the result alive; an abandoned question expires on schedule. Zero new operations, zero new tools,\nzero parity work. `elicit.ttl = 120s` becomes \"120 seconds with nobody interested\", which is what it should\nhave meant.\n\n**2. Add an absolute ceiling so idle cannot mean forever.** Pair each `\u003cx>.ttl` (idle) with an `\u003cx>.maxAge`\n(absolute, never renewed, default generous or zero-meaning-unlimited). Effective deadline is\n`min(created + maxAge, lastTouched + ttl)`. Without this, a stuck poller pins a resource indefinitely,\nwhich is the standard failure of touch-on-read and the reason it should be designed in on day one rather\nthan added after the first leak. One new setting per family, and settings are the cheap axis here —\nthe registry gives each one a config key, an `MCPX_*` variable, a flag, `/v1/settings` and an MCP tool for\nfree (`internal/settings/`).\n\n**3. Keep an explicit `ttl` parameter, on create only.** Where a caller knows the lifetime up front, it\nsays so on the operation that creates the thing — as `POST /v1/artifacts` and the MCP task `ttl` already\ndo. This stays a `Param` on an existing mutating operation, so nothing about `GET` safety changes. Extend\nit to the elicit and ask creation paths for symmetry.\n\n**4. One vocabulary, echoed everywhere.** Every expiring resource's representation carries the same two\nfields — `expiresAt` (RFC 3339) and `ttlRemainingMs` — so a client never has to know which family a\nresource is in. `Request.TTLRemaining()` already exists for elicitations; this generalises it. A client\nthat sees `expiresAt` move after a poll learns the resource is touch-renewed without being told.\n\n**5. Where renewal must happen without a read**, and only there, the extension rides on an operation that\nalready exists and is already mutating, with the same parameter name as (3). No `/renew` path segment\nanywhere. If a case is found where no such operation exists, that is the argument for a new endpoint and it\nshould be made in the issue for that specific case, with the reason written down.\n\nWhat this costs: a `lastTouched` field and a touch call in each store, the deadline calculation, and one\nnew setting per family. What it avoids: four endpoints × four surfaces, and the recurring question of what\na new expiring resource should do.\n\n### The daemon's own lifetime (owns #181 collision 9)\n\n**Owns #181 collision 9:** one lifetime rule for every surface -- activity on any surface renews the daemon's\nidle deadline, and nothing else does. #85 (ssh, `ControlMaster`/`ControlPersist`) and #86 (a browser tab)\napply it rather than deciding their own; the third case in the collision, daemons leaked by the e2e suite\n(#52), was fixed by #182 (`stop --all` through the info files, `MCPX_AUTOSTART_IDLE_EXIT=60s`) and needs\nnothing from here.\n\nWhat that rule has to settle, because today's code answers it by accident (see Current state):\n\n- **Is an open stream activity?** Recommended: a stream counts while it is *delivering* -- each event\n written or each `http.ssePing` keepalive re-stamps the idle clock -- so an open tab or a remote TUI keeps\n the daemon, and a stream nobody reads (a dead tab behind a proxy that never closes) does not outlive\n `maxAge`. The alternative, \"only request starts count\", is today's behaviour and kills a daemon under a\n watching dashboard.\n- **Is a transport process activity?** No. An ssh master connection or a TCP keep-alive with no requests on\n it is not a caller; `ControlPersist` governs the ssh process, not the daemon.\n- **Ceiling.** `daemon.idleExit`/`autostart.idleExit` are the idle half; the same `maxAge` pairing in (2)\n above applies if a daemon should ever be bounded absolutely (probably not: `0` = unlimited).\n\n### The note's other words\n\n`prompt` and `attachment` do not name resources that exist today. Prompts are rendered on demand\n(`POST /v1/prompt`, `internal/cli/prompts.go`) and hold nothing with a lifetime; attachments are closest to\nartifacts, which are covered above. If either grows state later, the convention above is what it should\nadopt — which is the point of settling it once. `mcp` maps to `proto.sessionIdle`, already idle-based, and\n`proto.stateTTL`, which is **not**: a `requestState` carries a signed absolute expiry minted with the token\n(`internal/mcpserver/state.go:56-74`), so it cannot be touch-renewed; it is effectively renewed by being\nre-minted on each round of an interrupted call. (Corrected in the 2026-09-30 issues pass; the table above\nhad it right and this sentence contradicted it.)\n\n## Open questions\n\n- Should artifacts be touch-renewed? An artifact read keeping it alive is convenient for a long-running\n script and surprising for a 1 GiB quota (`artifacts.quota`). Current opinion: artifacts stay absolute by\n default with a `ttl` on put, and gain `artifacts.idleTtl` as an opt-in. They are the one resource where\n the storage cost argues against generosity.\n- Does touch-on-read apply to *any* read, or only to reads by the owning session? An unrelated\n `GET /v1/elicit` listing every pending question would renew all of them, which is probably not intended.\n Likely rule: collection reads do not touch, item reads do.\n- Renaming or re-meaning `\u003cx>.ttl` from absolute to idle is a behaviour change to a documented setting.\n Is that acceptable pre-1.0, or does it want new setting names and a deprecation?\n- What emits when something expires? `/v1/events` already exists; an `expired` event would let a UI show\n why a question vanished rather than having it silently disappear.\n- Is `maxAge` worth it for every family, or only for the ones with a storage or process cost behind them?\n\n## Ease · Impact · Related\n\n**Ease**: M — mechanically small per store (a timestamp, a touch, a `min()`), but it touches five\nsubsystems and changes the meaning of documented settings. **Impact**: med — high for anything with a human\nin the loop, where `elicit.ttl = 120s` is the current ceiling on how long a person may take to answer.\n**Depends on / related**: #77 (protocol follow-ups — task status and cancellation are adjacent lifecycle\ngaps; a task that reports status is also a task that is being watched), #76 (any new parameter must reach\nthe CLI and the plugin, not just `/v1`), #78 (daemon state correctness), #6 (event store — expiry events\nbelong there), #86 (a dashboard sitting on an elicitation is the motivating case for touch-on-read; applies\nthe lifetime rule), #85 (applies the lifetime rule to ssh), #52 (closed, fixed in #182 — the e2e leak\ncase of collision 9), #177/#172 (`elicit.ttl` is a compiled-in default with no setting), #185 (`ClampedBy`:\nif a caller-supplied `ttl` must not exceed the daemon's `maxAge`, that is its ceiling mechanism).\n\nSecurity/auth deferred; see tracker.\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:15:35Z","url":"https://github.com/developing-today/code/issues/1884"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:290977a0-1279-bd9f-1368-f1da80fa7ac8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E754:17C530:34426B:444944:6B06173C |
| html-safe-nonce | 90bbff84d382179931118df1fbb1124578174954c34fd8b57991666dcb0e51cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzU0OjE3QzUzMDozNDQyNkI6NDQ0OTQ0OjZCMDYxNzNDIiwidmlzaXRvcl9pZCI6Ijg2NDAzMzY2MzIwMTQ1NzU0MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c4c381c83c17eb6266d633d679913f287d51e2bbf226fcc5eec9bf1cbc5e905e |
| hovercard-subject-tag | issue:6088487573 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1884/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc81c7a98cf22934900263a4ce45f48795aee4e907874fc362bd6062631edb06/developing-today/code/issues/1884 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc81c7a98cf22934900263a4ce45f48795aee4e907874fc362bd6062631edb06/developing-today/code/issues/1884 |
| og:image:alt | Relocated from dezren39/darwin-nix#87 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue reference... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width