Skip to content

feat(construct): add the planner evaluation set - #7

Open
nikbackdev wants to merge 518 commits into
construct-planner-promptfrom
construct-planner-eval
Open

nikbackdev wants to merge 518 commits into
construct-planner-promptfrom
construct-planner-eval

Conversation

@nikbackdev

@nikbackdev nikbackdev commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Description

The reference evaluation set for the planner: cases of a starting profile, one record and the expected decision per property, and a runner that scores the planner on a configured model against PRD G2 (95 % of records with the expected decisions, no contradicting pair).

The design is in gears/construct/docs/features/planner.md.

Review stack. All Construct PRs come from forks, so a stack of PRs with each base on the previous branch can only live in this fork. Each PR here shows its own change only. The bottom base, construct-base, is the sensitive-data checks and admission change (constructorfabric#5311, on top of constructorfabric#5248 and constructorfabric#5249) with main merged in. Merging goes through constructorfabric#5317, from the bottom up.

Not in this PR: the score on a reference model, which needs the model and its endpoint agreed; more cases after the first run.

Testing

  • Unit tests pass
  • New tests added for new functionality

Also run locally: cargo fmt, cargo clippy -D warnings, cargo gears lint --dylint (cargo-gears 0.0.8), make check-release-config, gts-validator, cfs validate, and the runner against a local fake model.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Code is documented with rustdoc comments

@nikbackdev
nikbackdev force-pushed the construct-planner-prompt branch from ce77405 to 9bbca2e Compare October 13, 2026 09:57
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch 2 times, most recently from 12253cb to e0d8e54 Compare October 13, 2026 14:03
@nikbackdev
nikbackdev force-pushed the construct-planner-prompt branch 2 times, most recently from 260efb4 to 4e78fb9 Compare October 13, 2026 14:56
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch 2 times, most recently from 6ad0adc to a95f8e3 Compare October 15, 2026 00:54
@nikbackdev
nikbackdev force-pushed the construct-planner-prompt branch from 4e78fb9 to 2bdcf42 Compare October 15, 2026 00:54
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch from a95f8e3 to c6b2d1a Compare October 15, 2026 02:23
@nikbackdev
nikbackdev force-pushed the construct-planner-prompt branch from 2bdcf42 to 8ad7c5d Compare October 15, 2026 02:35
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch 3 times, most recently from fb6bd40 to a3d7969 Compare October 20, 2026 08:54
entropyshift and others added 16 commits October 20, 2026 11:24
…tings-service-improvements-for-frontend

feat(settings-service)!: display name, category order and a needs-review surface for the console
…ntion-rule listings

`GET /files`, `GET /files/{id}/versions` and `GET /retention-rules` now
page with an opaque keyset cursor instead of `offset`:

- the response is `{items, page_info: {next_cursor, prev_cursor, limit}}`
  instead of a bare array, and a page can be walked in either direction;
- `cursor` replaces `offset`; `offset` or any other unknown query
  parameter is a 400, and so is `limit=0`;
- the default page size is 25 and the maximum 200 (larger values are
  clamped); the order is `created_at DESC` with the row id as the
  tie-breaker, so pages never skip or repeat rows.

A new migration adds the keyset indexes for the three listings.
api.md gains a "Changes for 0.2.x clients" section.

BREAKING CHANGE: the three listing endpoints return a page object
instead of a JSON array and reject `offset`; `limit=0` is rejected.

Signed-off-by: Roland From <rfedorov@linkentools.com>
…ion tests fail for their own reason

`validate()` now rejects `default_page_size: 0` or `max_page_size: 0`: either would make every listing return an empty page with no cursor. The two existing page-size rejection tests set `finalize_internal_secret`, which `validate()` checks first, and all four rejection tests assert on the error text.

Signed-off-by: Roland From <rfedorov@linkentools.com>
`Direction` and `Seek` in `domain/pagination.rs` lacked `#[domain_model]`, which the architecture lint (DE0309) requires for public domain types.

Signed-off-by: Roland From <rfedorov@linkentools.com>
… OData extractor

Every listing (GET /files, GET /files/{id}/versions, GET /retention-rules and
now GET /storages) binds its page size and continuation through the toolkit
`OData` extractor, as docs/toolkit_unified_system/07 prescribes:

- `$top` and `$skiptoken` are accepted as synonyms of `limit` and `cursor`;
  both spellings of one parameter in a request are a 400.
- `$skip` and every other unsupported system query option get the toolkit's
  400 with its hint; `$filter`, `$orderby` and `$select` are refused with
  UNSUPPORTED_QUERY_PARAM, as is any plain key a listing does not take.
- `limit=0` / `$top=0` is INVALID_LIMIT on `$top`.
- GET /storages returns a cursor-paginated `Page<StorageDto>` in `id asc`
  order instead of a bare array.
- A cursor is checked against the listing's order before its binding, so a
  cursor issued by another listing is always ORDER_MISMATCH.

Services and stores take the parsed `CursorV1`; `pagination::decode` becomes
`pagination::seek`. File-storage docs and docs/api/api.json are updated.

Signed-off-by: Roland From <rfedorov@linkentools.com>
…ate-only pagination items

- The four listings declare `limit`/`cursor` through one `page_params()` builder
  extension and build their description from `listing_description(order)`;
  `GET /storages` now reads "Canonical order is `id asc`" like the others.
- `reject_unsupported_options` uses `ODataQuery::has_filter`/`has_select` and
  `ODataOrderBy::is_empty` instead of reaching into the fields.
- Pagination helpers, `Seek`, the repo page queries, `list_backends` and
  `MAX_PAGE_SIZE_CEILING` become `pub(crate)`: nothing outside the crate uses
  them. `page_by_id` documents that it is only for small, configuration-sized
  in-memory lists.

Signed-off-by: Roland From <rfedorov@linkentools.com>
… fixed 200

Signed-off-by: Roland From <rfedorov@linkentools.com>
… a bare array

Signed-off-by: Roland From <rfedorov@linkentools.com>
… register_routes

Signed-off-by: Roland From <rfedorov@linkentools.com>
…ndabot/docker/testing/docker/rust-1.99.1-bookworm

chore(deps): bump rust from 1.98.1-bookworm to 1.99.1-bookworm in /testing/docker
…ndabot/docker/deploy/docker/rust-1.99.1-bookworm

chore(deps): bump rust from 1.98.1-bookworm to 1.99.1-bookworm in /deploy/docker
Signed-off-by: Lobster40 <lobster40@gmail.com>
Weekly Dependabot runs opened ~10 PRs at once, each starting ~25 workflows.
On 2026-10-14 that burst exhausted the GITHUB_TOKEN rate limit and the runner
pool, and Cargo.lock merges kept forcing rebases of the remaining PRs.

- cargo: group patch updates; minor stays individual because a 0.x minor is
  breaking in cargo (constructorfabric#4900 base64 0.22 -> 0.23)
- cargo: rustcrypto group so sha2/digest/rsa/signature move together (constructorfabric#5350)
- docker: one group across all three directories (rust 1.99.1 arrived as
  constructorfabric#5393, constructorfabric#5394, constructorfabric#5396)
- github-actions: group minor/patch; majors stay individual; codeql kept
- all: Monday 02:00 UTC schedule, 5-day cooldown, open-PR limit 5,
  consistent "chore(deps)" prefix

Security updates ignore groups and cooldown, so they still arrive at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lobster40 <lobster40@gmail.com>
- pin sccache-action `version: v0.18.0` in all 10 steps: without it the
  action calls the GitHub releases API on every job (src/setup.ts at
  fc920bf, lines 30-40), which exhausted the installation rate limit when
  ~10 Dependabot PRs opened at once on 2026-10-14
- nextest: retries = 2 for four known-flaky tests only (no global retries),
  each marked as a quarantine to be fixed
- e2e: cancel-in-progress on pull_request, so a rebased PR stops its stale run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lobster40 <lobster40@gmail.com>
…ire-sqlpgq

Signed-off-by: vasylcf <vasylcf@gmail.com>
… in the present tense

The PRD's toolkit-db risk row claimed a reference-scale p95 measured on a
development stand whose harness is not in this repository; it now leaves
reference-scale latency unclaimed until a full-scale run is recorded here.
The PostgreSQL constraint says plainly that SQL/PGQ is not required.

Sweep for the same class, present-tense SQL/PGQ claims and stand-only
measurements, across the gear's documents:
- DESIGN traversal component: one execution path, the two-query hop, instead
  of three paths selected by configuration;
- DESIGN worked example, step 5: the path no longer depends on configuration
  or scope;
- DESIGN plugin selection: the GRAPH_TABLE decline example is in the past
  tense;
- PRD dependency row, README, ADR-0001 addendum, DESIGN traversal sketch: the
  2026-10-13 comparisons are marked as development-stand measurements.

Signed-off-by: vasylcf <vasylcf@gmail.com>
Artifizer and others added 26 commits October 26, 2026 18:08
Close review findings C1, C2, C4, and C5.

Worker-session leases (C1, new ADR-0017):
- Every heartbeat wrote `te_task_state.lease_until` for each task:
  about 10K updates/s at the profile, on an indexed column of the
  hottest table, so PostgreSQL could not update in place. A heartbeat
  now renews one `te_worker_sessions` row per worker process and
  domain; per-task lease tokens still fence every write.
- Session expiry marks the session expired, then requeues its tasks
  in batches as normal liveness failures (one blacklist strike per
  queue). Hand-offs get their own `handoff_until` accept window.
- PRD §5.6 states the behavior change: a heartbeat keeps all leases
  of the process alive; the execution timeout bounds a stuck handler.

Claim path (C2, DESIGN §4.6):
- Counters are checked under the counter-row lock before any task
  write, so a capacity skip never writes the task row.
- Per-node saturation cache; round_robin seeks past saturated
  tenants; fifo reads at most `claim_scan_rows_max` rows per claim.
- Describe SKIP LOCKED streams, batch claims (`max_tasks`), and
  node-local claim coalescing in DESIGN; ADR-0008 stays proposed.

Stored background slot (C4):
- Replace `hash(task_id) % bg_shards` with a stored `bg_slot`
  (0..1023) on task, timer, and session rows. Shards own slot ranges
  (`te-bg-{S}-{i}` locks), the predicate is a plain column check
  inside the index, and changing `bg_shards` moves no data.

MySQL/MariaDB partial indexes (C5, DESIGN §3.7):
- Give every partial index a MySQL form (NULL outside the predicate,
  or predicate columns first), use the ascii charset for long key
  columns, and add a TODO(toolkit) to expose the outbox's
  dialect-aware index helper.

Sync ADR-0003, ADR-0005, ADR-0013, the config, metrics, lock order,
traceability, and the `task_claimed` event schema.

Signed-off-by: Artifizer <artifizer@gmail.com>
The checked-in `gts.cf.toolkit.authz.permission.v1~` schema is a copy
of the macro output of `AuthzPermissionV1`. Add a test that fails when
the file no longer matches the struct, so doc-level tooling never
resolves a stale schema.

Signed-off-by: Artifizer <artifizer@gmail.com>
…ains by queue

Hold caller idempotency keys for a short window instead of the whole
retention, so te_dedup no longer grows with every stored task.

Bound search with indexed sort keys, a creation-time window, page size
caps, and a capped count, so cost does not grow with stored history.

Fix the backoff formula: count retries from 1, saturate instead of
overflowing, and let jitter only shorten the wait.

Route task domains by queue only. Type rules are checked at create time,
because task types are registered at runtime. Dead-letter queues are no
longer routed, so the shipped queues can share one.

Signed-off-by: Artifizer <artifizer@gmail.com>
Signed-off-by: Artifizer <artifizer@gmail.com>
Replace the gear-level SKIP LOCKED plan with the counter-first,
guarded-update protocol owned by toolkit-db (toolkit_db::secure::claim):
plain scoped candidate reads, guarded slot reservation before any task
write, guarded queued -> claimed transition, settle, commit. The gear
keeps long-poll, waiter groups, and coalescing, and has no dialect SQL.

Make "counters before task rows" the engine-wide lock order and apply it
to finalize(), task creation, dependency additions, and liveness
requeues. Scope the round-robin "next tenant" probe with the caller's
PDP constraints so tenant workers never spend the probe budget on
tenants they cannot claim from.

Signed-off-by: Artifizer <artifizer@gmail.com>
Replace time-range partitions that are created ahead and dropped with a
fixed ring of N list partitions per history table, keyed by a stored
ring_slot (time bucket mod N). Partitions are created once by the
migrations; retention recycles the next slot by mark, rescue, and
TRUNCATE, so there is no runtime partition DDL and the partition count
is bounded. A te_ring_state table routes writes of retained tasks to the
_retained tables, so no write targets a recycled slot.

The retention loop follows the Event Broker retention worker: a paced
tick with bounded, idempotent passes; SQLite keeps a bounded DELETE.

Signed-off-by: Artifizer <artifizer@gmail.com>
Drop the gear's own anonymous /health, /ready, and /metrics routes.
Readiness goes through the ToolKit Healthcheck capability (domain
databases reachable, migrations applied, startup recovery finished);
metrics are OpenTelemetry instruments exported by the platform meter
provider. Label rules keep cardinality bounded and never expose
tenant-owned task type IDs; add retention and readiness metrics.

Signed-off-by: Artifizer <artifizer@gmail.com>
Use only the options the ToolKit OData extractor accepts ($filter,
$orderby, $select, $top, $skiptoken) and its JsonPage response with
page_info.next_cursor. Replace LOD presets with a plain view parameter,
embed full-view relations without $expand, clamp the page size in the
handler, and move counting to a separate capped GET /tasks/count.

Signed-off-by: Artifizer <artifizer@gmail.com>
Worker-session leases keep a task leased while its process heartbeats,
even if the handler hangs, so the execution timeout is the only bound.
Resolve it request -> type -> queue -> default_execution_timeout_secs so
every task has one, and cap every value with trust_limits
max_execution_timeout_secs (tighter for tenant-owned types).

Signed-off-by: Artifizer <artifizer@gmail.com>
The design depends on ToolKit and SDK primitives that do not exist yet,
and several TODO(toolkit) markers had no owner. Point them, and the
gear-local patterns that should become shared code, at the tracking
issues: secure claim (constructorfabric#5477, constructorfabric#5478), leases (constructorfabric#5479), idempotency keys
(constructorfabric#5480), partition ring (constructorfabric#5481), sharded background ownership (constructorfabric#5482),
guarded counters (constructorfabric#5483), consumer inbox (constructorfabric#5484), budgeted CEL (constructorfabric#5485),
and the payload column type (constructorfabric#5486).

Signed-off-by: Artifizer <artifizer@gmail.com>
…be checks

The engine reads waitable topics with platform rights, but setting an event
wait only checked the caller's consume right on the event type (and on the
subject type when one was given). A caller could skip the subject-type check
by omitting it, topic consume was never checked, PDP constraints were treated
as pass/fail, and the set-time check stayed in force for the wait's whole life.
Together with the CEL match expression this let a wait observe events outside
the caller's own consume rights.

- Every event condition has an effective subject type (explicit, or the event
  type's single allowed subject type); matches are filtered by it.
- Set/arm runs the broker's subscribe checks with the caller's context:
  consume on the topic, the event type, and the subject type.
- Decidable PDP constraints are stored as event_consume_filter and applied to
  every candidate event before the match expression; constraints the engine
  cannot enforce refuse the wait (EVENT_CONSUME_UNVERIFIABLE).
- Event-condition timeouts are capped by event_waits.max_wait_secs, bounding
  how long set-time checks stay in force.

Updates DESIGN, PRD section 5.4, and ADR-0004, ADR-0007, ADR-0016.

Signed-off-by: Artifizer <artifizer@gmail.com>
…requested issues

Signed-off-by: Artifizer <artifizer@gmail.com>
Ring recycling waited "poll interval + longest transaction" before
truncating a slot, so a node with a stale cache could still write into
it and lose history. Writers for old buckets and the mark step now lock
the same te_ring_state row, which fences them without timing.

Queue-wide queue depth was one counter row that every create and claim
of a queue had to lock, and claims waited on it while holding their
other counter locks. Queue-wide and domain-wide depth are now sampled
ceilings; te_queue_backlog is removed and the per-tenant limits stay
exact. ADR-0008 asks toolkit-db (constructorfabric#5478) for SKIP LOCKED candidate
selection by default on PostgreSQL/MySQL and widens the benchmark.

Per-tenant counter rows were never sharded, so one busy tenant (for
example the platform tenant on the system queue) used a single hot row.
The same shard rule now applies to tenant rows; reserved shards are
recorded on the task and released exactly.

Signed-off-by: Artifizer <artifizer@gmail.com>
… gaps

- State the throughput target per task-domain database: all nodes share
  it, so more nodes do not add write capacity; add a per-task write
  estimate to the write budget.
- te_events: store the event type as an enum code, add ring_slot and a
  (task_id, id) index; te_task_entries: add ring_slot and a
  (task_id, created_at, id) index.
- Add live-table maintenance rules for PostgreSQL dead rows (per-table
  autovacuum, fillfactor, no new live indexes without review, dead-row
  metric, long-run benchmark).
- Treat a caller-supplied input_schema as untrusted: size and depth
  limits, no remote $ref, linear-time regex only.
- Replace conflicting allow_all() statements with one complete list, and
  answer 404 for a single task the caller may not read (no existence
  oracle).
- Add type and queue search indexes on te_task_results, put task_id last
  in the tag and resource-reference indexes, and document which index
  serves each search filter.

Signed-off-by: Artifizer <artifizer@gmail.com>
… PR.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…z-concrete-resource-types

fix(event-broker)!: authorize concrete resources
…es-restricted-login

feat(toolkit-db, e2e): run a gear under a restricted PostgreSQL login
…optimization

perf(ci): cache Linux compilation and CI tools on the current upstream workflow
Signed-off-by: Artifizer <artifizer@gmail.com>
…cord-schema-lookup

fix(construct): build again after the record types and manage-facts merges
New crate libs/toolkit-http-proxy (cf-gears-toolkit-http-proxy). HTTP/1.1
runs on hyper 1, HTTP/2 on the h2 crate. TLS configs come only from
toolkit-http, so the fips feature covers the whole path.

- pool: HTTP/1.1 idle stack with per-host and global caps, retired before
  the upstream's announced Keep-Alive timeout; HTTP/2 multiplexed
  connections with a per-host cap, chosen by spare capacity (our target
  capped by the upstream's MAX_CONCURRENT_STREAMS, learnt before first
  use); every HTTP/1.1 connection and HTTP/2 stream has one owner and is
  closed or reset when the owner goes away
- HTTP/1.1 connections have no task of their own: the request that owns a
  connection drives it, so a response body reads the socket in the task
  that consumes it and a 64 KiB read buffer is enough; a connection whose
  request upload has not finished, or whose last write is still pending,
  is closed instead of pooled
- retry at most once, never of a request the upstream may have processed
  unless it is idempotent: unsent requests, REFUSED_STREAM and
  HTTP_1_1_REQUIRED (then HTTP/1.1 for the host), and for idempotent
  requests a graceful GOAWAY or a keep-alive race; bodies are resent only
  when empty or attached as a ReplayableBody
- requests waiting for a failed connect attempt share its error
- ALPN with a per-host cache; WebSocket upgrade only after a validated 101
- HTTP/2 accepts 64 KiB frames (fewer frames per large body)
- timeouts: connect, response head, body idle, write stall; progress only
  records a timestamp, and timeouts run on a shared coarse timer service
  (10 ms ticks, one driver per client on tokio's clock);
  ResponseBody::set_idle_timeout lets a caller own the idle policy of a
  long-lived stream such as SSE
- request/response header sanitizing against smuggling and desync;
  Content-Length: 0 for empty bodies of methods with body semantics; split
  cookie fields joined before an HTTP/1.1 hop
- balance: DNS refresh keeping the last good addresses, TCP health
  checks, round-robin, SSRF filter hook
- regression suite for the Pingora advisories, HTTP/1.1 desync classes
  and HTTP/2 abuse (HPACK bomb, zero window, CONTINUATION and empty-DATA
  floods); fuzz target for the header sanitizer

toolkit-http exports custom_roots_client_config. The workspace requires
h2 >= 0.4.20; the FIPS CI lanes (Linux, macOS, Windows) and test-fips
build or run the new crate.

Signed-off-by: MikeFalcon77 <3686170+mikefalcon77@users.noreply.github.com>
OAGW: drop pingora_proxy.rs and the in-memory session bridge; forward
directly through the engine with the same endpoint selection, error
mapping (plus WriteTimeout -> RequestTimeout) and WebSocket relay.
Buffered request bodies are attached as ReplayableBody, so the engine may
resend them when the upstream provably did not process the request. One
request deadline covers endpoint selection, DNS resolution and the
exchange. SSE responses are bounded by streaming_idle_timeout instead of
the engine's per-read timeout, so quiet streams are not cut after the
read timeout. The OAuth2 token cache uses a small LRU+TTL cache instead
of pingora-memory-cache (exact keys, huge TTLs never expire instead of
panicking). Add the proxy_roundtrip benchmark.

event-broker: forward through the engine (HTTP/1.1 only, as before).

Workspace: Pingora leaves the dependency graph (and OAGW's own httparse
dependency with the bridge parser), so the tokio < 1.54 pin, the
RUSTSEC-2024-0437 ignore and the dependabot tokio ignore go too; the
workspace now requires tokio 1.54.

Docs: toolkit ADR-0004 (the engine: security properties, retry policy,
pool limits, timers, FIPS 140-3, benchmark) and OAGW ADR-0019 (the
migration, including that engine failures are now errors rather than
gateway-written 502 responses), "Amended by" notes in OAGW ADR-0016/0018,
OAGW DESIGN, DECOMPOSITION and feature 0004, security and FIPS docs.

Signed-off-by: MikeFalcon77 <3686170+mikefalcon77@users.noreply.github.com>
docs(task-engine): add Task Engine PRD and DESIGN
The architecture lint (DE1202) requires a doc comment on crate-public fields.

Signed-off-by: MikeFalcon77 <3686170+mikefalcon77@users.noreply.github.com>
…toolkit-http-proxy

Replace Pingora with an in-house upstream proxy engine (toolkit-http-proxy)
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch 2 times, most recently from 55762a7 to 4c3db1f Compare October 27, 2026 07:52
Reference cases for the planner: a starting profile, one record and the
expected decision per property, across the person types, chat messages,
fact candidates and records that change nothing. Every test run checks
the cases against the person types and the record types. An ignored test
runs the planner on a configured model and scores the entity steps of
its plans against the PRD G2 target: 95 % right decisions and no
contradicting pair.

Signed-off-by: Nikita <Nikita.Bazhenov@constructor.tech>
@nikbackdev
nikbackdev force-pushed the construct-planner-eval branch from 4c3db1f to bca5c7c Compare October 27, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.