Cairn is a general-purpose AI state-space search engine, validated first on autonomous penetration testing. Sometimes misspelled as Carin.
Python aiai-agentai-cybersecurityai-hackerai-hackingblackbox-testingctfctf-toolsllmpenetration-testingpentestingred-teamingsecurity-automationsecurity-tools
fix: tighten bootstrap conclude compatibility
leixiao3890e7e06ddf
diff --git a/cairn/src/cairn/dispatcher/contracts.py b/cairn/src/cairn/dispatcher/contracts.pyindex 587940f..c6c6943 100644--- a/cairn/src/cairn/dispatcher/contracts.py+++ b/cairn/src/cairn/dispatcher/contracts.py@@ -47,7 +47,10 @@ def _looks_like_bootstrap_execute_data(payload: dict[str, Any]) -> bool:def _looks_like_bootstrap_conclude_data(payload: dict[str, Any]) -> bool:- if not isinstance(payload, dict) or set(payload) != {"fact"}:+ if not isinstance(payload, dict):+ return False+ keys = set(payload)+ if keys not in ({"fact"}, {"fact", "complete"}):return Falsereturn _is_dict(payload.get("fact"))@@ -139,9 +142,9 @@ def validate_bootstrap_conclude_payload(payload: dict[str, Any]) -> tuple[str, sdata = payloadif not isinstance(data, dict):raise ValueError("accepted must be true or false")-- if data.get("complete") is not None:- raise ValueError("complete is not allowed")+ extra_keys = set(data) - {"fact", "complete"}+ if extra_keys:+ raise ValueError("unexpected keys in conclude payload")fact = data.get("fact")if not isinstance(fact, dict):raise ValueError("fact is required")diff --git a/cairn/src/cairn/dispatcher/prompts/default/bootstrap.md b/cairn/src/cairn/dispatcher/prompts/default/bootstrap.mdindex 56193f2..ddd2f9a 100644--- a/cairn/src/cairn/dispatcher/prompts/default/bootstrap.md+++ b/cairn/src/cairn/dispatcher/prompts/default/bootstrap.md@@ -17,6 +17,7 @@ Only return the following after you have confirmed that Goal has been satisfied:# Rules- If the problem is not yet solved, keep working and do not stop on your own.- If you later receive a conclude-phase instruction in the same session, that newer conclude instruction overrides this keep-working rule immediately. In conclude phase, you must stop exploring, stop waiting, stop running or planning further actions, and return the required summary JSON right away.+- Output `complete` only if Goal has already been definitively achieved in this session. If Goal is not yet achieved, do not output `complete`, do not summarize partial progress as completion, and keep working until a conclude-phase instruction replaces this task.- `fact.description` must clearly state the confirmed key objective results. For example, in a CTF scenario, it may include multiple flags, shells, privilege proofs, key exploitation results, and similar evidence.- `complete.description` should explain why the currently confirmed results are sufficient to prove that Goal has been achieved.- Do not put long data blobs in `description`. Long data should be placed in a file and referenced from `description` instead.diff --git a/cairn/src/cairn/dispatcher/prompts/default/bootstrap_conclude.md b/cairn/src/cairn/dispatcher/prompts/default/bootstrap_conclude.mdindex b96d833..1508c3a 100644--- a/cairn/src/cairn/dispatcher/prompts/default/bootstrap_conclude.md+++ b/cairn/src/cairn/dispatcher/prompts/default/bootstrap_conclude.md@@ -21,6 +21,7 @@ Normal return example:- Do not run any more commands, make any more tool calls, inspect anything else, wait for any unfinished command, or try to obtain any additional information.- Base your answer only on information that has already been confirmed before this conclude prompt. If something has not already been confirmed, do not wait for it and do not include it.- This JSON summary is your final output for this phase. After outputting it, stop.+- Do not output `complete` in this phase. Even if Goal is not achieved or you want to explain status, put that information into `fact.description` only.- `fact.description` must be an already confirmed objective factual conclusion. Do not output plans, guesses, or explanatory filler.- Do not put long data blobs in `fact.description`. Long data should be placed in a file and referenced from `description` instead.diff --git a/cairn/src/cairn/dispatcher/tasks/bootstrap.py b/cairn/src/cairn/dispatcher/tasks/bootstrap.pyindex 5e1c349..815e762 100644--- a/cairn/src/cairn/dispatcher/tasks/bootstrap.py+++ b/cairn/src/cairn/dispatcher/tasks/bootstrap.py@@ -342,6 +342,15 @@ def _try_conclude_fallback(return "failed"try:payload = parse_json_output(result.stdout)+ conclude_data = payload.get("data") if isinstance(payload.get("data"), dict) else payload+ if isinstance(conclude_data, dict) and isinstance(conclude_data.get("complete"), dict):+ LOG.warning(+ "bootstrap conclude returned unexpected complete payload project=%s intent=%s worker=%s complete_preview=%s",+ project.project.id,+ intent.id,+ worker.name,+ preview(str(conclude_data.get("complete"))),+ )kind, fact_description = validate_bootstrap_conclude_payload(payload)except Exception as exc:LOG.warning(