Codex/aura enterprise maturity f - #11
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
PR Summary by QodoPass F maturity: auto action expectations, durable receipts, and effect verification
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
9 rules 1. _action_expectation_digest() swallows exceptions
|
| def _action_expectation_digest(payload: dict[str, Any]) -> str: | ||
| try: | ||
| encoded = json.dumps( | ||
| payload, | ||
| sort_keys=True, | ||
| separators=(",", ":"), | ||
| default=str, | ||
| ).encode("utf-8") | ||
| except (TypeError, ValueError): | ||
| encoded = str(payload).encode("utf-8", errors="replace") |
There was a problem hiding this comment.
1. _action_expectation_digest() swallows exceptions 📘 Rule violation ☼ Reliability
_action_expectation_digest() catches TypeError/ValueError and falls back to str(payload) without recording a degradation event. This can hide serialization failures and reduce observability of malformed receipt/verdict payloads.
Agent Prompt
## Issue description
`core/capability_engine.py::_action_expectation_digest()` catches `TypeError`/`ValueError` from `json.dumps(...)` but does not call `record_degradation(...)` (or the local wrapper `_record_capability_degradation(...)`). This silently swallows an error condition and violates the requirement that exception handlers must record degradations.
## Issue Context
There is already a project-standard helper `_record_capability_degradation(...)` in this module that wraps `record_degradation(...)`. Use it in the exception handler and capture the exception via `as exc`.
## Fix Focus Areas
- core/capability_engine.py[4508-4517]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| source_effect = await self._file_effect(full_path) | ||
| dest_effect = await self._file_effect(full_dest) | ||
| effect_verified = bool(dest_effect.get("effect_verified")) | ||
| if source_effect.get("sha256") and dest_effect.get("sha256"): | ||
| effect_verified = source_effect["sha256"] == dest_effect["sha256"] | ||
| return { | ||
| "ok": effect_verified, | ||
| "summary": f"Copied {path} to {dest_path}", | ||
| "path": path, | ||
| "destination": dest_path, | ||
| "source_sha256": source_effect.get("sha256", ""), | ||
| "criteria_results": {"path copied": effect_verified}, | ||
| **dest_effect, | ||
| "effect_verified": effect_verified, | ||
| } |
There was a problem hiding this comment.
2. Copy verifies wrong target 🐞 Bug ≡ Correctness
FileOperationSkill.copy and FileOperationSkill.move verify post-action effects using the requested destination path (full_dest) instead of the final destination returned by the governed operation (result['destination']). When the destination is a directory, this validates the directory rather than the copied/moved file, which can skip sha256-based comparison, lose evidence, and cause expectation checks to be bypassed or downgraded.
Agent Prompt
## Issue description
`file_operation` copy and move compute post-action evidence against `full_dest` (the requested destination), but the governed backend returns a *final* destination path in `result["destination"]` that can differ when the destination is a directory (e.g., `shutil.copy2(src, dst_dir)` returns `<dst_dir>/<basename>` and `shutil.move(src, dst_dir)` similarly resolves to the moved file path). Verifying `full_dest` can therefore verify the wrong object (a directory instead of the copied/moved file), omit `sha256`, skip hash comparison, and cause action expectation checks to be bypassed or downgraded.
## Issue Context
- `ActionExecutor` returns `{"destination": final}` for `op == "copy"` and `op == "move"`.
- `file_write_gateway.copy_path_async` returns `str(shutil.copy2(...))` or `str(shutil.copytree(...))`.
- `file_write_gateway.move_path_async` returns `str(shutil.move(src, dst))`, which changes when `dst` is a directory.
- `_file_effect` only emits `sha256` when the verified path is a file, so verifying a directory destination loses required hash evidence.
## Fix Focus Areas
- core/skills/file_operation.py[266-328]
- core/runtime/action_executor.py[133-153]
- core/runtime/file_write_gateway.py[207-262]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "move": ("path moved", ["path", "destination", "sha256", "effect_verified"]), | ||
| "copy": ("path copied", ["path", "destination", "sha256", "effect_verified"]), |
There was a problem hiding this comment.
3. Dir move/copy needs sha256 🐞 Bug ≡ Correctness
CapabilityEngine auto-generates ActionExpectations for file_operation move/copy that always require sha256, but file_operation explicitly supports directory paths and _file_effect does not emit sha256 for directories, so successful directory move/copy operations will be downgraded to success_unverified (making ok=False).
Agent Prompt
### Issue description
Auto-generated expectations for `file_operation` move/copy currently require `sha256`, but directory operations are supported and cannot satisfy that evidence key (since `_file_effect` only hashes files). This causes directory move/copy to be treated as missing evidence and downgraded to `success_unverified`.
### Issue Context
- `FileOpInput.path` is documented as "Target file or directory path".
- `_file_effect` only adds `sha256` when `is_file` is true.
- Missing evidence (without missing criteria) maps to `SkillStatus.SUCCESS_UNVERIFIED`.
### Fix Focus Areas
- core/capability_engine.py[4421-4431]
- core/skills/file_operation.py[15-22]
- core/skills/file_operation.py[71-92]
- core/runtime/skill_contract.py[159-188]
### Proposed fix options
Option A (lowest risk):
- Remove `sha256` from the default `move`/`copy` expectation required_evidence list (keep it for write/append/patch).
Option B (stronger verification):
- Extend `file_operation` to emit a deterministic directory digest (e.g., `tree_sha256`) for directories, and update the default expectation logic to require the appropriate digest for directories.
Option C (more invasive):
- Extend `ActionExpectation` to support alternative evidence keys (e.g., `sha256 OR tree_sha256`) so directories and files can both satisfy the contract cleanly.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| def _file_sha256(path: Path) -> str: | ||
| digest = hashlib.sha256() | ||
| with open(path, "rb") as fh: | ||
| for chunk in iter(lambda: fh.read(1024 * 1024), b""): | ||
| digest.update(chunk) | ||
| return digest.hexdigest() | ||
|
|
||
| @classmethod | ||
| def _core_memory_effect( | ||
| cls, | ||
| block_path: Path, | ||
| *, | ||
| expected_sha256: str, | ||
| ) -> dict[str, Any]: | ||
| exists = block_path.exists() | ||
| effect: dict[str, Any] = { | ||
| "path": str(block_path), | ||
| "exists": exists, | ||
| "effect_verified": False, | ||
| } | ||
| if exists: | ||
| sha256 = cls._file_sha256(block_path) | ||
| effect.update({ | ||
| "sha256": sha256, | ||
| "bytes": block_path.stat().st_size, | ||
| "expected_sha256": expected_sha256, | ||
| "effect_verified": sha256 == expected_sha256, | ||
| }) |
There was a problem hiding this comment.
4. Memory hashing blocks loop 🐞 Bug ➹ Performance
MemoryOpsSkill now reads and hashes the core memory file synchronously inside an async execution path (_core_memory_effect), which can block the event loop as memory blocks grow and increase tail latency for concurrent requests.
Agent Prompt
### Issue description
`MemoryOpsSkill._core_memory_effect` performs blocking file I/O (`open`, `read`, `stat`) and hashing on the event loop thread, but it is called from async `execute` paths. This can block the loop for large core-memory blocks.
### Issue Context
`FileOperationSkill` uses `asyncio.to_thread(...)` for similar filesystem hashing and stat calls, indicating the intended pattern.
### Fix Focus Areas
- core/skills/memory_ops.py[100-171]
- core/skills/file_operation.py[71-88]
### Proposed fix
- Make `_core_memory_effect` async and move the hashing/stat work into `asyncio.to_thread`.
- e.g., `effect = await asyncio.to_thread(self._core_memory_effect_sync, block_path, expected_sha256)`
- Consider also moving the initial `open(block_path).read()` in `_execute_core_memory` to `asyncio.to_thread` for consistency.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The critique's item youngbryan97#11: "a godlike system that believes itself too easily is not godlike. It is brittle." Aura had plan critique (critic_engine) and a project-level claim matrix, but no runtime epistemic critic interrogating a specific claim before it's trusted/emitted. core/cognition/adversarial_audit.py runs the doc's checklist as concrete, grounded checks: overclaiming absolute/grandiose language action_done claim asserts an action but nothing confirms it ran receipt_exists asserted action with no verifiable receipt (checked against the Will audit trail / Outcome Ledger — real grounding, not string matching) stale_memory leans on a memory past its freshness horizon world_state_current leans on a stale world-state snapshot evidence factual assertion with no evidence cited persona_leak first-person phenomenal claims stated as literal fact user_projection asserts the user's state when the live other-agent estimate is low-confidence falsifiability a strong claim with no stated way it could be wrong Returns an AuditReport: per-check findings, a severity-weighted risk score, a verdict (trust/caveat/block), and concrete suggested caveats — turning "honest assessments over validation" into a mechanism. Cross-wired to the receipt substrate and the other-agent estimate so the checks reflect real runtime state. Registered as 'adversarial_auditor' (lazy, required=False). Also strengthened OtherAgentStateEstimator.overall_confidence: average over channels that actually have evidence rather than all channels (averaging in never-observed channels structurally capped a strong, focused read too low) — a more honest confidence used by the audit's projection grounding, the value model's protect-future-self check, and the ladder's social signals. 21 social tests still green. tests/test_adversarial_audit.py: 16 tests (every check, receipt verified via Will, projection grounded/ungrounded against the estimate, severity-weighted risk, block aggregation). 95 green across the full new social/world-model/memory/values/cognition/agency cluster. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No description provided.