Skip to content

feat(kdo): integrate H5-R2B H2 repeat-call advisory - #67

Merged
TheHalfMoon merged 2 commits into
mainfrom
feat/kdo-h5-r2b-h2-repeat-advisory
Aug 15, 2026
Merged

feat(kdo): integrate H5-R2B H2 repeat-call advisory#67
TheHalfMoon merged 2 commits into
mainfrom
feat/kdo-h5-r2b-h2-repeat-advisory

Conversation

@TheHalfMoon

@TheHalfMoon TheHalfMoon commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Implements canonical KDO-H5-R2B — H2-BOUND REPEAT-CALL ADVISORY INTEGRATION under the original authorization plus canonical reconciliations C1 and C2.

Exact certified identity

CANONICAL BASE:
67a68faabb42d8472f6b5e68a2246ae1e2813bb0

ACCEPTED PRE-LEDGER HEAD:
ad41442423e5f6e6fb260fabc4e28dba0fb52adf

ACCEPTED PRE-LEDGER TREE:
ab6d0dd46853f684a4afd2460651a4c95d955985

LEDGER / CURRENT EXPECTED HEAD:
07fb9cf787155d19d75dd369c951f7444525e452

CURRENT TREE:
495477a2cd2af9c7eaa8f596bcf6365a58d907f8

PRE-LEDGER GATE:
PASS

POST-LEDGER CERTIFICATION:
PASS

UNRESOLVED REVIEW THREADS:
0

AUTO-MERGE:
DISABLED

The only delta from accepted pre-ledger head ad414424... to current head 07fb9cf... is the authorized evidence ledger:

docs/planning/KODAC_KDO_H5_R2B_H2_REPEAT_CALL_ADVISORY_EVIDENCE_2026-08-15.md

Certified implementation

  • fixed active repeat policy [2], identity 7331f353c9a29af123cd54fa99453768b35fe2534db5d009df9dae67cdc80222;
  • serialized/validated R2A advisory signals while preserving all canonical R2A identity vectors;
  • specialized model.history.repeat_call_advisory.appended H2 event;
  • H2 advisory record binds request anchor + exact assistant history record + exact triggering tool-result record + validated R2A signal;
  • projection re-derives tool name/input fingerprint from those source records before accepting the advisory;
  • exact fixed model-visible role=system advisory with no tool name/id/raw args/preview/result content;
  • only successfully completed matched tool-call/result pairs advance R2B state;
  • failed turns reset local R2B state;
  • stale same-batch signals are suppressed when the final active chain changes;
  • assistant + all tool results + optional advisory are aggregate-bound before first history append;
  • local repeat state commits only after complete history persistence;
  • advisory sink failure is not swallowed and prevents a later provider request;
  • existing hard duplicate/cycle guards remain authoritative and unchanged;
  • no K2/policy/approval/confinement/Done Gate authority added.

C1 historical-test reconciliation

Exactly five historical tests were minimally reconciled. No test was deleted, skipped, disabled, or broadly weakened.

  • H2-R2 permits only the pure local R2A dependency while retaining ambient authority bans.
  • H4-R2B/R2C replace obsolete loop byte pins with explicit no-Landlock/no-confinement coupling assertions.
  • H5-R1A remains non-integrated in both loop and H2.
  • H5-R2A fixed vectors, strict canonicalization/bounds, donor pin, and primitive no-authority contract remain protected; only the historical pre-R2B non-integration assertion is superseded.

C2 K3 applicability

The complete 11-path ledger-bearing diff has empty intersection with the canonical K3-R4 and K3-R5 pull_request.paths trigger sets. Therefore on this exact head:

K3-R4 = NOT_APPLICABLE_PATH_FILTER_PROVEN
K3-R5 = NOT_APPLICABLE_PATH_FILTER_PROVEN

No unrelated trigger path was touched merely to force workflow scheduling.

Exact-head post-ledger evidence

For 07fb9cf787155d19d75dd369c951f7444525e452:

  • governance — PASS
  • provenance — PASS
  • legacy-tests — PASS
  • runtime-change-classifier — PASS
  • macOS Typecheck/Test — PASS
  • Ubuntu Typecheck/Test — PASS
  • Windows Typecheck/Test — PASS
  • k2-runtime-gate — PASS
  • CodeRabbit — SUCCESS
  • unresolved review threads — 0
  • manual exact-head H2/security/authority/historical-test review — PASS

Explicit boundaries

No denied/failed attempt counting without canonical completed tool-result evidence. No user-role reminder injection. No raw argument preview. No hard duplicate/cycle relaxation. No H5-R1A activation. No H5-R3 guarded tool pipeline. No subagents/delegation/worktree/Git writes. No K2/approval/confinement/Done Gate change. No H5 completion or H6 readiness claim.

The bounded claim KODAC_H2_BOUND_REPEAT_CALL_ADVISORY_PROVEN remains unavailable until this exact certified head is merged into canonical main.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@TheHalfMoon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 56a63cc6-841b-48a2-b4f9-6d5f1eef84e5

📥 Commits

Reviewing files that changed from the base of the PR and between 67a68fa and 07fb9cf.

📒 Files selected for processing (11)
  • docs/planning/KODAC_KDO_H5_R2B_H2_REPEAT_CALL_ADVISORY_EVIDENCE_2026-08-15.md
  • packages/kodac-runtime/src/agent/loop.ts
  • packages/kodac-runtime/src/agent/repeat-call-signal.ts
  • packages/kodac-runtime/src/protocol/event.ts
  • packages/kodac-runtime/src/session/model-visible-history.ts
  • packages/kodac-runtime/test/kdo-h2-r2-event-derived-history.test.ts
  • packages/kodac-runtime/test/kdo-h4-r2b-linux-landlock-backend.test.ts
  • packages/kodac-runtime/test/kdo-h4-r2c-k2-linux-landlock-read-only.test.ts
  • packages/kodac-runtime/test/kdo-h5-r1a-tool-result-pruning.test.ts
  • packages/kodac-runtime/test/kdo-h5-r2a-repeat-call-signal.test.ts
  • packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts

Comment @coderabbitai help to get the list of available commands.

@TheHalfMoon
TheHalfMoon force-pushed the feat/kdo-h5-r2b-h2-repeat-advisory branch from 0c91b48 to ad41442 Compare August 14, 2026 23:56
@TheHalfMoon
TheHalfMoon marked this pull request as ready for review August 15, 2026 00:02
@TheHalfMoon
TheHalfMoon merged commit f99c8e3 into main Aug 15, 2026
9 of 10 checks passed
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

feat(kdo): H5-R2B H2-bound repeat-call advisory integration

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Integrates the R2A repeat-call signal into the agent loop as a fixed, model-visible system
 advisory emitted via a new model.history.repeat_call_advisory.appended H2 event.
• Advisory records are strictly source-bound: the projector re-derives tool name/input/fingerprint
 from the exact triggering assistant/tool-result history records before accepting a signal.
• Adds serialization/validation for R2A advisory signals, canonical-policy enforcement (fixed
 threshold [2]), same-batch stale-signal suppression, and failure-safe history persistence
 (assistant + tool results + advisory bound atomically; sink failures are not swallowed).
• Reconciles five historical tests (H2-R2, H4-R2B/R2C, H5-R1A, H5-R2A) to reflect the new
 loop/history integration without weakening their protections; existing hard duplicate/cycle guards
 and K2/confinement authority remain unchanged.
• Adds a new focused test suite (kdo-h5-r2b-repeat-call-advisory-history.test.ts) and a governance
 evidence ledger documenting the certification chain.
Diagram

graph TD
  Loop["BoundedAgentLoop"] --> Signal["repeat-call-signal.ts"] --> Loop
  Loop --> Advisory["Advisory Record Builder"] --> Session["RuntimeSession.emit()"]
  Session --> EventLog[(Event Journal)]
  EventLog --> Projector["model-visible-history.ts"]
  Projector -->|"re-derive & verify signal"| Signal
  Projector --> Provider["Next Provider Request"]
  subgraph Legend
    direction LR
    _mod([Module]) ~~~ _db[(Event Journal)]
  end
Loading
High-Level Assessment

The PR's approach—deriving and re-validating the advisory signal from canonical source records at projection time rather than trusting an opaque payload—is the correct design for an auditable, tamper-resistant history model already established by prior H2/H5 primitives (R2A signal, H2-R2 event-sourced projection). Alternatives like storing raw tool name/args in the advisory or using a mutable in-memory repeat tracker (as the DeepCode donor does) were explicitly considered and rejected because they would leak sensitive data into model-visible content or introduce non-reconstructible state, which conflicts with the codebase's event-sourcing and no-hidden-state conventions.

Files changed (11) +1721 / -34

Enhancement (4) +429 / -12
loop.tsWire R2A repeat-call observation into the agent loop +118/-11

Wire R2A repeat-call observation into the agent loop

• Observes each turn's matched tool-call/result pairs to advance the repeat-call signal, builds and aggregate-binds an optional advisory record with the assistant/tool-result batch before first history append, resets local state on failed turns, and commits repeat state only after successful persistence.

packages/kodac-runtime/src/agent/loop.ts

repeat-call-signal.tsAdd serialization/validation for repeat-call advisory signals +93/-0

Add serialization/validation for repeat-call advisory signals

• Adds signal JSON serialization and a strict validator that independently recomputes identities/fingerprints and rejects unknown fields or tampering, exposing the resulting signal JSON on transitions.

packages/kodac-runtime/src/agent/repeat-call-signal.ts

event.tsAdd repeat_call_advisory event type +2/-1

Add repeat_call_advisory event type

• Registers the new 'model.history.repeat_call_advisory.appended' event type in the Kodac event protocol union.

packages/kodac-runtime/src/protocol/event.ts

model-visible-history.tsAdd H2 advisory history record creation, validation, and projection binding +216/-0

Add H2 advisory history record creation, validation, and projection binding

• Introduces a fixed system-role advisory message/record type bound to canonical policy/threshold, validates and re-derives tool name/input/fingerprint from the referenced assistant/tool-result records during projection, and rejects unbound or stale signals.

packages/kodac-runtime/src/session/model-visible-history.ts

Tests (6) +428 / -22
kdo-h2-r2-event-derived-history.test.tsUpdate projector import allowlist for new signal dependency +2/-1

Update projector import allowlist for new signal dependency

• Adds the repeat-call-signal module to the expected import list for the H2-R2 projector purity test.

packages/kodac-runtime/test/kdo-h2-r2-event-derived-history.test.ts

kdo-h4-r2b-linux-landlock-backend.test.tsReplace agent-loop byte pin with no-authority coupling assertion +6/-5

Replace agent-loop byte pin with no-authority coupling assertion

• Swaps the frozen loop.ts blob-hash assertion for a regex check proving the loop does not import Landlock/confinement authority, reflecting the intentional R2B supersession.

packages/kodac-runtime/test/kdo-h4-r2b-linux-landlock-backend.test.ts

kdo-h4-r2c-k2-linux-landlock-read-only.test.tsReplace agent-loop byte pin with no-authority coupling assertion +2/-2

Replace agent-loop byte pin with no-authority coupling assertion

• Same reconciliation as H4-R2B: replaces the loop.ts blob pin with a no-Landlock/no-confinement-import assertion.

packages/kodac-runtime/test/kdo-h4-r2c-k2-linux-landlock-read-only.test.ts

kdo-h5-r1a-tool-result-pruning.test.tsExtend non-integration proof to model-visible-history.ts +4/-4

Extend non-integration proof to model-visible-history.ts

• Adds assertions that pruning helpers are absent from model-visible-history.ts and removes now-superseded byte pins for loop.ts, model-visible-history.ts, and event.ts.

packages/kodac-runtime/test/kdo-h5-r1a-tool-result-pruning.test.ts

kdo-h5-r2a-repeat-call-signal.test.tsRelax superseded byte pins for R2B-integrated files +4/-10

Relax superseded byte pins for R2B-integrated files

• Removes obsolete assertions that loop.ts must not reference repeat-call-signal, and drops now-superseded blob pins for loop.ts, model-visible-history.ts, and event.ts while retaining R2A's fixed vectors and no-authority contract.

packages/kodac-runtime/test/kdo-h5-r2a-repeat-call-signal.test.ts

kdo-h5-r2b-repeat-call-advisory-history.test.tsAdd focused R2B repeat-call advisory test suite +410/-0

Add focused R2B repeat-call advisory test suite

• New test file covering signal serialization/validation, hostile-input hardening, deterministic advisory record creation, source-binding rejection, loop integration ordering, batch suppression semantics, failure resets, and advisory sink-failure handling.

packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts

Documentation (1) +864 / -0
KODAC_KDO_H5_R2B_H2_REPEAT_CALL_ADVISORY_EVIDENCE_2026-08-15.mdAdd H5-R2B evidence/governance ledger +864/-0

Add H5-R2B evidence/governance ledger

• New 864-line governance ledger documenting the certification chain, authorization/reconciliation references, protected-blob pins, and pre/post-ledger gate requirements for the H5-R2B feature.

docs/planning/KODAC_KDO_H5_R2B_H2_REPEAT_CALL_ADVISORY_EVIDENCE_2026-08-15.md

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Forged repeat state accepted 🐞 Bug ⛨ Security
Description
The projector compares only the bound call fields, so a signal with arbitrary priorStateIdentity
and nextStateIdentity is accepted once its unkeyed SHA-256 identity is recomputed. This permits a
threshold-two system advisory without a canonical count-1-to-count-2 R2A transition.
Code

packages/kodac-runtime/src/session/model-visible-history.ts[R493-496]

+  if (
+    derived.nextState.toolName !== signal.toolName ||
+    derived.nextState.toolInputIdentity !== signal.toolInputIdentity ||
+    derived.nextState.callFingerprint !== signal.callFingerprint
Relevance

●● Moderate

Strengthening signal/state binding is security-significant but may be seen as over-constraining
canonical derivation; no close precedent.

PR-#49

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The projector derives only a count-one state and ignores both state identities, while the signal
validator merely hashes the identities supplied in the signal. The canonical transition
implementation can derive the exact expected prior state, next state, and complete signal.

packages/kodac-runtime/src/session/model-visible-history.ts[488-498]
packages/kodac-runtime/src/agent/repeat-call-signal.ts[607-620]
packages/kodac-runtime/src/agent/repeat-call-signal.ts[623-668]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The advisory source-binding check validates only tool identity fields and does not prove that the signal's prior and next state identities are the canonical count-1 and count-2 states.

## Issue Context
`validateRepeatCallAdvisorySignalJson` establishes internal hash consistency, not authenticity or derivation from the bound call. Derive the first transition from `null`, derive the second transition from that state, and compare the supplied canonical signal against the complete expected threshold-two signal.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[488-498]
- packages/kodac-runtime/src/agent/repeat-call-signal.ts[607-620]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Proxy payload executes traps 🐞 Bug ☼ Reliability
Description
The new advisory-record validator reflects over caller-owned payload objects before rejecting them,
allowing Proxy traps to execute during journal projection. This violates the hostile-input
validation boundary and can cause side effects or denial of service.
Code

packages/kodac-runtime/src/session/model-visible-history.ts[R381-383]

+export function validateRepeatCallAdvisoryHistoryRecord(value: unknown): RepeatCallAdvisoryHistoryRecord {
+  const record = asPlainRecord(value, "repeatCallAdvisoryHistoryRecord")
+  exactKeys(record, ADVISORY_RECORD_KEYS, "repeatCallAdvisoryHistoryRecord")
Relevance

●●● Strong

Proxy-trap-free validation is a proven team priority; same reflection pattern was fixed before.

PR-#56

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
validateRepeatCallAdvisoryHistoryRecord immediately calls helpers that use
Object.getPrototypeOf, Object.getOwnPropertySymbols, and Object.getOwnPropertyDescriptors on
the supplied value. The added hostile-input test covers only the inner primitive signal string, and
past PR #56 documents the same Proxy-trap failure pattern in record validation.

packages/kodac-runtime/src/session/model-visible-history.ts[149-176]
packages/kodac-runtime/src/session/model-visible-history.ts[381-395]
packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[120-149]
PR-#56

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A Proxy supplied as an advisory event payload can execute traps when the validator inspects its prototype, keys, or descriptors.

## Issue Context
The primitive signal-string validator is hook-free, but the outer advisory record is not. Introduce a serialized or otherwise hook-free boundary before reflective object validation, and add tests proving no Proxy trap runs through both the direct validator and projector paths.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[149-176]
- packages/kodac-runtime/src/session/model-visible-history.ts[381-395]
- packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[120-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Duplicate advisories project repeatedly 🐞 Bug ≡ Correctness
Description
A separately sequenced event can replay the same advisory payload because the projector does not
track consumed record identities, signal identities, or source tuples. Each replay appends another
system message for the same threshold crossing.
Code

packages/kodac-runtime/src/session/model-visible-history.ts[R571-573]

+      assertRepeatAdvisorySourceBinding(record, assistantRecord, toolResultRecord)
      projected = [...projected, record.message]
      assertProjectedBounds(projected)
Relevance

●● Moderate

Deduping replayed advisory events seems plausible, but projector already relies on sequence guards;
no matching precedent.

PR-#49

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Assistant and tool-result identities are tracked, but there is no corresponding advisory-consumption
set; the advisory branch unconditionally appends every independently valid event. Existing
projection coverage contains only one advisory event.

packages/kodac-runtime/src/session/model-visible-history.ts[512-513]
packages/kodac-runtime/src/session/model-visible-history.ts[557-574]
packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[195-203]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The same valid advisory payload can be replayed at a later contiguous event sequence and will be projected repeatedly.

## Issue Context
Define the intended uniqueness key, such as advisory record identity or signal/source tuple, track it within each request anchor, and reject a second use. Add a projection regression with two increasing-sequence events carrying the same advisory payload.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[512-513]
- packages/kodac-runtime/src/session/model-visible-history.ts[557-574]
- packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[195-203]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Stale batch advisory accepted 🐞 Bug ≡ Correctness
Description
Source binding accepts a matching call anywhere in the assistant batch without proving that its
fingerprint remains the final active chain. Consequently, an advisory for A in an A,A,B batch can be
projected after B has reset the chain.
Code

packages/kodac-runtime/src/session/model-visible-history.ts[R480-482]

+  const matchingCalls = (assistantRecord.message.toolCalls ?? []).filter(
+    (call) => call.id === toolResultId && call.name === toolResultName,
+  )
Relevance

●● Moderate

Batch-final-call binding semantics are subtle; no close historical decision found for this exact
projector edge case.

PR-#49

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The projector only finds one matching call and compares its identity; it never evaluates later calls
in that assistant message. By contrast, the loop explicitly clears a pending advisory when a later
call changes the fingerprint.

packages/kodac-runtime/src/session/model-visible-history.ts[480-498]
packages/kodac-runtime/src/agent/loop.ts[250-280]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Projection accepts an advisory tied to an earlier call even when a later completed call in the same batch changes the active repeat chain.

## Issue Context
Preserve legitimate A,A,A behavior while rejecting A,A,B: process the ordered assistant calls and corresponding seen results after the triggering call, and require the advisory fingerprint to remain the final active chain before appending it. Add a direct projector regression for an A,A,B event history.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[470-500]
- packages/kodac-runtime/src/session/model-visible-history.ts[557-573]
- packages/kodac-runtime/src/agent/loop.ts[250-280]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context
Review mode: 🧠 Deep: This is a security- and history-integrity-sensitive runtime integration with substantial new logic across loop, signal validation, projection, event persistence, and many independent test reconciliations, creating multiple plausible subtle defects.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +493 to +496
if (
derived.nextState.toolName !== signal.toolName ||
derived.nextState.toolInputIdentity !== signal.toolInputIdentity ||
derived.nextState.callFingerprint !== signal.callFingerprint

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Forged repeat state accepted 🐞 Bug ⛨ Security

The projector compares only the bound call fields, so a signal with arbitrary priorStateIdentity
and nextStateIdentity is accepted once its unkeyed SHA-256 identity is recomputed. This permits a
threshold-two system advisory without a canonical count-1-to-count-2 R2A transition.
Agent Prompt
## Issue description
The advisory source-binding check validates only tool identity fields and does not prove that the signal's prior and next state identities are the canonical count-1 and count-2 states.

## Issue Context
`validateRepeatCallAdvisorySignalJson` establishes internal hash consistency, not authenticity or derivation from the bound call. Derive the first transition from `null`, derive the second transition from that state, and compare the supplied canonical signal against the complete expected threshold-two signal.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[488-498]
- packages/kodac-runtime/src/agent/repeat-call-signal.ts[607-620]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +571 to 573
assertRepeatAdvisorySourceBinding(record, assistantRecord, toolResultRecord)
projected = [...projected, record.message]
assertProjectedBounds(projected)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Duplicate advisories project repeatedly 🐞 Bug ≡ Correctness

A separately sequenced event can replay the same advisory payload because the projector does not
track consumed record identities, signal identities, or source tuples. Each replay appends another
system message for the same threshold crossing.
Agent Prompt
## Issue description
The same valid advisory payload can be replayed at a later contiguous event sequence and will be projected repeatedly.

## Issue Context
Define the intended uniqueness key, such as advisory record identity or signal/source tuple, track it within each request anchor, and reject a second use. Add a projection regression with two increasing-sequence events carrying the same advisory payload.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[512-513]
- packages/kodac-runtime/src/session/model-visible-history.ts[557-574]
- packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[195-203]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +480 to +482
const matchingCalls = (assistantRecord.message.toolCalls ?? []).filter(
(call) => call.id === toolResultId && call.name === toolResultName,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Stale batch advisory accepted 🐞 Bug ≡ Correctness

Source binding accepts a matching call anywhere in the assistant batch without proving that its
fingerprint remains the final active chain. Consequently, an advisory for A in an A,A,B batch can be
projected after B has reset the chain.
Agent Prompt
## Issue description
Projection accepts an advisory tied to an earlier call even when a later completed call in the same batch changes the active repeat chain.

## Issue Context
Preserve legitimate A,A,A behavior while rejecting A,A,B: process the ordered assistant calls and corresponding seen results after the triggering call, and require the advisory fingerprint to remain the final active chain before appending it. Add a direct projector regression for an A,A,B event history.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[470-500]
- packages/kodac-runtime/src/session/model-visible-history.ts[557-573]
- packages/kodac-runtime/src/agent/loop.ts[250-280]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +381 to +383
export function validateRepeatCallAdvisoryHistoryRecord(value: unknown): RepeatCallAdvisoryHistoryRecord {
const record = asPlainRecord(value, "repeatCallAdvisoryHistoryRecord")
exactKeys(record, ADVISORY_RECORD_KEYS, "repeatCallAdvisoryHistoryRecord")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. Proxy payload executes traps 🐞 Bug ☼ Reliability

The new advisory-record validator reflects over caller-owned payload objects before rejecting them,
allowing Proxy traps to execute during journal projection. This violates the hostile-input
validation boundary and can cause side effects or denial of service.
Agent Prompt
## Issue description
A Proxy supplied as an advisory event payload can execute traps when the validator inspects its prototype, keys, or descriptors.

## Issue Context
The primitive signal-string validator is hook-free, but the outer advisory record is not. Introduce a serialized or otherwise hook-free boundary before reflective object validation, and add tests proving no Proxy trap runs through both the direct validator and projector paths.

## Fix Focus Areas
- packages/kodac-runtime/src/session/model-visible-history.ts[149-176]
- packages/kodac-runtime/src/session/model-visible-history.ts[381-395]
- packages/kodac-runtime/test/kdo-h5-r2b-repeat-call-advisory-history.test.ts[120-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

1 participant