Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ced937a
Add opt-in staged assistant entry points and recovery
FlyOverCoderKY Nov 11, 2026
8fc20d8
Compose default-off production support answering
FlyOverCoderKY Nov 11, 2026
2033552
Add purpose-bound engineering model ports
FlyOverCoderKY Nov 11, 2026
8b32b6f
Preserve actual usage and consistent model budget admission
FlyOverCoderKY Nov 12, 2026
7be4d4f
Bound answering root execution and run staged turns every minute
FlyOverCoderKY Nov 12, 2026
945e87e
Compose engineering processing with durable usage accounting
FlyOverCoderKY Nov 12, 2026
d4e9f5c
Share background maintenance eligibility with the workload fixture
FlyOverCoderKY Nov 12, 2026
8dcd44a
Add bounded read-only GitHub repository metadata ports
FlyOverCoderKY Nov 11, 2026
97baf71
Add bounded GitHub issue dispatch and reconciliation ports
FlyOverCoderKY Nov 11, 2026
3651e13
Scope issue creation credentials to the exact repository identity
FlyOverCoderKY Nov 12, 2026
3330516
Align native answering fixtures with the configured scheduler and sca…
FlyOverCoderKY Nov 12, 2026
768afec
fix: preserve engineering model boundary and billing guards
FlyOverCoderKY Nov 12, 2026
dc7a822
fix: address configured support integration review findings
FlyOverCoderKY Nov 12, 2026
274954d
fix: resume prepared answering work within invocation budget
FlyOverCoderKY Nov 12, 2026
43e7644
test: verify deferred answering checkpoint settlement
FlyOverCoderKY Nov 12, 2026
4c90f75
fix: bound answering hints and preserve known usage
FlyOverCoderKY Nov 12, 2026
fcdc4bc
fix: preserve human intake and scope repository reads
FlyOverCoderKY Nov 12, 2026
870f92f
docs: correct repository reconciliation request ceiling
FlyOverCoderKY Nov 12, 2026
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
43 changes: 27 additions & 16 deletions docs/KNOWLEDGE_COMPOSITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,20 @@ prerequisites.

### Limiter window cleanup and the shared cron

The [scheduler](../worker/src/index.ts) keeps five distinct cron expressions.
`RATE_LIMIT_CRON` remains `0-57 * * * *`. Its 58 eligible minutes allocate
two isolated rate invocations followed by one ready-hint invocation:
The [scheduler](../worker/src/index.ts) configures five cron entries.
`RATE_LIMIT_CRON` is the all-minute `*/1 * * * *` trigger, including UTC minutes
58 and 59. When answering processing is enabled, this physical invocation
belongs exclusively to one bounded answering preparation or paid stage.
Background cleanup uses its separate `0-58 * * * *` trigger and rotates through
20 exclusive lanes, including the global limiter and retrieval-ready tasks.
Each background task runs once per 20 eligible ticks, nominally 20-21 minutes.
Retained history and contention can consume answering opportunities. The SDK's
300-second turn deadline and its expiry/human-handoff rules remain authoritative.

With answering OFF, cleanup uses its 18-lane rotation, nominally 18-19 minutes.
The all-minute rate trigger performs background work only at minutes 0 through
57. Those 58 eligible minutes allocate two isolated rate invocations followed by
one ready-hint invocation:

- UTC minutes with remainder 0 or 1 when divided by three run one
[global limiter cleanup](../worker/src/knowledge-maintenance.ts) page of at
Expand All @@ -408,14 +419,12 @@ two isolated rate invocations followed by one ready-hint invocation:
task. This reduces the previous 29 ready opportunities to 19; ready hints
remain a latency aid, with atomic SDK jobs and physical recovery preserved.

The original four other expressions remain in place. The cleanup rotation
retains its original 15 lanes, the separately gated learning-review discovery
lane and two engineering limiter lanes, for 18 exclusive lanes. Each lane runs
once per 18 eligible ticks, a nominal 18-19 minutes because minute 59 is
omitted. The learning lane emits queue hints only; a review phase runs in a
later Queue invocation. The default root supplies no trusted learning bundle
and keeps the review flag off. Minutes 58 and 59 have no `RATE_LIMIT_CRON`
invocation. Before
The OFF cleanup rotation covers the original 15 lanes, the separately gated
learning-review discovery lane and two engineering limiter lanes. The learning
lane emits queue hints for a later Queue invocation. The default root keeps
the review flag off. The OFF rate callback performs no Store work at minutes
58 and 59. Mail send, mail reconciliation and release-reconciliation cadences
retain their separate invocations. Before
merging, inventory every Worker's current cron triggers in the deployment
account: pushes to `main` deploy these schedules regardless of the Knowledge
flag. Deployment replaces this Worker's existing expressions with these
Expand All @@ -432,14 +441,16 @@ pages are not snapshots. Descriptors, malformed/legacy `0.2.0` rows and
unknown layouts remain retained. This does not silently migrate old limiter
storage; existing Identity/Support maintenance remains in place.

The scheduled limiter ceiling is 780 physical rows per hour if all 39 pages
succeed and fill. Live windows, descriptors, retained rows and cursor-cycle
The OFF-mode scheduled limiter ceiling is 780 physical rows per hour if all
39 pages succeed and fill. The enabled 20-lane cleanup rotation has lower
background throughput, so that figure describes the OFF cadence. Live windows,
descriptors, retained rows and cursor-cycle
overhead consume slots, so this is not a deletion or expiry guarantee. The
synthetic capacity regression creates 50 browser IP subjects plus one subject
in each of six Agent Access policy shapes per five-minute cohort: 672 counters
per hour for four continuing hours, then two hours without new arrivals.
Seven persistent descriptors, live windows and the minute-58/59 gaps remain
in the actual Store. It checks backlog and oldest-expiry age at the same
The OFF-mode regression retains seven persistent descriptors, live windows and
the minute-58/59 background gaps in the actual Store. It checks backlog and oldest-expiry age at the same
workload phase after warmup, cursor-cycle progress and eventual drainage.
This finite workload is not a production benchmark, universal arrival-rate
bound or passed-gate claim in this guide.
Expand Down Expand Up @@ -485,7 +496,7 @@ completions cannot overwrite a newer generation. Already committed projection
writes are not rolled back after acknowledgement uncertainty.

The existing Knowledge turn in the
[18-lane cleanup schedule](../worker/src/maintenance-schedule.ts) independently
[mode-dependent cleanup rotation](../worker/src/maintenance-schedule.ts) independently
calls `repairRetrievalPage` with `limit:1` and `maxBatches:1`. Complete physical
cycles and the SDK's existing atomic article-change jobs remain the recovery
path for a lost hint, collection/policy changes and unfinished work. The ready
Expand Down
94 changes: 83 additions & 11 deletions docs/SUPPORT_COMPOSITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Public host composition notes for authenticated product feedback on
[pegma.dev](https://pegma.dev). This is the ecosystem's Cloudflare reference
environment for Support Desk customer create / list / read / reply and a small
staff operator surface over the same application services, including human
requests, takeover and private handoff context. The human HTTP handlers keep
assistant handling disabled.
requests, takeover and private handoff context. Ordinary human HTTP handlers keep
assistant handling disabled; the optional production composition uses a separate
explicitly admitted browser route and defaults to OFF.

The separate synthetic stage source defines its own Worker, Queue and D1
binding with a scripted local model. It starts disabled and has no production
Expand Down Expand Up @@ -386,14 +387,38 @@ provider or activation result.
## Maintenance and health

The separate cleanup cron (`0-58 * * * *`) runs one rotating task per
invocation, including Support Desk queue repair, inactive projection sweep,
each Support/Admin rate-limit policy and the separately gated learning-review
discovery lane, for 18 exclusive lanes. Each task runs once per 18 eligible
ticks, a nominal 18-19 minutes because minute 59 is omitted, with independent
queue cursors and no writes for unchanged bookmarks.
Identity Mail send and reconciliation have separate invocations
(`* * * * *` and `1-59 * * * *`); KB ready hints and their isolated rate cleanup
use the existing `0-57 * * * *` lane. No cron is added for human controls.
invocation. With answering OFF, its 18 lanes cover Support queue repair,
inactive projection sweep, each Support/Admin/engineering rate policy,
Identity and Knowledge maintenance, and separately gated learning-review
work. Each runs once per 18 eligible ticks (nominally 18-19 minutes because
minute 59 is omitted). Unchanged bookmarks do not cause writes.

The distinct all-minute trigger (`*/1 * * * *`) belongs exclusively to
answering while processing is enabled. One physical invocation performs at
most one preparation or paid stage, under the same 25-second bound including
qualification; it never runs another maintenance job on that D1 allowance.
This gives two simultaneous admitted turns four minute-spaced stages within
the SDK's 300-second window, including across UTC midnight. The real Worker
[composition tests](../worker/src/support-assistant-root-composition.test.ts)
exercise this chronology with genuine Memory services and fictional provider
responses. The [Native tests](../worker/src/support-assistant-production.d1.test.ts)
separately meter every physical invocation at 50 D1 calls and 100 parameters.
These local proofs do not establish deployed CPU or provider acceptance.

While answering is enabled, its former global rate-window cleanup and
retrieval-readiness jobs each become one of 20 exhaustive cleanup lanes.
Their background throughput changes from roughly 90 seconds/3 minutes to
20-21 minutes; all other cleanup work remains in the rotation. Request-time
expiry and source/role proofs remain authoritative. With answering OFF, the
all-minute trigger retains the original 39 rate and 19 readiness pages per
hour and performs no Store work at minutes 58/59.

Identity Mail send and reconciliation keep their separate invocations
(`* * * * *` and `1-59 * * * *`), and release reconciliation retains its
six-hour window. The configuration still has five cron entries. Local parser and Native
validation cover the changed source separately;
Cloudflare backend acceptance of the distinct all-minute expression and
deployment remain operational checks.
Mail send for support
notifications is deferred (templates are defined; create/reply/staff reply omit
notification for this host surface).
Expand All @@ -419,7 +444,6 @@ store probe runs only when `SUPPORT_HEALTH_PROBE` is exactly `"true"`.

Built in the open by RetireGolden, LLC.


## Optional engineering human composition

The [engineering assembly](SUPPORT_ENGINEERING.md) uses policy version 6.
Expand All @@ -432,6 +456,54 @@ enabled callback and dependency bundle gate the router and staff-detail hints.
Human review has an additional strict current flag. The default Worker passes
no engineering configuration, leaving intake, review and processing OFF.

The optional [GitHub repository adapter](../worker/src/support-engineering-repository.ts)
supplies Application `repositoryMetadata`, the AI `github` ports and Application
`dispatchResults`. Its immutable allowlist identifies each repository, GitHub
App and installation. A trusted host issuer must supply current, expiring
App-JWT and installation-token authority. No issuer or live repository is
configured by default. Each operation starts with read-only
[installation discovery](https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app)
and [repository metadata](https://docs.github.com/en/rest/repos/repos#get-a-repository).
Public visibility alone does not prove installation membership. Exact repository
identity, visibility, installation and current host authority must agree.

The existing runtime accepts `adapter.github` through its `ports` option; pass
`adapter.repositoryMetadata` and `adapter.dispatchResults` to the existing
Application engineering options. Creation also requires a separate current
`issueCreationEnabled` callback, false when omitted. After the SDK durably starts
dispatch, creation [mints an installation token](https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app)
with the exact numeric repository ID and only metadata-read and issues-write
permissions. The bounded response must identify that single repository, selected
scope, exact permissions and a live expiry. Fresh trusted authority is checked
after minting. That ephemeral token supplies the exact SDK-approved title, body
and labels in one [issue POST](https://docs.github.com/en/rest/issues/issues#create-an-issue).
Credential minting and issue creation share the same operation deadline. The
issue payload contains the approved fields and marker. An uncertain write stays
with read-only reconciliation. Linking an existing issue records the private
Support association.

[Duplicate search](https://docs.github.com/en/rest/search/search#search-issues-and-pull-requests)
uses trusted ordinary search terms scoped to the configured repository and
issues, returning at most five candidates from one page. This bounded window
is not an exhaustive duplicate guarantee. Reconciliation requires a unique
exact SDK marker, direct issue readback and the expected GitHub App creator;
link reconciliation instead checks the exact existing issue ID and number.
Missing, incomplete, ambiguous or unavailable evidence stays unknown. The
Application verifier independently rereads that evidence and binds its result
to the SDK's retained dispatch identity. The marker does not attest the private
request hash. Reconciliation remains read-only after creation is disabled or
the local proposal body is withdrawn.

One total deadline bounds authentication and all requests to ten seconds or the
earlier caller deadline or credential expiry. An operation makes at most six
GitHub requests, with at most 64 KiB per response, a 24 KiB issue payload, no
pagination, retries or cached observations. The [metadata composition tests](../worker/src/support-engineering-repository.test.ts)
and [issue transport tests](../worker/src/support-engineering-github.test.ts)
use actual SDK policy, approval, dispatch and reconciliation over MemoryStore
with fictional external responses. This optional capability adds no processor,
scheduler or HTTP dispatch route, leaves the default Worker OFF, and does not
qualify a live installation or production export policy.

A configured staged-learning factory receives the same optional composition
as its third `create` argument. It composes `composeSupportEngineeringHuman`
into its existing `createSupportApi` call so current staff-detail hints and
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@pegma/support-desk-templates": "0.2.7",
"@pegma/webhooks": "0.1.1",
"agents": "^0.20.1",
"gpt-tokenizer": "4.1.2",
"zod": "^4.4.3"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading