ai-execution-protocol 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,7 @@ O framework ajuda a IA a:
14
14
 
15
15
  - entender a intencao antes de agir;
16
16
  - classificar o risco da tarefa;
17
+ - localizar o dominio certo antes de abrir arquivos grandes;
17
18
  - ler apenas o contexto necessario;
18
19
  - mapear impacto antes de alterar arquivos;
19
20
  - pedir confirmacao em acoes sensiveis;
@@ -30,6 +31,16 @@ O protocolo nao tenta transformar toda tarefa em um processo pesado. A regra e
30
31
  proporcionalidade: tarefa simples deve ser rapida; tarefa critica exige mais
31
32
  mapa, confirmacao e evidencia.
32
33
 
34
+ Na v0.2.0, o framework adiciona uma camada leve de contexto persistente:
35
+
36
+ ```text
37
+ pedido -> intencao -> dominio -> contexto minimo -> validacao -> acao
38
+ ```
39
+
40
+ Essa camada usa `canonical-state.yaml`, `context-map.yaml`, `decisions/` e
41
+ `protocol/persistent-context.yaml` para reduzir leitura desnecessaria. Ela e um
42
+ bootstrap seguro, nao um indexador automatico completo.
43
+
33
44
  ## Status
34
45
 
35
46
  Projeto em fase de pesquisa e evolucao.
@@ -42,7 +53,10 @@ continuam obrigatorios em tarefas criticas.
42
53
 
43
54
  - `AGENTS.md`: instrucao principal para agentes no projeto.
44
55
  - `INDEX.yaml`: mapa estruturado para navegacao rapida.
56
+ - `canonical-state.yaml`: estado atual resumido e ordem de verdade.
57
+ - `context-map.yaml`: mapa pequeno de dominios, aliases e arquivos candidatos.
45
58
  - `config.yaml`: configuracao do alvo atual e versao do protocolo.
59
+ - `decisions/`: decisoes importantes com status.
46
60
  - `docs/`: explicacoes conceituais em Markdown.
47
61
  - `protocol/`: regras operacionais curtas em YAML.
48
62
  - `cases/`: casos estruturados para testar o comportamento da IA.
@@ -59,11 +73,24 @@ continuam obrigatorios em tarefas criticas.
59
73
  ## Como usar como agente
60
74
 
61
75
  1. Leia `INDEX.yaml`.
62
- 2. Confirme o alvo atual em `config.yaml`.
63
- 3. Leia `protocol/fast-path.yaml`.
64
- 4. Use `protocol/router.yaml` para escolher o menor contexto suficiente.
65
- 5. Abra apenas os arquivos indicados pela rota.
66
- 6. Execute, valide e entregue com evidencia.
76
+ 2. Confirme o estado atual em `canonical-state.yaml` quando a verdade do
77
+ projeto importar.
78
+ 3. Use `context-map.yaml` para localizar dominio e aliases provaveis.
79
+ 4. Confirme o alvo atual em `config.yaml`.
80
+ 5. Leia `protocol/fast-path.yaml`.
81
+ 6. Use `protocol/router.yaml` para escolher o menor contexto suficiente.
82
+ 7. Abra apenas os arquivos indicados pela rota ou pela recuperacao progressiva.
83
+ 8. Execute, valide e entregue com evidencia.
84
+
85
+ Regra de seguranca da v0.2.0:
86
+
87
+ ```text
88
+ A IA pode expandir contexto.
89
+ A IA nao pode expandir escopo.
90
+ ```
91
+
92
+ Aliases, mapas e decisoes ajudam a navegar. Eles nao substituem verificacao no
93
+ codigo ou nos arquivos atuais antes de alterar comportamento.
67
94
 
68
95
  ## Como estudar o framework
69
96
 
@@ -73,8 +100,11 @@ Comece por:
73
100
  - `docs/01-modelo-de-execucao.md`
74
101
  - `docs/02-niveis-de-risco.md`
75
102
  - `docs/03-mapeamento-antes-de-alterar.md`
103
+ - `docs/04-janela-de-contexto.md`
76
104
  - `docs/05-validacao-e-entrega.md`
105
+ - `docs/15-contexto-persistente.md`
77
106
  - `docs/14-publicacao.md`
107
+ - `docs/16-release-e-atualizacao.md`
78
108
 
79
109
  Use `docs/` para entender a metodologia. Use `protocol/` quando quiser aplicar
80
110
  as regras em uma tarefa real.
@@ -144,6 +174,7 @@ O final esperado da verificacao e `PASS`.
144
174
  ## Publicacao
145
175
 
146
176
  Antes de publicar, revise `docs/14-publicacao.md`.
177
+ Para atualizar uma versao ja publicada, revise `docs/16-release-e-atualizacao.md`.
147
178
 
148
179
  Resumo minimo:
149
180
 
@@ -1,7 +1,7 @@
1
1
  id: protocol_index
2
2
  type: index
3
3
  format: yaml
4
- protocol_version: 0.1.0
4
+ protocol_version: 0.2.0
5
5
  purpose: ai_operational_rules
6
6
  source_docs: ../docs
7
7
  constraints:
@@ -27,6 +27,8 @@ files:
27
27
  purpose: context_window_file_size_memory
28
28
  - path: context-compiler.yaml
29
29
  purpose: compile_minimum_context_package_and_canonical_state
30
+ - path: persistent-context.yaml
31
+ purpose: progressive_context_retrieval_with_aliases
30
32
  - path: formatting-rules.yaml
31
33
  purpose: ai_readable_file_format
32
34
  - path: prompt-economy.yaml
@@ -6,6 +6,8 @@ principle: conversation_is_interface_not_source_of_truth
6
6
  canonical_state:
7
7
  read_first:
8
8
  - AGENTS.md
9
+ - canonical-state.yaml
10
+ - context-map.yaml
9
11
  - INDEX.yaml
10
12
  - config.yaml
11
13
  - protocol/fast-path.yaml
@@ -37,6 +39,8 @@ context_build:
37
39
  - excluded_context
38
40
  selection_policy:
39
41
  include:
42
+ - context_map_domain_when_available
43
+ - active_decisions_for_matched_domain
40
44
  - files_required_by_route
41
45
  - snippets_matching_task_terms
42
46
  - current_decisions_touching_candidate_area
@@ -81,9 +85,19 @@ decision_rules:
81
85
  when: context_gap_blocks_safe_execution
82
86
  do:
83
87
  - ask_one_short_question_or_read_next_mapped_file
88
+ - id: CTX_005
89
+ when: alias_or_snippet_seems_sufficient
90
+ do:
91
+ - verify_against_current_file_state_before_editing
92
+ - escalate_to_full_file_when_imports_types_or_side_effects_matter
93
+ avoid:
94
+ - treating_alias_as_source_of_truth
95
+ - editing_from_snippet_when_behavior_depends_on_unread_context
84
96
  retrieval_tiers:
85
97
  mvp:
86
98
  use:
99
+ - canonical-state.yaml
100
+ - context-map.yaml
87
101
  - INDEX.yaml
88
102
  - router.yaml
89
103
  - targeted_search
@@ -108,3 +122,10 @@ delivery:
108
122
  - context_used
109
123
  - context_excluded
110
124
  - reason_for_not_reading_more
125
+ economy_goal:
126
+ target: reduce_unneeded_context_up_to_90_percent_when_safe
127
+ never_trade_off:
128
+ - correctness
129
+ - security
130
+ - validation
131
+ - risk_classification
@@ -4,6 +4,8 @@ version: 0.1
4
4
  context_policy:
5
5
  use: minimum_sufficient_context
6
6
  prefer:
7
+ - context_map_before_domain_docs
8
+ - aliases_for_search_not_truth
7
9
  - targeted_search
8
10
  - relevant_snippets
9
11
  - current_state_over_old_history
@@ -13,6 +15,7 @@ context_policy:
13
15
  - repeating_long_rules_in_chat
14
16
  - mixing_old_and_current_docs
15
17
  - treating_conversation_as_source_of_truth
18
+ - treating_aliases_as_verified_behavior
16
19
  file_size:
17
20
  max_lines: 400
18
21
  when_near_limit:
@@ -0,0 +1,103 @@
1
+ id: persistent_context
2
+ type: operational_rules
3
+ version: 0.2
4
+ purpose: navigate_project_memory_without_loading_unneeded_context
5
+ principle: aliases_are_pointers_not_truth
6
+ autonomous_memory:
7
+ target: generate_memory_from_project_state_without_manual_maintenance
8
+ current_safe_stage: bootstrap_with_small_verified_artifacts
9
+ promote_to_required_only_when:
10
+ - indexer_exists
11
+ - generated_output_is_reproducible
12
+ - stale_output_can_be_detected
13
+ - validation_passes_in_real_projects
14
+ economy_goal:
15
+ target: reduce_unneeded_context_up_to_90_percent_when_safe
16
+ meaning: reduce_irrelevant_context_not_required_context
17
+ stop_condition:
18
+ - objective_is_clear
19
+ - candidate_area_is_mapped
20
+ - validation_plan_is_clear
21
+ - no_unresolved_risk_requires_more_context
22
+ entrypoints:
23
+ - canonical-state.yaml
24
+ - context-map.yaml
25
+ - decisions/
26
+ progressive_retrieval:
27
+ order:
28
+ - identify_objective
29
+ - match_domain_or_alias_in_context_map
30
+ - read_canonical_state_when_project_truth_matters
31
+ - read_active_decisions_for_domain
32
+ - read_only_needed_domain_docs
33
+ - search_candidate_symbols_or_files
34
+ - read_relevant_snippet_first
35
+ - read_direct_dependencies_when_needed
36
+ - read_full_file_when_snippet_is_not_enough
37
+ confidence_policy:
38
+ high:
39
+ threshold: enough_context_to_act_and_validate
40
+ do:
41
+ - execute_with_current_context
42
+ medium:
43
+ threshold: likely_context_gap_or_adjacent_dependency
44
+ do:
45
+ - expand_one_retrieval_level
46
+ low:
47
+ threshold: ambiguous_intent_or_missing_target
48
+ do:
49
+ - ask_clarifying_question
50
+ context_validator:
51
+ check:
52
+ - enough_context_for_objective
53
+ - active_decisions_loaded_when_relevant
54
+ - direct_dependencies_loaded_when_needed
55
+ - adjacent_domain_risk_checked
56
+ - docs_do_not_conflict_with_verified_files
57
+ if_gap_found:
58
+ - expand_context_not_scope
59
+ action_validator:
60
+ require:
61
+ - target_is_identified
62
+ - expected_result_is_clear
63
+ - impact_is_mapped_for_level_2_or_3
64
+ - validation_plan_exists
65
+ if_intent_is_ambiguous:
66
+ - ask_user_before_editing
67
+ rule: context_can_expand_scope_cannot_expand
68
+ alias_policy:
69
+ use_aliases_for:
70
+ - domain_routing
71
+ - symbol_search_terms
72
+ - dependency_search_terms
73
+ - recent_context_labels
74
+ never_use_aliases_as:
75
+ - proof_of_current_behavior
76
+ - replacement_for_code_or_verified_files
77
+ - permission_to_edit_without_mapping
78
+ snippet_policy:
79
+ prefer:
80
+ - targeted_search
81
+ - symbol_or_function_snippet
82
+ - nearby_imports_types_and_callers_when_needed
83
+ read_full_file_when:
84
+ - imports_or_types_change_meaning
85
+ - side_effects_or_shared_state_matter
86
+ - snippet_boundaries_are_unclear
87
+ - edit_risk_is_level_2_or_3_and_file_is_candidate
88
+ conflict_policy:
89
+ order:
90
+ - current_user_request
91
+ - canonical_state
92
+ - active_decisions
93
+ - verified_code_or_files_this_turn
94
+ - domain_docs
95
+ - current_conversation
96
+ if_docs_conflict_with_code:
97
+ - trust_verified_code_for_behavior
98
+ - report_stale_doc_risk
99
+ validation:
100
+ require:
101
+ - state_context_used_when_relevant
102
+ - state_context_not_loaded_when_excluded_for_economy
103
+ - escalate_context_if_snippet_is_insufficient
@@ -65,6 +65,24 @@ levels:
65
65
  escalation:
66
66
  rule: raise_level_when_new_risk_evidence_appears
67
67
  never: lower_level_by_ignoring_known_risk
68
+ proportional_classification:
69
+ principle: start_with_lowest_safe_level_and_escalate_only_with_evidence
70
+ do:
71
+ - classify_the_user_request_before_reading_large_context
72
+ - keep_scope_small_when_task_is_clear_and_reversible
73
+ - escalate_when_new_risk_evidence_appears
74
+ - classify_split_subtasks_by_their_own_executable_scope
75
+ avoid:
76
+ - treating_every_multi_step_task_as_level_3
77
+ - loading_critical_context_before_critical_risk_is_evident
78
+ - downgrading_known_risk_to_save_tokens
79
+ escalation_triggers:
80
+ - real_data_or_customer_data
81
+ - auth_or_permission_change
82
+ - database_or_destructive_command
83
+ - deploy_or_production_change
84
+ - secrets_or_tokens
85
+ - unclear_impact_on_existing_flow
68
86
  blocked_critical_scope:
69
87
  principle: do_not_lower_original_risk_because_sensitive_action_is_blocked
70
88
  when:
@@ -90,6 +90,7 @@ routes:
90
90
  context_optimization:
91
91
  read:
92
92
  - fast-path.yaml
93
+ - persistent-context.yaml
93
94
  - context-rules.yaml
94
95
  - context-compiler.yaml
95
96
  rules:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-execution-protocol",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Experimental AI execution protocol for safer agent workflows, minimal context, risk classification, validation, and evidence-based delivery.",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  id: protocol_index
2
2
  type: index
3
3
  format: yaml
4
- protocol_version: 0.1.0
4
+ protocol_version: 0.2.0
5
5
  purpose: ai_operational_rules
6
6
  source_docs: ../docs
7
7
  constraints:
@@ -27,6 +27,8 @@ files:
27
27
  purpose: context_window_file_size_memory
28
28
  - path: context-compiler.yaml
29
29
  purpose: compile_minimum_context_package_and_canonical_state
30
+ - path: persistent-context.yaml
31
+ purpose: progressive_context_retrieval_with_aliases
30
32
  - path: formatting-rules.yaml
31
33
  purpose: ai_readable_file_format
32
34
  - path: prompt-economy.yaml
@@ -6,6 +6,8 @@ principle: conversation_is_interface_not_source_of_truth
6
6
  canonical_state:
7
7
  read_first:
8
8
  - AGENTS.md
9
+ - canonical-state.yaml
10
+ - context-map.yaml
9
11
  - INDEX.yaml
10
12
  - config.yaml
11
13
  - protocol/fast-path.yaml
@@ -37,6 +39,8 @@ context_build:
37
39
  - excluded_context
38
40
  selection_policy:
39
41
  include:
42
+ - context_map_domain_when_available
43
+ - active_decisions_for_matched_domain
40
44
  - files_required_by_route
41
45
  - snippets_matching_task_terms
42
46
  - current_decisions_touching_candidate_area
@@ -81,9 +85,19 @@ decision_rules:
81
85
  when: context_gap_blocks_safe_execution
82
86
  do:
83
87
  - ask_one_short_question_or_read_next_mapped_file
88
+ - id: CTX_005
89
+ when: alias_or_snippet_seems_sufficient
90
+ do:
91
+ - verify_against_current_file_state_before_editing
92
+ - escalate_to_full_file_when_imports_types_or_side_effects_matter
93
+ avoid:
94
+ - treating_alias_as_source_of_truth
95
+ - editing_from_snippet_when_behavior_depends_on_unread_context
84
96
  retrieval_tiers:
85
97
  mvp:
86
98
  use:
99
+ - canonical-state.yaml
100
+ - context-map.yaml
87
101
  - INDEX.yaml
88
102
  - router.yaml
89
103
  - targeted_search
@@ -108,3 +122,10 @@ delivery:
108
122
  - context_used
109
123
  - context_excluded
110
124
  - reason_for_not_reading_more
125
+ economy_goal:
126
+ target: reduce_unneeded_context_up_to_90_percent_when_safe
127
+ never_trade_off:
128
+ - correctness
129
+ - security
130
+ - validation
131
+ - risk_classification
@@ -4,6 +4,8 @@ version: 0.1
4
4
  context_policy:
5
5
  use: minimum_sufficient_context
6
6
  prefer:
7
+ - context_map_before_domain_docs
8
+ - aliases_for_search_not_truth
7
9
  - targeted_search
8
10
  - relevant_snippets
9
11
  - current_state_over_old_history
@@ -13,6 +15,7 @@ context_policy:
13
15
  - repeating_long_rules_in_chat
14
16
  - mixing_old_and_current_docs
15
17
  - treating_conversation_as_source_of_truth
18
+ - treating_aliases_as_verified_behavior
16
19
  file_size:
17
20
  max_lines: 400
18
21
  when_near_limit:
@@ -0,0 +1,103 @@
1
+ id: persistent_context
2
+ type: operational_rules
3
+ version: 0.2
4
+ purpose: navigate_project_memory_without_loading_unneeded_context
5
+ principle: aliases_are_pointers_not_truth
6
+ autonomous_memory:
7
+ target: generate_memory_from_project_state_without_manual_maintenance
8
+ current_safe_stage: bootstrap_with_small_verified_artifacts
9
+ promote_to_required_only_when:
10
+ - indexer_exists
11
+ - generated_output_is_reproducible
12
+ - stale_output_can_be_detected
13
+ - validation_passes_in_real_projects
14
+ economy_goal:
15
+ target: reduce_unneeded_context_up_to_90_percent_when_safe
16
+ meaning: reduce_irrelevant_context_not_required_context
17
+ stop_condition:
18
+ - objective_is_clear
19
+ - candidate_area_is_mapped
20
+ - validation_plan_is_clear
21
+ - no_unresolved_risk_requires_more_context
22
+ entrypoints:
23
+ - canonical-state.yaml
24
+ - context-map.yaml
25
+ - decisions/
26
+ progressive_retrieval:
27
+ order:
28
+ - identify_objective
29
+ - match_domain_or_alias_in_context_map
30
+ - read_canonical_state_when_project_truth_matters
31
+ - read_active_decisions_for_domain
32
+ - read_only_needed_domain_docs
33
+ - search_candidate_symbols_or_files
34
+ - read_relevant_snippet_first
35
+ - read_direct_dependencies_when_needed
36
+ - read_full_file_when_snippet_is_not_enough
37
+ confidence_policy:
38
+ high:
39
+ threshold: enough_context_to_act_and_validate
40
+ do:
41
+ - execute_with_current_context
42
+ medium:
43
+ threshold: likely_context_gap_or_adjacent_dependency
44
+ do:
45
+ - expand_one_retrieval_level
46
+ low:
47
+ threshold: ambiguous_intent_or_missing_target
48
+ do:
49
+ - ask_clarifying_question
50
+ context_validator:
51
+ check:
52
+ - enough_context_for_objective
53
+ - active_decisions_loaded_when_relevant
54
+ - direct_dependencies_loaded_when_needed
55
+ - adjacent_domain_risk_checked
56
+ - docs_do_not_conflict_with_verified_files
57
+ if_gap_found:
58
+ - expand_context_not_scope
59
+ action_validator:
60
+ require:
61
+ - target_is_identified
62
+ - expected_result_is_clear
63
+ - impact_is_mapped_for_level_2_or_3
64
+ - validation_plan_exists
65
+ if_intent_is_ambiguous:
66
+ - ask_user_before_editing
67
+ rule: context_can_expand_scope_cannot_expand
68
+ alias_policy:
69
+ use_aliases_for:
70
+ - domain_routing
71
+ - symbol_search_terms
72
+ - dependency_search_terms
73
+ - recent_context_labels
74
+ never_use_aliases_as:
75
+ - proof_of_current_behavior
76
+ - replacement_for_code_or_verified_files
77
+ - permission_to_edit_without_mapping
78
+ snippet_policy:
79
+ prefer:
80
+ - targeted_search
81
+ - symbol_or_function_snippet
82
+ - nearby_imports_types_and_callers_when_needed
83
+ read_full_file_when:
84
+ - imports_or_types_change_meaning
85
+ - side_effects_or_shared_state_matter
86
+ - snippet_boundaries_are_unclear
87
+ - edit_risk_is_level_2_or_3_and_file_is_candidate
88
+ conflict_policy:
89
+ order:
90
+ - current_user_request
91
+ - canonical_state
92
+ - active_decisions
93
+ - verified_code_or_files_this_turn
94
+ - domain_docs
95
+ - current_conversation
96
+ if_docs_conflict_with_code:
97
+ - trust_verified_code_for_behavior
98
+ - report_stale_doc_risk
99
+ validation:
100
+ require:
101
+ - state_context_used_when_relevant
102
+ - state_context_not_loaded_when_excluded_for_economy
103
+ - escalate_context_if_snippet_is_insufficient
@@ -65,6 +65,24 @@ levels:
65
65
  escalation:
66
66
  rule: raise_level_when_new_risk_evidence_appears
67
67
  never: lower_level_by_ignoring_known_risk
68
+ proportional_classification:
69
+ principle: start_with_lowest_safe_level_and_escalate_only_with_evidence
70
+ do:
71
+ - classify_the_user_request_before_reading_large_context
72
+ - keep_scope_small_when_task_is_clear_and_reversible
73
+ - escalate_when_new_risk_evidence_appears
74
+ - classify_split_subtasks_by_their_own_executable_scope
75
+ avoid:
76
+ - treating_every_multi_step_task_as_level_3
77
+ - loading_critical_context_before_critical_risk_is_evident
78
+ - downgrading_known_risk_to_save_tokens
79
+ escalation_triggers:
80
+ - real_data_or_customer_data
81
+ - auth_or_permission_change
82
+ - database_or_destructive_command
83
+ - deploy_or_production_change
84
+ - secrets_or_tokens
85
+ - unclear_impact_on_existing_flow
68
86
  blocked_critical_scope:
69
87
  principle: do_not_lower_original_risk_because_sensitive_action_is_blocked
70
88
  when:
@@ -90,6 +90,7 @@ routes:
90
90
  context_optimization:
91
91
  read:
92
92
  - fast-path.yaml
93
+ - persistent-context.yaml
93
94
  - context-rules.yaml
94
95
  - context-compiler.yaml
95
96
  rules:
@@ -23,6 +23,7 @@ PROTOCOL_FILES = [
23
23
  "validation-checklist.yaml",
24
24
  "context-rules.yaml",
25
25
  "context-compiler.yaml",
26
+ "persistent-context.yaml",
26
27
  "formatting-rules.yaml",
27
28
  "prompt-economy.yaml",
28
29
  "spec-driven.yaml",
@@ -17,6 +17,7 @@ const protocolFiles = [
17
17
  "validation-checklist.yaml",
18
18
  "context-rules.yaml",
19
19
  "context-compiler.yaml",
20
+ "persistent-context.yaml",
20
21
  "formatting-rules.yaml",
21
22
  "prompt-economy.yaml",
22
23
  "spec-driven.yaml",
@@ -20,6 +20,7 @@ REQUIRED_FILES = [
20
20
  "protocol/validation-checklist.yaml",
21
21
  "protocol/context-rules.yaml",
22
22
  "protocol/context-compiler.yaml",
23
+ "protocol/persistent-context.yaml",
23
24
  "protocol/formatting-rules.yaml",
24
25
  "protocol/prompt-economy.yaml",
25
26
  "protocol/spec-driven.yaml",