1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
//! GAP-SG-205: the resolved database target, reported on every envelope that
//! resolved one.
//!
//! # Why this is not just another knob record
//!
//! The Explicit Target Designation rule asks for one thing: a verb with a side
//! effect must name its target in the argv, and the target it actually resolved
//! must appear in the output. The second half is what makes the first half
//! auditable — without it, a write that landed in the wrong database leaves no
//! trace to find.
//!
//! v1.2.6 emitted the two members from `super::base_meta`, which sounded
//! right and was not: `base_meta` runs downstream of TWO short-circuits —
//! `crate::output::envelope::emit_json` skips the whole layer when
//! [`super::active`] is false, and [`super::apply`] returns early when
//! [`super::AgentSurface::is_noop`] is true. So the target appeared only for a
//! caller that had already set some unrelated flag, and vanished on the default
//! path every agent actually uses:
//!
//! ```text
//! remember --db T → no agent_surface block at all
//! remember --db T --max-items 50 → db_path_source: "argv"
//! ```
//!
//! Hanging a universal contract off an optional block is the same proxy mistake
//! this release already paid for twice in [`super::gate`]. The cure is not to
//! move the field somewhere else; it is to stop conditioning the block on
//! "some knob is set" and condition it on "there is something to report". A
//! resolved target is something to report.
//!
//! # Why the members live inside `agent_surface`
//!
//! Measured, not assumed: 66 of the 74 published schemas close their root with
//! `additionalProperties: false`, and all 66 already declare `agent_surface`.
//! A new root member would therefore break 66 contracts, while the existing
//! block absorbs the record at zero schema cost.
//!
//! # When nothing is reported
//!
//! Absent means the process never resolved a target, which is the honest answer
//! for `config`, `completions` and `locale` — they touch no database at all. It
//! never means "resolved but omitted"; that distinction is the whole point.
use AgentSurface;
use crate;
use ;
/// Member naming which configuration layer supplied the target.
pub const SOURCE_KEY: &str = "db_path_source";
/// Member carrying the absolute path this process resolved.
pub const RESOLVED_KEY: &str = "db_path_resolved";
/// Member recording that an ambient target was accepted on purpose.
///
/// Present only when the caller passed the dispensation flag, so its absence
/// beside a non-`argv` source is itself the signal that nothing explicit
/// authorised the inheritance.
pub const DISPENSATION_KEY: &str = "db_path_dispensation";
/// Wire spelling of the dispensation, matching the flag that grants it.
pub const DISPENSATION_VALUE: &str = "use-active";
/// Writes the target record into `meta`, when this process resolved a target.
///
/// Idempotent and total: calling it on a record that already carries the
/// members overwrites them with the same values, so both the shaping path and
/// the inert path can call it without coordinating.
/// `true` when this process has a target worth reporting.
///
/// `crate::output::envelope` asks before deciding whether the layer has to run
/// at all, so an envelope from a host-only subcommand keeps the zero-cost path.
/// Builds the record on its own, for envelopes that carry no shaping record.
///
/// Returns `None` when there is no target, which lets the caller skip the
/// insertion entirely rather than attach an empty block.