Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkgs/mcpx/internal/daemon/routes_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,10 @@ func (s *Server) handleAskAbandon(w http.ResponseWriter, r *http.Request) {
var body struct {
TaskCancelled bool `json:"taskCancelled"`
}
if r.Body != nil {
_ = json.NewDecoder(r.Body).Decode(&body)
// The decode is capped like every other body read here; a missing
// or malformed body leaves the zero value (not cancelled).
if limited := http.MaxBytesReader(w, r.Body, defaults.HTTPCallBodyLimit); r.Body != nil {
_ = json.NewDecoder(limited).Decode(&body)
}
if body.TaskCancelled {
s.reg.markAskTaskCancelled(id)
Expand Down
10 changes: 10 additions & 0 deletions pkgs/mcpx/internal/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ type Defaults struct {
// state and are never pruned.
RetentionMaxAge string `json:"retentionMaxAge"`
RetentionMaxTerminalRows int `json:"retentionMaxTerminalRows"`
// AudienceWindow is how recent an answerer heartbeat must be for
// an audience to count as present (#2438).
AudienceWindow string `json:"audienceWindow"`
} `json:"elicit"`
// Proto governs how mcpx speaks the protocol to its own clients: which
// era mechanisms it offers, and how long it will hold a call open while
Expand Down Expand Up @@ -657,6 +660,13 @@ var (
// question is kept in the broker store before an open prunes it
// (#1677, design #1675 Phase 2: the recorded 30 days).
ElicitRetentionMaxAge = mustDur(builtin.Elicit.RetentionMaxAge, "elicit.retentionMaxAge")
// ElicitAudienceWindow is how recent an answerer heartbeat must be
// for an audience to count as present (#2438). Answerer surfaces
// poll on a one-second cadence (mcpx elicit watch) or per user
// refresh, so two minutes is generous without letting a long-gone
// answerer count. An internal bound: defaults.json only, absent
// from the settings registry.
ElicitAudienceWindow = mustDur(builtin.Elicit.AudienceWindow, "elicit.audienceWindow")
// ElicitRetentionMaxTerminalRows caps how many terminal questions
// the broker store keeps, oldest first out (#1677).
ElicitRetentionMaxTerminalRows = builtin.Elicit.RetentionMaxTerminalRows
Expand Down
3 changes: 2 additions & 1 deletion pkgs/mcpx/internal/defaults/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
"handlerTimeout": "5m",
"inputRounds": 8,
"retentionMaxAge": "720h",
"retentionMaxTerminalRows": 1000
"retentionMaxTerminalRows": 1000,
"audienceWindow": "2m"
},
"proto": {
"native": true,
Expand Down
9 changes: 6 additions & 3 deletions pkgs/mcpx/internal/elicit/presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package elicit
import (
"os"
"time"

"github.com/developing-today/code/pkgs/mcpx/internal/defaults"
)

// Answerer presence: the broker's truthful no-audience signal (#2438,
Expand All @@ -25,10 +27,11 @@ import (
// answer.

// DefaultAudienceWindow is how recent an answerer heartbeat must be
// for the audience to count as present. Answerer surfaces poll on a
// one-second cadence (mcpx elicit watch) or per user refresh, so two
// for the audience to count as present. The value lives in
// defaults.json (elicit.audienceWindow, 2m): answerer surfaces poll on
// a one-second cadence (mcpx elicit watch) or per user refresh, so two
// minutes is generous without letting a long-gone answerer count.
const DefaultAudienceWindow = 2 * time.Minute
var DefaultAudienceWindow = defaults.ElicitAudienceWindow

// NoteAnswerer records that an answerer able to serve aud was seen
// now. An empty audience means an unfiltered answerer -- one polling
Expand Down