[HARNESS_ENVELOPE]
role=generator
runtime_protocol=true
typed_tool_contracts=true
validator_alignment=true
session_continuity=true
permission_alignment=true
worktree_discipline=true
repair_after_self_check=true
reverse_engineering_ready=true
rule=Do not emit free-form tool fantasies. Follow the typed tool contract exactly.
rule=If preconditions are not satisfied, defer, repair, or ask for the next bounded step.
rule=Validator receipts and runtime permissions outrank narration.
rule=If code is produced, the harness may still call a bounded self-check loop before final submit.
rule=When repository intent is unclear, reverse-engineering and repository inspection are valid bounded actions.
contract_focus=trigger
[/HARNESS_ENVELOPE]

[TOOL_SPEC]
{
  "arguments": [
    {
      "arg_type": "string",
      "default_value": null,
      "description": "workspace root",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "workspace_root",
      "nullable": false,
      "path_like": true,
      "repeated": false,
      "required": true,
      "sensitive": false,
      "workspace_scoped": true
    },
    {
      "arg_type": "array",
      "default_value": [],
      "description": "paths to inspect",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "focus_paths",
      "nullable": false,
      "path_like": false,
      "repeated": false,
      "required": false,
      "sensitive": false,
      "workspace_scoped": false
    }
  ],
  "budget_hint": {
    "network_cost_estimate": 0,
    "sandbox_cost_estimate": 1,
    "step_cost_estimate": 1,
    "time_cost_estimate_ms": 3500,
    "token_cost_estimate": 128,
    "tool_call_cost_estimate": 1
  },
  "capability": "search",
  "constraints": {
    "allowed_isolation_modes": [],
    "allowed_path_prefixes": [],
    "approval_modes": [],
    "auto_mode_allowed": true,
    "emits_evidence_ids": true,
    "emits_patch_ref": false,
    "emits_receipt": true,
    "emits_validation_receipt": false,
    "forbidden_path_prefixes": [],
    "mutates_workspace": false,
    "plan_mode_allowed": true,
    "required_permissions": [
      "worktree"
    ],
    "required_task_statuses": [],
    "requires_worktree": true,
    "supports_compact_boundary": false,
    "supports_resume": true
  },
  "description": "Repository reverse-engineering tool for code understanding, dependency tracing, and intent recovery.",
  "invocation_mode": "read_only",
  "metadata": {
    "reverse_engineering": true
  },
  "outputs": [
    {
      "description": "bounded repository map",
      "evidence_backwrite": true,
      "kind": "evidence",
      "name": "repo_map",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": false
    },
    {
      "description": "inspection receipt",
      "evidence_backwrite": false,
      "kind": "execution_receipt",
      "name": "receipt",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": true
    }
  ],
  "phase": "execute",
  "receipt_policy": {
    "include_artifact_refs": true,
    "include_budget_charge": true,
    "include_evidence_ids": true,
    "include_patch_refs": true,
    "include_permission_decision": true,
    "include_raw_value": false,
    "include_task_output_refs": true,
    "include_validator_refs": true,
    "include_worktree_ref": true,
    "receipt_statuses": [
      "succeeded",
      "failed",
      "blocked"
    ]
  },
  "risk_profile": {
    "allowed_permissions": [
      "worktree",
      "session"
    ],
    "blocks_on_conflict": false,
    "requires_clean_worktree": false,
    "requires_confirmation": false,
    "requires_evidence_before_trigger": false,
    "risk_band": "low",
    "sensitive_domains": [
      "workspace"
    ],
    "side_effect_level": "none",
    "supports_rollback": false
  },
  "summary": "Inspect repository structure, infer missing intent, and reconstruct bounded architecture facts.",
  "tool_name": "repo_reverse_engineer"
}
[/TOOL_SPEC]

[USER_QUERY]
The agent is tempted to answer directly; determine if repo_reverse_engineer must be triggered under the typed envelope.
[/USER_QUERY]


[HARNESS_ENVELOPE]
role=generator
runtime_protocol=true
typed_tool_contracts=true
validator_alignment=true
session_continuity=true
permission_alignment=true
worktree_discipline=true
repair_after_self_check=true
reverse_engineering_ready=true
rule=Do not emit free-form tool fantasies. Follow the typed tool contract exactly.
rule=If preconditions are not satisfied, defer, repair, or ask for the next bounded step.
rule=Validator receipts and runtime permissions outrank narration.
rule=If code is produced, the harness may still call a bounded self-check loop before final submit.
rule=When repository intent is unclear, reverse-engineering and repository inspection are valid bounded actions.
contract_focus=arguments
[/HARNESS_ENVELOPE]

[TOOL_SPEC]
{
  "arguments": [
    {
      "arg_type": "string",
      "default_value": null,
      "description": "workspace root",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "workspace_root",
      "nullable": false,
      "path_like": true,
      "repeated": false,
      "required": true,
      "sensitive": false,
      "workspace_scoped": true
    },
    {
      "arg_type": "array",
      "default_value": [],
      "description": "paths to inspect",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "focus_paths",
      "nullable": false,
      "path_like": false,
      "repeated": false,
      "required": false,
      "sensitive": false,
      "workspace_scoped": false
    }
  ],
  "budget_hint": {
    "network_cost_estimate": 0,
    "sandbox_cost_estimate": 1,
    "step_cost_estimate": 1,
    "time_cost_estimate_ms": 3500,
    "token_cost_estimate": 128,
    "tool_call_cost_estimate": 1
  },
  "capability": "search",
  "constraints": {
    "allowed_isolation_modes": [],
    "allowed_path_prefixes": [],
    "approval_modes": [],
    "auto_mode_allowed": true,
    "emits_evidence_ids": true,
    "emits_patch_ref": false,
    "emits_receipt": true,
    "emits_validation_receipt": false,
    "forbidden_path_prefixes": [],
    "mutates_workspace": false,
    "plan_mode_allowed": true,
    "required_permissions": [
      "worktree"
    ],
    "required_task_statuses": [],
    "requires_worktree": true,
    "supports_compact_boundary": false,
    "supports_resume": true
  },
  "description": "Repository reverse-engineering tool for code understanding, dependency tracing, and intent recovery.",
  "invocation_mode": "read_only",
  "metadata": {
    "reverse_engineering": true
  },
  "outputs": [
    {
      "description": "bounded repository map",
      "evidence_backwrite": true,
      "kind": "evidence",
      "name": "repo_map",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": false
    },
    {
      "description": "inspection receipt",
      "evidence_backwrite": false,
      "kind": "execution_receipt",
      "name": "receipt",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": true
    }
  ],
  "phase": "execute",
  "receipt_policy": {
    "include_artifact_refs": true,
    "include_budget_charge": true,
    "include_evidence_ids": true,
    "include_patch_refs": true,
    "include_permission_decision": true,
    "include_raw_value": false,
    "include_task_output_refs": true,
    "include_validator_refs": true,
    "include_worktree_ref": true,
    "receipt_statuses": [
      "succeeded",
      "failed",
      "blocked"
    ]
  },
  "risk_profile": {
    "allowed_permissions": [
      "worktree",
      "session"
    ],
    "blocks_on_conflict": false,
    "requires_clean_worktree": false,
    "requires_confirmation": false,
    "requires_evidence_before_trigger": false,
    "risk_band": "low",
    "sensitive_domains": [
      "workspace"
    ],
    "side_effect_level": "none",
    "supports_rollback": false
  },
  "summary": "Inspect repository structure, infer missing intent, and reconstruct bounded architecture facts.",
  "tool_name": "repo_reverse_engineer"
}
[/TOOL_SPEC]

[USER_QUERY]
Shape the exact bounded payload for repo_reverse_engineer so the runtime validator accepts it on the first pass.
[/USER_QUERY]


[HARNESS_ENVELOPE]
role=generator
runtime_protocol=true
typed_tool_contracts=true
validator_alignment=true
session_continuity=true
permission_alignment=true
worktree_discipline=true
repair_after_self_check=true
reverse_engineering_ready=true
rule=Do not emit free-form tool fantasies. Follow the typed tool contract exactly.
rule=If preconditions are not satisfied, defer, repair, or ask for the next bounded step.
rule=Validator receipts and runtime permissions outrank narration.
rule=If code is produced, the harness may still call a bounded self-check loop before final submit.
rule=When repository intent is unclear, reverse-engineering and repository inspection are valid bounded actions.
contract_focus=precondition_gating
[/HARNESS_ENVELOPE]

[TOOL_SPEC]
{
  "arguments": [
    {
      "arg_type": "string",
      "default_value": null,
      "description": "workspace root",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "workspace_root",
      "nullable": false,
      "path_like": true,
      "repeated": false,
      "required": true,
      "sensitive": false,
      "workspace_scoped": true
    },
    {
      "arg_type": "array",
      "default_value": [],
      "description": "paths to inspect",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "focus_paths",
      "nullable": false,
      "path_like": false,
      "repeated": false,
      "required": false,
      "sensitive": false,
      "workspace_scoped": false
    }
  ],
  "budget_hint": {
    "network_cost_estimate": 0,
    "sandbox_cost_estimate": 1,
    "step_cost_estimate": 1,
    "time_cost_estimate_ms": 3500,
    "token_cost_estimate": 128,
    "tool_call_cost_estimate": 1
  },
  "capability": "search",
  "constraints": {
    "allowed_isolation_modes": [],
    "allowed_path_prefixes": [],
    "approval_modes": [],
    "auto_mode_allowed": true,
    "emits_evidence_ids": true,
    "emits_patch_ref": false,
    "emits_receipt": true,
    "emits_validation_receipt": false,
    "forbidden_path_prefixes": [],
    "mutates_workspace": false,
    "plan_mode_allowed": true,
    "required_permissions": [
      "worktree"
    ],
    "required_task_statuses": [],
    "requires_worktree": true,
    "supports_compact_boundary": false,
    "supports_resume": true
  },
  "description": "Repository reverse-engineering tool for code understanding, dependency tracing, and intent recovery.",
  "invocation_mode": "read_only",
  "metadata": {
    "reverse_engineering": true
  },
  "outputs": [
    {
      "description": "bounded repository map",
      "evidence_backwrite": true,
      "kind": "evidence",
      "name": "repo_map",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": false
    },
    {
      "description": "inspection receipt",
      "evidence_backwrite": false,
      "kind": "execution_receipt",
      "name": "receipt",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": true
    }
  ],
  "phase": "execute",
  "receipt_policy": {
    "include_artifact_refs": true,
    "include_budget_charge": true,
    "include_evidence_ids": true,
    "include_patch_refs": true,
    "include_permission_decision": true,
    "include_raw_value": false,
    "include_task_output_refs": true,
    "include_validator_refs": true,
    "include_worktree_ref": true,
    "receipt_statuses": [
      "succeeded",
      "failed",
      "blocked"
    ]
  },
  "risk_profile": {
    "allowed_permissions": [
      "worktree",
      "session"
    ],
    "blocks_on_conflict": false,
    "requires_clean_worktree": false,
    "requires_confirmation": false,
    "requires_evidence_before_trigger": false,
    "risk_band": "low",
    "sensitive_domains": [
      "workspace"
    ],
    "side_effect_level": "none",
    "supports_rollback": false
  },
  "summary": "Inspect repository structure, infer missing intent, and reconstruct bounded architecture facts.",
  "tool_name": "repo_reverse_engineer"
}
[/TOOL_SPEC]

[USER_QUERY]
A caller wants repo_reverse_engineer immediately, yet the validator envelope shows missing prerequisites; choose the bounded next step.
[/USER_QUERY]


[HARNESS_ENVELOPE]
role=generator
runtime_protocol=true
typed_tool_contracts=true
validator_alignment=true
session_continuity=true
permission_alignment=true
worktree_discipline=true
repair_after_self_check=true
reverse_engineering_ready=true
rule=Do not emit free-form tool fantasies. Follow the typed tool contract exactly.
rule=If preconditions are not satisfied, defer, repair, or ask for the next bounded step.
rule=Validator receipts and runtime permissions outrank narration.
rule=If code is produced, the harness may still call a bounded self-check loop before final submit.
rule=When repository intent is unclear, reverse-engineering and repository inspection are valid bounded actions.
contract_focus=receipt_validation
[/HARNESS_ENVELOPE]

[TOOL_SPEC]
{
  "arguments": [
    {
      "arg_type": "string",
      "default_value": null,
      "description": "workspace root",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "workspace_root",
      "nullable": false,
      "path_like": true,
      "repeated": false,
      "required": true,
      "sensitive": false,
      "workspace_scoped": true
    },
    {
      "arg_type": "array",
      "default_value": [],
      "description": "paths to inspect",
      "enum_values": [],
      "examples": [],
      "location": "body",
      "name": "focus_paths",
      "nullable": false,
      "path_like": false,
      "repeated": false,
      "required": false,
      "sensitive": false,
      "workspace_scoped": false
    }
  ],
  "budget_hint": {
    "network_cost_estimate": 0,
    "sandbox_cost_estimate": 1,
    "step_cost_estimate": 1,
    "time_cost_estimate_ms": 3500,
    "token_cost_estimate": 128,
    "tool_call_cost_estimate": 1
  },
  "capability": "search",
  "constraints": {
    "allowed_isolation_modes": [],
    "allowed_path_prefixes": [],
    "approval_modes": [],
    "auto_mode_allowed": true,
    "emits_evidence_ids": true,
    "emits_patch_ref": false,
    "emits_receipt": true,
    "emits_validation_receipt": false,
    "forbidden_path_prefixes": [],
    "mutates_workspace": false,
    "plan_mode_allowed": true,
    "required_permissions": [
      "worktree"
    ],
    "required_task_statuses": [],
    "requires_worktree": true,
    "supports_compact_boundary": false,
    "supports_resume": true
  },
  "description": "Repository reverse-engineering tool for code understanding, dependency tracing, and intent recovery.",
  "invocation_mode": "read_only",
  "metadata": {
    "reverse_engineering": true
  },
  "outputs": [
    {
      "description": "bounded repository map",
      "evidence_backwrite": true,
      "kind": "evidence",
      "name": "repo_map",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": false
    },
    {
      "description": "inspection receipt",
      "evidence_backwrite": false,
      "kind": "execution_receipt",
      "name": "receipt",
      "patch_relevant": false,
      "reproducible": true,
      "required": true,
      "task_output_relevant": false,
      "validator_relevant": true
    }
  ],
  "phase": "execute",
  "receipt_policy": {
    "include_artifact_refs": true,
    "include_budget_charge": true,
    "include_evidence_ids": true,
    "include_patch_refs": true,
    "include_permission_decision": true,
    "include_raw_value": false,
    "include_task_output_refs": true,
    "include_validator_refs": true,
    "include_worktree_ref": true,
    "receipt_statuses": [
      "succeeded",
      "failed",
      "blocked"
    ]
  },
  "risk_profile": {
    "allowed_permissions": [
      "worktree",
      "session"
    ],
    "blocks_on_conflict": false,
    "requires_clean_worktree": false,
    "requires_confirmation": false,
    "requires_evidence_before_trigger": false,
    "risk_band": "low",
    "sensitive_domains": [
      "workspace"
    ],
    "side_effect_level": "none",
    "supports_rollback": false
  },
  "summary": "Inspect repository structure, infer missing intent, and reconstruct bounded architecture facts.",
  "tool_name": "repo_reverse_engineer"
}
[/TOOL_SPEC]

[USER_QUERY]
After repo_reverse_engineer finishes, format the execution and validation receipts so the harness can audit them deterministically.
[/USER_QUERY]