naqsha.reflection¶
Reflection Loop and Automated Rollback Manager
naqsha.reflection ¶
Reflection Loop boundaries.
RELIABILITY_GATE_TEST_PATHS
module-attribute
¶
RELIABILITY_GATE_TEST_PATHS: tuple[str, ...] = (
"tests/test_trace_replay.py",
"tests/test_protocols.py",
"tests/test_policy_and_trace.py",
"tests/test_memory_simplemem_cross.py",
"tests/redteam/test_corpus.py",
)
ReflectionPatch
dataclass
¶
Artifacts for human review.
Merging into the active workspace is performed only by AutomatedRollbackManager
inside the reflection package when workspace policy allows auto-merge; there is no
merge method on this object.
Source code in src/naqsha/reflection/base.py
ready_for_human_review
property
¶
True when the Reliability Gate passed; merge still needs human approval.
ReflectionPatchEventSink ¶
Bases: Protocol
Callbacks for patch lifecycle (implemented by embedders using RuntimeEventBus).
Source code in src/naqsha/reflection/base.py
ReflectionTomlSettings
dataclass
¶
Subset of [reflection] used by SimpleReflectionLoop.
reliability_gate does not skip pytest for patch eligibility: it only gates whether
auto_merge may run after the gate passes (fail-closed for autonomous merges).
Source code in src/naqsha/reflection/config.py
SimpleReflectionLoop ¶
Builds isolated Reflection Patch folders from a QAOA trace.
This class does not import or call Tool Policy, the Core Runtime, or model adapters.
Source code in src/naqsha/reflection/loop.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
propose_patch ¶
Source code in src/naqsha/reflection/loop.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
ReliabilityGateResult
dataclass
¶
Source code in src/naqsha/reflection/reliability_gate.py
AutomatedRollbackManager ¶
Snapshot naqsha.toml and tools/ before merge; restore on failed boot.
Source code in src/naqsha/reflection/rollback.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
merge_patch ¶
merge_patch(
patch: ReflectionPatch,
*,
team_workspace: Path,
run_id: str,
agent_id: str = "",
event_sink: ReflectionPatchEventSink | None = None,
) -> None
Backup tracked files, apply patch.workspace/{merge}/, set boot pending.
Source code in src/naqsha/reflection/rollback.py
verify_boot_if_pending ¶
verify_boot_if_pending(
team_workspace: Path,
*,
health_check: Callable[[], bool],
event_sink: ReflectionPatchEventSink | None = None,
) -> bool
If boot status is pending, run health_check; rollback on failure.
Source code in src/naqsha/reflection/rollback.py
ReflectionWorkspaceError ¶
build_candidate_markdown ¶
Source code in src/naqsha/reflection/candidate.py
build_meta_json ¶
build_meta_json(
events: list[TraceEvent],
*,
reliability_gate_passed: bool,
gate_result: ReliabilityGateResult | None,
auto_merged: bool = False,
) -> str
Source code in src/naqsha/reflection/candidate.py
load_reflection_toml_settings ¶
Parse [reflection] from team_workspace/naqsha.toml if present.
Source code in src/naqsha/reflection/config.py
failing_gate_runner ¶
Test helper: gate always fails.
Source code in src/naqsha/reflection/loop.py
noop_gate_runner ¶
Test helper: gate always passes.
Source code in src/naqsha/reflection/loop.py
resolve_project_root_for_gate ¶
Find a development checkout root that contains the gate test files.
Source code in src/naqsha/reflection/reliability_gate.py
run_reliability_gate_subprocess ¶
Run pytest on the Reliability Gate corpus (blocking).
Source code in src/naqsha/reflection/reliability_gate.py
assert_workspace_outside_package ¶
Ensure path is not inside the installed naqsha package directory.
Source code in src/naqsha/reflection/workspace.py
create_isolated_workspace ¶
Create parent / {prefix}-{uuid} after validating parent.