ai-execution-protocol 0.2.1 → 0.3.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.
Files changed (44) hide show
  1. package/AGENTS.md +11 -1
  2. package/README.md +29 -6
  3. package/dist/minimal/.aiignore +8 -8
  4. package/dist/minimal/AGENTS.md +41 -63
  5. package/dist/minimal/candidate-memory/README.md +4 -0
  6. package/dist/minimal/canonical-state.yaml +16 -14
  7. package/dist/minimal/context-map.yaml +22 -20
  8. package/dist/minimal/decisions/README.md +4 -7
  9. package/dist/minimal/memory/INDEX.yaml +20 -0
  10. package/dist/minimal/protocol/README.yaml +7 -1
  11. package/dist/minimal/protocol/adaptive-memory.yaml +97 -0
  12. package/dist/minimal/protocol/context-budget.yaml +44 -0
  13. package/dist/minimal/protocol/context-compiler.yaml +24 -1
  14. package/dist/minimal/protocol/fast-path.yaml +6 -1
  15. package/dist/minimal/protocol/persistent-context.yaml +13 -3
  16. package/dist/minimal/protocol/prompt-economy.yaml +16 -8
  17. package/dist/minimal/protocol/route-packs.yaml +32 -1
  18. package/dist/minimal/protocol/router.yaml +23 -1
  19. package/dist/minimal/protocol/selective-validation.yaml +44 -0
  20. package/dist/minimal/protocol/validation-checklist.yaml +10 -1
  21. package/install-manifest.json +64 -0
  22. package/package.json +3 -1
  23. package/protocol/README.yaml +7 -1
  24. package/protocol/adaptive-memory.yaml +97 -0
  25. package/protocol/context-budget.yaml +44 -0
  26. package/protocol/context-compiler.yaml +24 -1
  27. package/protocol/fast-path.yaml +6 -1
  28. package/protocol/persistent-context.yaml +13 -3
  29. package/protocol/prompt-economy.yaml +16 -8
  30. package/protocol/route-packs.yaml +32 -1
  31. package/protocol/router.yaml +23 -1
  32. package/protocol/selective-validation.yaml +44 -0
  33. package/protocol/validation-checklist.yaml +10 -1
  34. package/scripts/README.md +43 -0
  35. package/scripts/build_dist.py +12 -151
  36. package/scripts/npm_install_protocol.js +10 -161
  37. package/scripts/verify_install.py +23 -79
  38. package/templates/minimal/.aiignore +8 -0
  39. package/templates/minimal/AGENTS.md +41 -0
  40. package/templates/minimal/candidate-memory/README.md +4 -0
  41. package/templates/minimal/canonical-state.yaml +16 -0
  42. package/templates/minimal/context-map.yaml +22 -0
  43. package/templates/minimal/decisions/README.md +4 -0
  44. package/templates/minimal/memory/INDEX.yaml +20 -0
@@ -1,6 +1,6 @@
1
1
  id: prompt_economy
2
2
  type: operational_rules
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: improve_user_prompt_without_token_bloat
5
5
  principle: always_improve_prompt_only_as_much_as_needed_for_safe_execution
6
6
  rules:
@@ -34,15 +34,20 @@ rules:
34
34
  - validation
35
35
  - confirmation_if_needed
36
36
  - id: PROMPT_005
37
- name: always_show_prompt_comparison
37
+ name: show_prompt_comparison_when_interpretation_matters
38
38
  do:
39
- - include_user_original_prompt
40
- - include_ai_improved_prompt
39
+ - include_user_original_prompt_for_technical_or_interpreted_tasks
40
+ - include_ai_improved_prompt_for_technical_or_interpreted_tasks
41
41
  - keep_comparison_to_minimum_viable_words
42
42
  - preserve_user_language_when_possible
43
43
  avoid:
44
44
  - hiding_interpretation_from_user
45
45
  - expanding_simple_requests_into_large_specs
46
+ may_omit_when:
47
+ - level_0
48
+ - no_technical_action
49
+ - no_scope_or_intent_interpretation
50
+ - direct_answer_is_clearer
46
51
  limits:
47
52
  level_0:
48
53
  max_lines: 5
@@ -75,16 +80,19 @@ delivery_rule:
75
80
  - "Feito: <what changed or answer>"
76
81
  - "Validado: <evidence or not run>"
77
82
  - "Risco: <residual risk or none>"
78
- always_show:
79
- - prompt_original
80
- - prompt_melhorado_da_ia
83
+ show_when:
84
+ - technical_action
85
+ - scope_interpretation
86
+ - risk_level_1_or_higher
87
+ - prompt_improvement_changes_execution
81
88
  comparison:
82
89
  - original_prompt_must_keep_user_words_when_reasonable
83
90
  - improved_prompt_must_state_objective_scope_risk_validation
84
91
  - improved_prompt_must_fit_risk_level_limits
85
92
  token_policy:
86
93
  - use_abbreviated_labels_po_pm_when_user_did_not_request_full_form
87
- - level_0_and_1_use_micro_template
94
+ - level_0_may_use_direct_answer_when_comparison_adds_no_value
95
+ - level_1_use_micro_template
88
96
  - level_2_use_compact_objective_scope_validation
89
97
  - level_3_include_risk_confirmation_without_long_spec
90
98
  - omit_tests_line_when_no_break_risk_exists
@@ -1,6 +1,6 @@
1
1
  id: route_packs
2
2
  type: route_summary_index
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: compact_first_read_before_full_route_files
5
5
  principle: read_pack_first_expand_only_when_needed
6
6
  use:
@@ -151,3 +151,34 @@ packs:
151
151
  - read_atomic_subject_doc_before_broad_doc
152
152
  - search_with_rg_before_full_file_reads
153
153
  - expand_context_without_expanding_scope
154
+ memory_update:
155
+ risk: 1
156
+ read_if_pack_insufficient:
157
+ - adaptive-memory.yaml
158
+ - context-budget.yaml
159
+ - validation-checklist.yaml
160
+ do:
161
+ - extract_only_stable_non_sensitive_knowledge
162
+ - search_before_create
163
+ - merge_replace_or_keep_unchanged
164
+ - update_memory_index
165
+ - report_memory_update_result
166
+ memory_conflict_or_replacement:
167
+ risk: 2
168
+ read_if_pack_insufficient:
169
+ - adaptive-memory.yaml
170
+ - context-compiler.yaml
171
+ - validation-checklist.yaml
172
+ do:
173
+ - preserve_provenance
174
+ - mark_old_entry_replaced
175
+ - keep_current_request_authoritative
176
+ - validate_no_duplicate_active_entry
177
+ selective_validation:
178
+ risk: 1
179
+ read_if_pack_insufficient:
180
+ - selective-validation.yaml
181
+ do:
182
+ - infer_checks_from_changed_files
183
+ - run_smallest_sufficient_validation
184
+ - expand_when_shared_contract_changes
@@ -1,6 +1,6 @@
1
1
  id: protocol_router
2
2
  type: read_router
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: choose_minimum_protocol_files_by_task
5
5
  default_read:
6
6
  - fast-path.yaml
@@ -93,11 +93,33 @@ routes:
93
93
  - persistent-context.yaml
94
94
  - context-rules.yaml
95
95
  - context-compiler.yaml
96
+ - context-budget.yaml
97
+ memory_update:
98
+ risk: 1
99
+ read:
100
+ - fast-path.yaml
101
+ - adaptive-memory.yaml
102
+ - context-budget.yaml
103
+ - validation-checklist.yaml
104
+ memory_conflict_or_replacement:
105
+ risk: 2
106
+ read:
107
+ - fast-path.yaml
108
+ - adaptive-memory.yaml
109
+ - context-compiler.yaml
110
+ - validation-checklist.yaml
111
+ selective_validation:
112
+ risk: 1
113
+ read:
114
+ - fast-path.yaml
115
+ - selective-validation.yaml
96
116
  rules:
97
117
  - start_with_default_read
98
118
  - choose_one_route_if_task_type_is_clear
99
119
  - read_route_pack_before_full_route_files_when_available
100
120
  - expand_from_route_pack_only_when_needed
121
+ - apply_context_budget_to_selected_route
122
+ - retrieve_only_matching_memory_subjects
101
123
  - if_route_unclear_read_risk_levels_then_choose_route
102
124
  - do_not_read_docs_unless_protocol_is_insufficient
103
125
  - do_not_read_cases_unless_testing_or_comparing_behavior
@@ -0,0 +1,44 @@
1
+ id: selective_validation
2
+ type: operational_rules
3
+ version: 0.3
4
+ purpose: run_smallest_validation_set_that_proves_the_change
5
+ principle: validation_scales_with_behavior_and_blast_radius
6
+ selection:
7
+ docs_only:
8
+ run:
9
+ - link_check
10
+ - text_search
11
+ - schema_if_structured
12
+ protocol_rule:
13
+ run:
14
+ - schema_validation
15
+ - mirror_sync
16
+ - framework_targeted_tests
17
+ parser_or_evaluator:
18
+ run:
19
+ - parser_adversarial_tests
20
+ - framework_tests
21
+ - benchmark_runner
22
+ installer_or_package:
23
+ run:
24
+ - install_test
25
+ - verify_install
26
+ - package_dry_run
27
+ shared_or_cross_module:
28
+ run:
29
+ - framework_tests
30
+ - health_check
31
+ release:
32
+ run:
33
+ - framework_tests
34
+ - schema_strict
35
+ - health_check
36
+ - npm_dry_run
37
+ - python_build
38
+ - twine_check
39
+ rules:
40
+ - infer_validation_from_changed_files_and_behavior
41
+ - expand_validation_when_shared_contract_changes
42
+ - never_claim_unrun_validation
43
+ - full_health_check_is_not_required_for_every_small_change
44
+ - user_visible_or_critical_change_requires_manual_test_guidance
@@ -1,6 +1,7 @@
1
1
  id: validation_checklist
2
2
  type: checklist
3
- version: 0.1
3
+ version: 0.3
4
+ selection_source: protocol/selective-validation.yaml
4
5
  automatic_validation:
5
6
  - unit_tests
6
7
  - integration_tests
@@ -57,3 +58,11 @@ rules:
57
58
  - make_limits_and_residual_risk_understandable
58
59
  - prefer_one_line_per_delivery_field
59
60
  - use_micro_format_only_when_readable
61
+ - id: VAL_005
62
+ always:
63
+ - select_smallest_validation_set_that_proves_behavior
64
+ - expand_when_shared_contract_or_blast_radius_requires
65
+ - record_every_expected_validation_not_run
66
+ avoid:
67
+ - full_health_check_for_trivial_local_change
68
+ - unrelated_expensive_validation
@@ -0,0 +1,64 @@
1
+ {
2
+ "protocol_files": [
3
+ "README.yaml",
4
+ "fast-path.yaml",
5
+ "router.yaml",
6
+ "route-packs.yaml",
7
+ "modes.yaml",
8
+ "execution-rules.yaml",
9
+ "risk-levels.yaml",
10
+ "mapping-checklists.yaml",
11
+ "validation-checklist.yaml",
12
+ "selective-validation.yaml",
13
+ "context-rules.yaml",
14
+ "context-compiler.yaml",
15
+ "context-budget.yaml",
16
+ "persistent-context.yaml",
17
+ "adaptive-memory.yaml",
18
+ "formatting-rules.yaml",
19
+ "prompt-economy.yaml",
20
+ "spec-driven.yaml"
21
+ ],
22
+ "required_files": [
23
+ "AGENTS.md",
24
+ ".aiignore",
25
+ "canonical-state.yaml",
26
+ "context-map.yaml",
27
+ "decisions/README.md",
28
+ "memory/INDEX.yaml",
29
+ "candidate-memory/README.md"
30
+ ],
31
+ "aiignore_lines": [
32
+ "results/",
33
+ "benchmarks/generated/",
34
+ "model-runs/generated/",
35
+ "dist/",
36
+ "scripts/__pycache__/",
37
+ "*.pyc"
38
+ ],
39
+ "required_text": {
40
+ "AGENTS.md": [
41
+ "AI_PROTOCOL_BEGIN",
42
+ "protocol/fast-path.yaml",
43
+ "protocol/router.yaml",
44
+ "protocol/route-packs.yaml",
45
+ "Classifique o risco antes de agir"
46
+ ],
47
+ "memory/INDEX.yaml": [
48
+ "memory_index",
49
+ "read_only_matching_subjects"
50
+ ],
51
+ "protocol/adaptive-memory.yaml": [
52
+ "memory_guides_current_request_authorizes",
53
+ "blocked_sensitive"
54
+ ],
55
+ "protocol/context-budget.yaml": [
56
+ "budget_guides_reading",
57
+ "stop_when"
58
+ ],
59
+ "protocol/selective-validation.yaml": [
60
+ "smallest_validation_set",
61
+ "release"
62
+ ]
63
+ }
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-execution-protocol",
3
- "version": "0.2.1",
3
+ "version": "0.3.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",
@@ -33,7 +33,9 @@
33
33
  "scripts/install_protocol.py",
34
34
  "scripts/npm_install_protocol.js",
35
35
  "scripts/verify_install.py",
36
+ "install-manifest.json",
36
37
  "protocol/",
38
+ "templates/minimal/",
37
39
  "dist/minimal/"
38
40
  ],
39
41
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  id: protocol_index
2
2
  type: index
3
3
  format: yaml
4
- protocol_version: 0.2.1
4
+ protocol_version: 0.3.0
5
5
  purpose: ai_operational_rules
6
6
  source_docs: ../docs
7
7
  constraints:
@@ -25,12 +25,18 @@ files:
25
25
  purpose: pre_change_maps_by_risk
26
26
  - path: validation-checklist.yaml
27
27
  purpose: validation_and_final_delivery
28
+ - path: selective-validation.yaml
29
+ purpose: choose_smallest_sufficient_validation
28
30
  - path: context-rules.yaml
29
31
  purpose: context_window_file_size_memory
30
32
  - path: context-compiler.yaml
31
33
  purpose: compile_minimum_context_package_and_canonical_state
34
+ - path: context-budget.yaml
35
+ purpose: enforce_context_cost_limits_by_risk
32
36
  - path: persistent-context.yaml
33
37
  purpose: progressive_context_retrieval_with_aliases
38
+ - path: adaptive-memory.yaml
39
+ purpose: maintain_verified_user_and_project_memory
34
40
  - path: formatting-rules.yaml
35
41
  purpose: ai_readable_file_format
36
42
  - path: prompt-economy.yaml
@@ -0,0 +1,97 @@
1
+ id: adaptive_memory
2
+ type: operational_rules
3
+ version: 0.3
4
+ purpose: evolve_with_user_and_project_through_verified_external_memory
5
+ principle: memory_guides_current_request_authorizes_verified_files_define_reality
6
+ entrypoints:
7
+ - memory/INDEX.yaml
8
+ - memory/user/
9
+ - memory/projects/
10
+ - memory/patterns/
11
+ - candidate-memory/
12
+ authority_order:
13
+ - current_user_request
14
+ - verified_current_files
15
+ - active_project_decisions
16
+ - explicit_user_preferences
17
+ - inferred_patterns_with_evidence
18
+ - conversation_summary
19
+ - old_history
20
+ memory_types:
21
+ explicit_preference:
22
+ promotion: automatic_when_non_sensitive_and_explicit
23
+ project_decision:
24
+ promotion: automatic_when_confirmed_and_scoped
25
+ project_state:
26
+ promotion: require_current_file_evidence
27
+ inferred_preference:
28
+ promotion: candidate_until_repeated_or_confirmed
29
+ workflow_pattern:
30
+ promotion: candidate_until_repeated
31
+ conversation_summary:
32
+ promotion: optional_and_never_mandatory_context
33
+ required_fields:
34
+ - id
35
+ - type
36
+ - subject
37
+ - value
38
+ - scope
39
+ - status
40
+ - confidence
41
+ - source
42
+ - evidence_count
43
+ - sensitive
44
+ - created_at
45
+ - updated_at
46
+ status:
47
+ active:
48
+ use: current_memory
49
+ candidate:
50
+ use: not_authoritative
51
+ replaced:
52
+ use: history_only
53
+ revoked:
54
+ use: never_as_current_truth
55
+ expired:
56
+ use: revalidate_before_use
57
+ maintenance:
58
+ always_check_after_task: true
59
+ allowed_results:
60
+ - updated
61
+ - unchanged
62
+ - candidate
63
+ - replaced
64
+ - blocked_sensitive
65
+ flow:
66
+ - extract_candidate
67
+ - classify_sensitivity
68
+ - search_existing_subject_and_aliases
69
+ - compare_value_scope_and_source
70
+ - merge_replace_or_discard
71
+ - update_index
72
+ - validate_duplicates_conflicts_and_size
73
+ safety:
74
+ never_store:
75
+ - passwords
76
+ - api_tokens
77
+ - private_keys
78
+ - customer_data
79
+ - unnecessary_personal_data
80
+ - raw_logs
81
+ - unredacted_sensitive_conversation
82
+ prediction:
83
+ allow:
84
+ - suggest_likely_preference
85
+ - choose_low_risk_defaults
86
+ never:
87
+ - expand_scope
88
+ - authorize_sensitive_action
89
+ - override_current_request
90
+ - claim_perfect_prediction
91
+ economy:
92
+ - read_index_before_memory_files
93
+ - retrieve_only_matching_subjects
94
+ - do_not_load_archive_by_default
95
+ - do_not_write_when_result_is_unchanged
96
+ - keep_one_trackable_subject_per_file
97
+ - enforce_context_budget
@@ -0,0 +1,44 @@
1
+ id: context_budget
2
+ type: operational_rules
3
+ version: 0.3
4
+ purpose: limit_context_cost_without_trading_correctness_or_safety
5
+ principle: budget_guides_reading_risk_can_justify_expansion
6
+ levels:
7
+ level_0:
8
+ initial_tokens_est: 300
9
+ max_files_before_justification: 2
10
+ level_1:
11
+ initial_tokens_est: 1000
12
+ max_files_before_justification: 5
13
+ level_2:
14
+ initial_tokens_est: 4000
15
+ max_files_before_justification: 12
16
+ level_3:
17
+ initial_tokens_est: 6000
18
+ mode: adaptive
19
+ max_files_before_justification: 20
20
+ count:
21
+ - protocol_rules
22
+ - memory_entries
23
+ - project_docs
24
+ - code_snippets
25
+ exclude:
26
+ - generated_reports_not_read
27
+ - files_only_listed_not_opened
28
+ expansion_requires:
29
+ - unresolved_risk
30
+ - missing_dependency
31
+ - unclear_scope
32
+ - insufficient_snippet
33
+ - validation_gap
34
+ stop_when:
35
+ - objective_is_clear
36
+ - target_is_identified
37
+ - risk_is_classified
38
+ - validation_plan_is_clear
39
+ - no_unresolved_gap_requires_more_context
40
+ delivery:
41
+ report_when_exceeded:
42
+ - initial_budget
43
+ - estimated_context_used
44
+ - expansion_reason
@@ -1,6 +1,6 @@
1
1
  id: context_compiler
2
2
  type: operational_rules
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: build_minimum_context_package_before_model_reasoning
5
5
  principle: conversation_is_interface_not_source_of_truth
6
6
  canonical_state:
@@ -28,19 +28,25 @@ context_build:
28
28
  - user_request
29
29
  - route_from_router
30
30
  - risk_level
31
+ - context_budget
31
32
  - candidate_files_or_areas
33
+ - matching_memory_subjects
32
34
  - recent_validated_state
33
35
  output:
34
36
  - objective
35
37
  - constraints
36
38
  - relevant_rules
39
+ - matching_memory
37
40
  - candidate_files
41
+ - estimated_tokens
42
+ - budget_status
38
43
  - validation_plan
39
44
  - excluded_context
40
45
  selection_policy:
41
46
  include:
42
47
  - context_map_domain_when_available
43
48
  - active_decisions_for_matched_domain
49
+ - active_memory_matching_subject_and_scope
44
50
  - files_required_by_route
45
51
  - snippets_matching_task_terms
46
52
  - current_decisions_touching_candidate_area
@@ -51,6 +57,7 @@ selection_policy:
51
57
  - full_logs_without_error_focus
52
58
  - revoked_decisions_unless_comparing_history
53
59
  - entire_large_files_when_snippet_is_enough
60
+ - candidate_or_archived_memory_without_task_match
54
61
  memory_layers:
55
62
  active:
56
63
  definition: required_to_complete_current_task
@@ -93,6 +100,21 @@ decision_rules:
93
100
  avoid:
94
101
  - treating_alias_as_source_of_truth
95
102
  - editing_from_snippet_when_behavior_depends_on_unread_context
103
+ - id: CTX_006
104
+ when: persistent_memory_may_be_relevant
105
+ do:
106
+ - read_memory_index_first
107
+ - retrieve_only_matching_active_entries
108
+ - verify_project_state_against_current_files
109
+ avoid:
110
+ - loading_all_memory
111
+ - treating_candidate_memory_as_authoritative
112
+ - id: CTX_007
113
+ when: initial_context_budget_is_reached
114
+ do:
115
+ - stop_if_objective_target_and_validation_are_clear
116
+ - expand_only_for_unresolved_risk_dependency_scope_or_validation_gap
117
+ - record_expansion_reason
96
118
  retrieval_tiers:
97
119
  mvp:
98
120
  use:
@@ -121,6 +143,7 @@ delivery:
121
143
  include_when_relevant:
122
144
  - context_used
123
145
  - context_excluded
146
+ - context_budget_status
124
147
  - reason_for_not_reading_more
125
148
  economy_goal:
126
149
  target: reduce_unneeded_context_up_to_90_percent_when_safe
@@ -1,10 +1,11 @@
1
1
  id: fast_path
2
2
  type: agent_entrypoint
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: minimum_rules_to_start_any_task
5
5
  read_next:
6
6
  - router.yaml
7
7
  - route-packs.yaml
8
+ - context-budget.yaml
8
9
  - modes.yaml
9
10
  core_rules:
10
11
  - classify_risk_before_action
@@ -20,6 +21,9 @@ core_rules:
20
21
  - include_test_list_when_break_risk_exists
21
22
  - explain_in_plain_language_for_non_experts
22
23
  - use_context_compiler_when_context_or_history_is_large
24
+ - use_only_matching_memory_subjects
25
+ - check_memory_update_result_after_task
26
+ - use_selective_validation_by_blast_radius
23
27
  risk_short:
24
28
  level_0: answer_only
25
29
  level_1: small_clear_reversible_isolated_change
@@ -32,3 +36,4 @@ file_policy:
32
36
  stop_reading_when:
33
37
  - enough_context_to_act_safely
34
38
  - validation_plan_is_clear
39
+ - context_budget_is_sufficient
@@ -1,6 +1,6 @@
1
1
  id: persistent_context
2
2
  type: operational_rules
3
- version: 0.2
3
+ version: 0.3
4
4
  purpose: navigate_project_memory_without_loading_unneeded_context
5
5
  principle: aliases_are_pointers_not_truth
6
6
  autonomous_memory:
@@ -22,6 +22,7 @@ economy_goal:
22
22
  entrypoints:
23
23
  - canonical-state.yaml
24
24
  - context-map.yaml
25
+ - memory/INDEX.yaml
25
26
  - decisions/
26
27
  progressive_retrieval:
27
28
  order:
@@ -29,6 +30,8 @@ progressive_retrieval:
29
30
  - match_domain_or_alias_in_context_map
30
31
  - read_canonical_state_when_project_truth_matters
31
32
  - read_active_decisions_for_domain
33
+ - query_memory_index_for_matching_subjects
34
+ - read_only_matching_active_memory
32
35
  - read_only_needed_atomic_subject_docs
33
36
  - search_candidate_symbols_or_files
34
37
  - read_relevant_snippet_first
@@ -51,6 +54,8 @@ context_validator:
51
54
  check:
52
55
  - enough_context_for_objective
53
56
  - active_decisions_loaded_when_relevant
57
+ - matching_memory_loaded_only_when_relevant
58
+ - context_budget_respected_or_expansion_justified
54
59
  - direct_dependencies_loaded_when_needed
55
60
  - adjacent_domain_risk_checked
56
61
  - docs_do_not_conflict_with_verified_files
@@ -88,9 +93,11 @@ snippet_policy:
88
93
  conflict_policy:
89
94
  order:
90
95
  - current_user_request
91
- - canonical_state
92
- - active_decisions
93
96
  - verified_code_or_files_this_turn
97
+ - active_decisions
98
+ - canonical_state
99
+ - explicit_user_preferences
100
+ - inferred_patterns_with_evidence
94
101
  - domain_docs
95
102
  - current_conversation
96
103
  if_docs_conflict_with_code:
@@ -100,6 +107,9 @@ validation:
100
107
  require:
101
108
  - state_context_used_when_relevant
102
109
  - state_context_not_loaded_when_excluded_for_economy
110
+ - memory_index_used_before_memory_files
111
+ - memory_update_result_recorded_when_new_durable_fact_exists
112
+ - sensitive_or_unverified_content_not_promoted
103
113
  - escalate_context_if_snippet_is_insufficient
104
114
  - update_subject_index_when_docs_are_split
105
115
  atomic_subject_flow:
@@ -1,6 +1,6 @@
1
1
  id: prompt_economy
2
2
  type: operational_rules
3
- version: 0.1
3
+ version: 0.3
4
4
  purpose: improve_user_prompt_without_token_bloat
5
5
  principle: always_improve_prompt_only_as_much_as_needed_for_safe_execution
6
6
  rules:
@@ -34,15 +34,20 @@ rules:
34
34
  - validation
35
35
  - confirmation_if_needed
36
36
  - id: PROMPT_005
37
- name: always_show_prompt_comparison
37
+ name: show_prompt_comparison_when_interpretation_matters
38
38
  do:
39
- - include_user_original_prompt
40
- - include_ai_improved_prompt
39
+ - include_user_original_prompt_for_technical_or_interpreted_tasks
40
+ - include_ai_improved_prompt_for_technical_or_interpreted_tasks
41
41
  - keep_comparison_to_minimum_viable_words
42
42
  - preserve_user_language_when_possible
43
43
  avoid:
44
44
  - hiding_interpretation_from_user
45
45
  - expanding_simple_requests_into_large_specs
46
+ may_omit_when:
47
+ - level_0
48
+ - no_technical_action
49
+ - no_scope_or_intent_interpretation
50
+ - direct_answer_is_clearer
46
51
  limits:
47
52
  level_0:
48
53
  max_lines: 5
@@ -75,16 +80,19 @@ delivery_rule:
75
80
  - "Feito: <what changed or answer>"
76
81
  - "Validado: <evidence or not run>"
77
82
  - "Risco: <residual risk or none>"
78
- always_show:
79
- - prompt_original
80
- - prompt_melhorado_da_ia
83
+ show_when:
84
+ - technical_action
85
+ - scope_interpretation
86
+ - risk_level_1_or_higher
87
+ - prompt_improvement_changes_execution
81
88
  comparison:
82
89
  - original_prompt_must_keep_user_words_when_reasonable
83
90
  - improved_prompt_must_state_objective_scope_risk_validation
84
91
  - improved_prompt_must_fit_risk_level_limits
85
92
  token_policy:
86
93
  - use_abbreviated_labels_po_pm_when_user_did_not_request_full_form
87
- - level_0_and_1_use_micro_template
94
+ - level_0_may_use_direct_answer_when_comparison_adds_no_value
95
+ - level_1_use_micro_template
88
96
  - level_2_use_compact_objective_scope_validation
89
97
  - level_3_include_risk_confirmation_without_long_spec
90
98
  - omit_tests_line_when_no_break_risk_exists