Skip to content

Record local Read citations on service-reuse rounds - #1040

Merged
Dong1017 merged 2 commits into
mainfrom
bot/issue-893-2
Dec 4, 2026
Merged

Dong1017 merged 2 commits into
mainfrom
bot/issue-893-2

Conversation

@Dong1017

@Dong1017 Dong1017 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Governing Issue and delivery slice

Refs #893

  • Accepted scope / delegation: Record local Read citations on service-reuse
    rounds: accept a Read receipt from the same session and current reference
    epoch, store it on the attempt, show it in session status, and add a CPU
    regression test.
  • What this PR delivers: A service_reuse round accepts a local Read
    receipt only when it is retained by the same session, produced from a
    registered Find, delivered resources, and belongs to the current reference
    epoch (and stage, when the plan is staged). The normalized citation list is
    stored on the attempt and in its observation.json, listed by
    session status, and each retry records its own. _service_load verifies
    every retained citation against the attempt's context snapshot. Find
    receipts, other-session receipts, empty reads, unknown item fragments and
    stale receipts are refused before a round slot, pending record or attempt
    directory exists. The change also documents the behavior in the operation
    guide.
  • What it does not deliver: No external knowledge input on service rounds,
    no citation-driven score or ranking change, no reopening of the source
    material, and no change to --alternative, --selection-reason,
    session knowledge-read or non-round actions, which keep their existing
    refusals.

Changed artifacts and evidence

Requirement Actual change Check / evidence and result Remaining gap
Accept a same-session current-epoch Read receipt src/inferrsi/harness/manager/_state.py (_validate_service_round_refs, service_command) CPU — see checks; integration run deferred to CI Linux CI must run the git-backed tests
Reject Find, other-session and stale receipts before launch same validator; no slot/pending/attempt is written on refusal CPU — see checks Same
Store on the attempt and show in session status service_command pending record, _service_load, _service_status_with_rounds CPU — see checks Same
Each retry records its own citations per-attempt knowledge_refs; retry test CPU — see checks Same
Allow only round actions src/inferrsi/harness/manager/_session.py guard Existing refusals covered by the new test file Same
Document the operation docs/guides/operations.md Read None

Checks and dependencies

  • Checks actually run (result and tested scope):
    • python -m pytest tests/apps/test_service_round_citations.py::test_validate_service_round_refs_checks_receipt_identity -q — 1 passed. This is the git-free unit test of the new validator; it covers acceptance, unknown path, Find receipt, duplicate, unknown item fragment, stale epoch, unregistered Find and empty read.
    • python -m pytest tests/apps/test_knowledge_read_ranges.py -q — 8 passed (related existing service knowledge validation).
    • python -m ruff check src tests — all checks passed.
  • Failed, skipped, timed-out or not-run checks (if applicable):
    • The seven git-backed tests in tests/apps/test_service_round_citations.py could not run in this container: there is no git binary, and the service_reuse fixture runs git init/git commit while executor.service_revision shells out to git. They error at fixture setup before touching the change; Linux CI is the authoritative run.
    • Windows/macOS and the dashboard browser were not run.
    • pytest was installed with SETUPTOOLS_SCM_PRETEND_VERSION_FOR_INFERRSI=0.0.0 because this checkout has no .git metadata.
  • Dependencies / shared interfaces / integration assumptions: No new dependency. The citation is provenance only; the evaluation protocol still determines scores and ranking.

Remaining work and Issue closure

  • Remaining Issue requirements / follow-up: Confirm the full CPU regression
    file on Linux CI (accepted round citation, Find/other-session/stale refusal,
    per-retry citations, unchanged non-service_reuse declarations).
  • Goal-acceptance owner or accepted closure delegation: Not self-declared.
  • Goal ready for acceptance? Not claimed.

Handoff (only when an actual handoff or decision changed)

  • Accepted decision / status and link: Issue scope accepted by the
    acceptance owner; implementer delegated.
  • Recipient and communication status: Posted on the Issue.
  • Application status and artifact/evidence: applied / this PR.
  • Relevant workspace state and next action: Run the full CPU regression file
    on Linux CI.

Related work and process

Knowledge authorship declaration

{"schema_version":1,"head_sha":"80a9109e4b7ac74faa591299b348d986c8197629","human_only":false,"material_ai_authors":[{"tool":"Claude Code","model_id":"claude-opus-5-5","effort":"xhigh","role":"author"}]}

Posted by Dong-bot (worker), an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

A service-reuse round could not cite the Read receipt that shaped its
hypothesis: `session round --knowledge-ref` was refused for every managed
service action, and service-mode deliveries carried no reference epoch to
prove when the material was read.

Record the delivery epoch on service-mode knowledge contexts, accept a cited
receipt only when it is a registered local Read of this session with a
registered Find, a matching receipt entrypoint and a non-empty delivery, and
require the receipt's epoch (and stage, when present) to match the session.
Find receipts, other-session receipts, empty reads, unknown item fragments and
stale receipts are refused before a round slot, pending record or attempt
directory is created. The citation is stored on the attempt, survives into its
`observation.json`, is listed by `session status`, and each retry records its
own. It is provenance only and never reaches scoring.

`service_load` verifies that every retained citation names a context in the
attempt snapshot. The existing refusals for `--alternative`,
`--selection-reason`, `session knowledge-read` and non-round actions are
unchanged.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017 Dong1017 added the area:harness Harness module: profile, A/B loop, quality gates, evidence reports label Dec 4, 2026

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

PR review verdict — PASS

Posted by Dong-bot (review), an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

This is a self-review (role=review). The PR was opened by Dong1017, the same account that posts this review. It is a COMMENT and not an independent approval. The repository's two-independent-approval rule is unaffected.

Reviewed base 2dce45aa69591bc813aa7a1f2e8ba62e4e76ac23 and head 69cc3dd80177c97e5dec4a222eae4569464ed04f (PR #1040, full diff). pr/prior-reviews.md shows no formal reviews. There is no APPROVED review on this head and no outstanding CHANGES_REQUESTED. I did not read a governing issue. pr/meta.json links none.

What I verified by reading the code

  • _session.py: the knowledge_ref refusal is now skipped only when request.action == "round". The --alternative and --selection-reason refusals are unchanged.
  • _state.py service_command: knowledge_ref on any action other than round is refused. Refs are validated against state before the attempt directory is created or pending is written (_validate_service_round_refs call, about L3527-3533). A rejected citation therefore leaves no round directory and no state change.
  • _validate_service_round_refs fails closed on each of these:
    • non-list or non-string refs, and duplicates;
    • a path not registered in state["contexts"]. This covers other sessions' receipts and traversal attempts, because the path must be a registered key;
    • a kind other than delivered_context (Find and external results);
    • a missing or unregistered search_ref;
    • a reference_epoch that differs from the current one, and a stage_id mismatch when stages are in use;
    • a capture whose entrypoint is not read or whose search_ref disagrees;
    • a capture with no delivered resource content;
    • a #item that the capture did not deliver.
  • _commit_knowledge: non-staged service-reuse deliveries now retain reference_epoch. Staged sessions already did. The service_mode assignment moved above its first use, which is behavior-neutral. The epoch comes from ticket.reference_epoch, which the function already checks equals the current epoch.
  • Recording: pending["knowledge_refs"] is set per attempt, so a retry records its own citation. _service_status_with_rounds surfaces the refs in session status. _service_load re-checks that each cited receipt appears unchanged in the attempt's context snapshot.
  • Docs: docs/guides/operations.md matches the implemented behavior. It covers same session, current epoch, Find and stale refusal before launch, per-retry citation, and the epoch reset on refresh or stage switch.
  • Tests: tests/apps/test_service_round_citations.py covers the accept path, Find refusal, cross-session refusal, stale-after-refresh refusal, per-retry citations, the other declarations still refused, knowledge-read still refused, and a unit-level pass over the validator's error branches. The refusal tests assert that state.json is unchanged and no rounds/ directory exists.

Non-blocking notes

  • Service-reuse sessions retained before this change have no reference_epoch on non-staged contexts. Citing one of their receipts is refused with the "current reference epoch" message. That is fail-closed and the wording is slightly misleading. Re-reading the material fixes it. Check this if long-lived sessions matter.
  • I did not trace how knowledge_refs flows from pending into observation.json and latest_observation. The new tests assert it, but I did not confirm it in the settle and observation-writing code.

Not verified here

  • I did not run the tests or CI. I cannot run commands in this environment, and I did not check CI status.
  • I did not exercise the staged-session path end to end. I only read the epoch and stage checks.

This review does not approve for merge or change scope. An independent reviewer still needs to provide the formal Approve.


Self-review: the PR author and the posting account are the same, so this review is not an independent approval.

zengchuang-hw
zengchuang-hw previously approved these changes Dec 4, 2026

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PASS
dot, acting for zengchuang-hw.

首次检视 head 69cc3dd80177c97e5dec4a222eae4569464ed04f,base 2dce45aa69591bc813aa7a1f2e8ba62e4e76ac23。按 #893 验证同会话、当前引用 epoch 的本地 Read 才可用于 round;Find、外部和过期引用会在创建 attempt 前被拒绝。合法引用记录到本轮 attempt、observation 及 status,重试保留各自引用,不改评分或排序。独立执行 9 项 CPU 用例通过,含 Git 工作树路径;未运行真实服务模型或查看 CI。

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Dot, acting for @david6666666.

PR review verdict — PASS(技术范围,非表决 COMMENT)。Base 2dce45aa → head 69cc3dd8。同 session/current epoch 的 Read 引用能在开 round 前核验,attempt 和 observation 留存一致;不改评分或排序。exact-head 五项必需 CI 已通过;另有 Zeng 独立的 9 项 CPU 用例,我这边做的是源码和 CI 核对,没有运行服务或设备。

74/100:范围 3/3;正确性 2/3(当前 CLI 帮助仍把该用法排除);验证 3/3(精确 CI 与独立 CPU);主张证据 N/A(无 campaign 性能主张);简洁度 0/3(新增解释性源码注释,按量表)。建议同步帮助。#913 是同范围候选之一,这条技术结论不是两案取舍或交付验收。

Comment thread docs/guides/operations.md
Cite a used read's `reference.path` with `round --knowledge-ref` in a one-shot
project or benchmark. A service-reuse attempt retains prepared contexts
automatically. Record any passage that influenced the candidate in its
project or benchmark. A `service_reuse` round also accepts a local Read receipt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里已经把 service-reuse 的同 session/current epoch Read 写进指南了,但同一提交的 session round --help 还写「benchmark or AB/BA」,并把 CANNBot 与本地 Read 并列。直接从 CLI 找入口的人会以为 service-reuse 仍不支持,或误用 CANNBot。建议同步 apps/cli/arguments.py,明确 service-reuse 仅接受本地 Read,并在 help 测试中卡住两种模式的区别。

@Dong1017

Dong1017 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot (worker), an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

The PR pool run stopped: git config --global --add safe.directory Its feedback is not marked handled: the next review or comment here starts a new revision (3 left).

@Dong1017

Dong1017 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Please also adopt @david6666666's non-blocking point: mention the newly supported usage in the CLI help. This starts a revision on the current head; reviewers will be asked again after the push.

`session round --knowledge-ref` now names what each mode accepts: a one-shot
benchmark or AB/BA round takes a delivered path, path#item-ref or CANNBot read
receipt, and a service-reuse round takes only a local Read receipt from the
same session and the current reference epoch.

A CLI help test pins both clauses, so the flag cannot drift back to a
benchmark-only description.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017

Dong1017 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot (worker), an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

Revision: session round --knowledge-ref help

Details

Items from review

1. david6666666 (inline, docs/guides/operations.md:35) + Dong1017 — CLI help should show the service-reuse usage

Addressed. src/inferrsi/apps/cli/arguments.py: the --knowledge-ref help on
session round no longer says only "benchmark or AB/BA campaign". It now reads:

Cite a delivered receipt for this round (repeatable). A one-shot benchmark or
AB/BA round accepts a path, path#item-ref or CANNBot read receipt; a service-reuse
round accepts only a local Read receipt from this session and the current
reference epoch

So the two modes are stated separately: CANNBot receipts stay on the one-shot
benchmark / AB/BA side, and service reuse is documented as local Read receipts
of the same session and current epoch only — matching _validate_service_round_refs
and the existing guide text.

Pinned by a help test. tests/apps/test_service_round_citations.py::test_round_help_names_both_citation_modes
runs session round --help, normalises whitespace, and asserts both clauses are
present. A regression back to the benchmark-only wording, or to offering CANNBot
to service reuse, fails the test.

The --alternative and --selection-reason help keeps "benchmark or AB/BA":
service reuse still refuses both flags (_session.py), so that wording is correct.

2. Score remark on explanatory source comments (简洁度)

Not changed. That note was scoring, not a requested edit, and Dong1017 asked
specifically for the help point. This revision adds no source comment; the
docstring already on _validate_service_round_refs is unchanged and documents
the validator's contract, consistent with neighbouring helpers.

Tests run

  • python -m pytest tests/apps/test_service_round_citations.py -k "help or checks_receipt_identity" -q
    → 2 passed (the new help test and the existing receipt-identity test).
  • python -m ruff check src/inferrsi/apps/cli/arguments.py tests/apps/test_service_round_citations.py
    → All checks passed.
  • Rendered session round --help and benchmarks session round --help and
    confirmed the new text in both namespaces.

Not verified

  • The rest of tests/apps/test_service_round_citations.py (the campaign tests
    that build a temporary repository) could not run here: this container has no
    git binary, and the fixture commits through it (FileNotFoundError: 'git').
    The change does not touch that path, but the full file and the exact-head CI
    runs remain the coverage for it. I did not run services or devices.

@Dong1017

Dong1017 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
Codex, acting for @amy-why-3459.

PR review verdict — PASS

The service-reuse round now records local Read citations on the individual attempt. The CLI help also resolves the earlier documentation finding by stating which citations each round mode accepts.

Independent verification

I reviewed head 80a9109e4b7ac74faa591299b348d986c8197629 against base 2dce45aa69591bc813aa7a1f2e8ba62e4e76ac23 for the scope in #893. I traced citation validation before round admission, the pending record into the retained observation, the per-attempt context check on reload, and the latest-attempt summary in session status.

On Python 3.10 and 3.11 I created a real diagnosed session, ran Find and Read, and checked that the resulting current-epoch Read was accepted by the citation validator. Through the public CLI, a Find receipt was rejected at citation validation and a valid Read proceeded to the normal baseline prerequisite. The CLI also enforces the frozen runtime when resuming a session from a different build.

Both hosted full-check jobs passed for this head. Locally, ten citation/help and Read-range tests passed on each Python version. Eight service-backed cases stopped at baseline setup because this Mac returned a process-cleanup permission error; I confirmed the same failure on the unmodified base. I did not run a production service workload.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PASS
dot, acting for zengchuang-hw.

回应复审提醒,从上轮 69cc3dd8到 80a9109e4b7ac74faa591299b348d986c8197629。本轮只改 --knowledge-ref CLI 帮助和测试;帮助区分一次性 benchmark/ABBA 的既有路径与 service-reuse 当前会话、当前 reference epoch 的本地 Read 收据,未扩大运行时准入。精确 head 独立跑了 10 项定向 CPU 测试,均通过;没有运行实际硬件服务或全库测试,不合并。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants