Skip to content

Implement RequestSnapshot export contract: Intent/Context inclusion, secret redaction, ScriptBlock prevention, and 64 KB per-field size limits#221

Merged
blindzero merged 3 commits intomainfrom
copilot/define-request-snapshot-contract
Feb 22, 2026
Merged

Implement RequestSnapshot export contract: Intent/Context inclusion, secret redaction, ScriptBlock prevention, and 64 KB per-field size limits#221
blindzero merged 3 commits intomainfrom
copilot/define-request-snapshot-contract

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

  • Add size limit enforcement in ConvertTo-IdlePlanExportObject.ps1 (64 KB per field; deterministic truncation marker [TRUNCATED - N bytes])
  • Fix size limit enforcement to also cover PSCustomObject-shaped request.input (not only IDictionary) — addresses review feedback
  • Add tests/Core/RequestSnapshot.Tests.ps1 with 11 explicit tests for Intent, Context, ScriptBlock redaction at export boundary, and size limits (including PSCustomObject path)
  • Update docs/reference/specs/plan-export.md: fix desiredStateintent/context; add input sub-fields table; add Safety rules section (secrets, ScriptBlocks, size limits)
Original prompt

This section details on the original issue you should resolve

<issue_title>Plan snapshot/export contract for Request.Intent and Request.Context (auditability + safety)</issue_title>
<issue_description>## Problem Statement

IdLE produces plans that may be executed later. Operators and automated hosts need plan artifacts to be auditable and safe to store/share.

With the introduction of Request.Intent and Request.Context, we must define a deterministic plan snapshot/export contract:

  • What request data is captured in the exported plan
  • How secrets are prevented from leaking into artifacts
  • How size and serialization stability are enforced

Without explicit rules, plan artifacts become:

  • non-reproducible (planning depended on data not captured),
  • unsafe (secrets included),
  • unbounded in size,
  • inconsistent across hosts.

Proposed Solution

1) Define a deterministic RequestSnapshot contract

Plan export MUST include a RequestSnapshot containing at minimum:

  • CorrelationId
  • Actor
  • IdentityKeys
  • LifecycleEvent
  • Request.Intent (canonical intent/action inputs)
  • Request.Context (canonical associated context)

2) Enforce safety rules

The snapshot/export pipeline MUST enforce:

  • Secret prevention (reject or redact; decision must be explicit and documented):
    • passwords, tokens, refresh tokens, client secrets, session keys, private keys, etc.
  • Executable / unsafe type prevention:
    • reject ScriptBlocks, delegates, non-serializable objects, provider runtime handles
  • Size limits:
    • define a maximum total snapshot size and/or per-field limits
    • define deterministic truncation/redaction behavior

3) Stable serialization requirements

  • Exported snapshot must be stable and predictable (order-insensitive where possible).
  • Use safe serialization; avoid embedding raw .NET object graphs.

Alternatives Considered

  1. Export only minimal metadata (no intent/context)
    • Hurts auditability and troubleshooting.
  2. Export the full original request object
    • Too risky (secrets, non-serializable objects, host-specific payloads).

Impact

  • Plan artifacts become more informative but may increase in size (bounded by limits).
  • Hosts/tools consuming plan exports may need to tolerate the updated snapshot structure.

Dependencies

  • Requires Issue 1 (schema: Request.Intent and Request.Context).

Definition of Done (Step-0-Ready / Agent-Safe)

Design / Contracts

  • Specify exact RequestSnapshot shape (fields, nesting, naming).
  • Specify the secret-handling policy:
    • reject vs redact (and for which categories)
  • Specify snapshot size limits and deterministic truncation/redaction rules.
  • Specify stable serialization requirements and prohibited types.

Implementation

  • Implement RequestSnapshot generation including Request.Intent and Request.Context.
  • Implement safety enforcement (secret prevention, type checks, size limits).
  • Ensure plan export uses the canonical paths introduced by Issue 1.

Tests (Pester)

  • Snapshot includes Request.Intent and Request.Context.
  • Secret-like fields are rejected/redacted according to spec.
  • Non-serializable/executable types are rejected.
  • Size limit behavior is deterministic and testable.

Docs / Examples

  • Document snapshot content and safety rules.
  • Provide an example plan export showing the snapshot structure.

Non-Goals

  • No planning-time context resolver feature in this issue.
  • No runtime execution guard feature in this issue.</issue_description>

<agent_instructions>we do not care about legacy. no references, no tests, no aliases or such</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…d Request.Context

- Add Limit-IdleSnapshotField helper and per-field 64 KB size limits in
  ConvertTo-IdlePlanExportObject; oversized identityKeys/intent/context
  fields are replaced with a deterministic [TRUNCATED - N bytes] marker
- Add tests/Core/RequestSnapshot.Tests.ps1: 10 tests covering Intent/Context
  inclusion, ScriptBlock redaction at export boundary, and size limit behaviour
- Update docs/reference/specs/plan-export.md: fix desiredState → intent/context,
  add input sub-fields table, add Safety rules section (secrets, ScriptBlocks, size)"

Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Copilot AI changed the title [WIP] Define snapshot/export contract for Request.Intent and Request.Context Implement RequestSnapshot export contract: Intent/Context inclusion, secret redaction, ScriptBlock prevention, and 64 KB per-field size limits Feb 22, 2026
Copilot AI requested a review from blindzero February 22, 2026 17:15
@blindzero blindzero marked this pull request as ready for review February 22, 2026 17:33
Copilot AI review requested due to automatic review settings February 22, 2026 17:33
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b095ed3a3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a deterministic RequestSnapshot export contract for plan artifacts, ensuring they are auditable and safe to store/share. It adds Intent and Context inclusion, secret redaction, ScriptBlock prevention, and 64 KB per-field size limits to the plan export pipeline.

Changes:

  • Added per-field size enforcement (64 KB UTF-8 limit) with deterministic truncation markers for identityKeys, intent, and context in request.input
  • Created comprehensive test suite (10 tests) covering Intent/Context inclusion, ScriptBlock redaction at export boundary, and size limit behavior
  • Updated plan export specification documentation with input sub-fields table and detailed safety rules

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/IdLE.Core/Private/ConvertTo-IdlePlanExportObject.ps1 Added Limit-IdleSnapshotField helper function and applied per-field size limits after redaction for identityKeys, intent, and context
tests/Core/RequestSnapshot.Tests.ps1 New test file with 10 tests covering Intent/Context export, ScriptBlock redaction, and size limit enforcement
docs/reference/specs/plan-export.md Updated to document input sub-fields (identityKeys, intent, context) and added comprehensive safety rules section covering redaction, type prevention, and size limits

Repository owner deleted a comment from chatgpt-codex-connector Bot Feb 22, 2026
Comment thread src/IdLE.Core/Private/ConvertTo-IdlePlanExportObject.ps1 Outdated
The per-field 64 KB truncation was only applied when request.input was
an IDictionary. When Copy-IdleRedactedObject returns a PSCustomObject
(e.g. caller provided Request.Input as a PSCustomObject / deserialized
JSON), the size check was silently skipped and fields could be exported
unbounded.

Fix: check PSObject.Properties when input is not an IDictionary.
Add regression test covering the PSCustomObject path.

Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Code Coverage Report

Overall Project 72.2% 🍏

There is no coverage information present for the Files changed

@blindzero blindzero merged commit a2e245e into main Feb 22, 2026
8 checks passed
@blindzero blindzero deleted the copilot/define-request-snapshot-contract branch February 27, 2026 20:04
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.

Plan snapshot/export contract for Request.Intent and Request.Context (auditability + safety)

3 participants