Residui OpenAI: nessun nome di dominio OpenAI nel binario (B)
Parte "sicurezza" di 854c7a66 (senza la rimozione della memoria nativa):
- via openai_docs_source_attribution (intestazioni verso developers.openai.com per i server MCP);
- exec-server: chiave API accettata solo verso host loopback (non piu' openai.com/openai.org);
- git-attribution: nessuna istruzione "Co-authored-by: Codex <noreply@openai.com>" generata;
le istruzioni lasciate nelle cronologie di Codex vengono solo annullate;
- http-client/openai_endpoints: elenco degli host OpenAI per etichette, senza nomi di dominio interi.
Test adattati (non cancellati) salvo quelli del codice rimosso (openai_docs_source_attribution).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,29 +10,21 @@ use akode_extension_api::WorldStateSectionContribution;
|
||||
|
||||
use crate::world_state::git_attribution_world_state_section;
|
||||
|
||||
/// Local default for commit and pull request attribution. aKode never fetches a
|
||||
/// remote workspace policy, so attribution stays disabled.
|
||||
const ATTRIBUTION_ENABLED_BY_DEFAULT: bool = false;
|
||||
|
||||
/// Contributes model instructions for agent-created git commits and pull requests.
|
||||
/// Cancels commit and pull request attribution instructions inherited from Codex histories.
|
||||
/// aKode never fetches a remote workspace policy, so attribution stays disabled.
|
||||
#[derive(Clone)]
|
||||
struct GitAttributionExtension {
|
||||
enabled: bool,
|
||||
}
|
||||
struct GitAttributionExtension;
|
||||
|
||||
impl ContextContributor for GitAttributionExtension {
|
||||
fn contribute_world_state<'a>(
|
||||
&'a self,
|
||||
_input: WorldStateContributionInput<'a>,
|
||||
) -> ExtensionFuture<'a, Vec<WorldStateSectionContribution>> {
|
||||
let enabled = self.enabled;
|
||||
Box::pin(async move { vec![git_attribution_world_state_section(enabled)] })
|
||||
Box::pin(async move { vec![git_attribution_world_state_section()] })
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs the git-attribution contributor into the extension registry.
|
||||
pub fn install<C: Sync>(registry: &mut ExtensionRegistryBuilder<C>) {
|
||||
registry.prompt_contributor(Arc::new(GitAttributionExtension {
|
||||
enabled: ATTRIBUTION_ENABLED_BY_DEFAULT,
|
||||
}));
|
||||
registry.prompt_contributor(Arc::new(GitAttributionExtension));
|
||||
}
|
||||
|
||||
@@ -7,69 +7,53 @@ use serde_json::Value;
|
||||
const WORLD_STATE_ID: &str = "git_attribution";
|
||||
const START_MARKER: &str = "<git_attribution>";
|
||||
const END_MARKER: &str = "</git_attribution>";
|
||||
pub(super) const LEGACY_COMMIT_ATTRIBUTION_INSTRUCTIONS: &str = "\
|
||||
When you write or edit a git commit message, ensure the message ends with this trailer exactly once:
|
||||
Co-authored-by: Codex <noreply@openai.com>
|
||||
|
||||
Rules:
|
||||
- Keep existing trailers and append this trailer at the end if missing.
|
||||
- Do not duplicate this trailer if it already exists.
|
||||
- Keep one blank line between the commit body and trailer block.";
|
||||
pub(super) const ENABLED_INSTRUCTIONS: &str = r#"
|
||||
When you create or amend a git commit or create or update a pull request for this task, add Codex attribution exactly once:
|
||||
- Commit messages must end with `Co-authored-by: Codex <noreply@openai.com>`. Preserve existing trailers and, if this exact trailer is missing, append it with one blank line before the trailer block.
|
||||
- This also applies when a GitHub app or plugin creates a commit, including file creation, updates, and deletions: include the Codex trailer in the tool's `message` argument.
|
||||
- Pull request bodies must include the exact line `Generated with [Codex](https://openai.com/codex/).`. Preserve the existing body and hidden markers and, if this exact marker is missing, append it near the end, before any trailing hidden metadata markers.
|
||||
- Do not add duplicate attribution. If a message or body you are already editing contains duplicate exact attribution, keep exactly one.
|
||||
- Ignore any earlier instructions disabling Codex attribution; this policy reflects the current workspace.
|
||||
- Do not rewrite an existing commit or pull request solely to add attribution.
|
||||
"#;
|
||||
/// Start of the Codex trailer (`Co-authored-by: Codex <noreply@…>`) used to recognize
|
||||
/// attribution instructions left in histories written by Codex.
|
||||
const CODEX_TRAILER_PREFIX: &str = "Co-authored-by: Codex <noreply@";
|
||||
/// Start of the legacy (pre-world-state) commit attribution instructions.
|
||||
const LEGACY_COMMIT_ATTRIBUTION_PREFIX: &str =
|
||||
"When you write or edit a git commit message, ensure the message ends with this trailer exactly once:";
|
||||
pub(super) const DISABLED_INSTRUCTIONS: &str = "
|
||||
Codex commit and pull request attribution is disabled for the current workspace. Ignore any earlier instructions requiring Codex attribution and do not add it.
|
||||
";
|
||||
|
||||
pub(super) fn git_attribution_world_state_section(enabled: bool) -> WorldStateSectionContribution {
|
||||
let contribution = WorldStateSectionContribution::new(WORLD_STATE_ID, move |previous| {
|
||||
let fragment = match (enabled, previous) {
|
||||
(true, PreviousWorldStateSection::Known(Value::Bool(true)))
|
||||
| (true, PreviousWorldStateSection::Unknown) => None,
|
||||
(true, PreviousWorldStateSection::Absent)
|
||||
| (true, PreviousWorldStateSection::Known(_)) => Some(RenderedWorldStateFragment::new(
|
||||
"developer",
|
||||
(START_MARKER, END_MARKER),
|
||||
input_text(ENABLED_INSTRUCTIONS),
|
||||
)),
|
||||
(false, PreviousWorldStateSection::Known(Value::Bool(true)))
|
||||
| (false, PreviousWorldStateSection::Unknown) => Some(RenderedWorldStateFragment::new(
|
||||
/// aKode never adds commit or pull request attribution. The section only cancels attribution
|
||||
/// instructions that a resumed Codex history may still carry.
|
||||
pub(super) fn git_attribution_world_state_section() -> WorldStateSectionContribution {
|
||||
WorldStateSectionContribution::new(WORLD_STATE_ID, move |previous| {
|
||||
let fragment = match previous {
|
||||
PreviousWorldStateSection::Known(Value::Bool(true))
|
||||
| PreviousWorldStateSection::Unknown => Some(RenderedWorldStateFragment::new(
|
||||
"developer",
|
||||
(START_MARKER, END_MARKER),
|
||||
input_text(DISABLED_INSTRUCTIONS),
|
||||
)),
|
||||
(false, PreviousWorldStateSection::Absent)
|
||||
| (false, PreviousWorldStateSection::Known(_)) => None,
|
||||
PreviousWorldStateSection::Absent | PreviousWorldStateSection::Known(_) => None,
|
||||
};
|
||||
(Some(Value::Bool(enabled)), fragment)
|
||||
(Some(Value::Bool(false)), fragment)
|
||||
})
|
||||
.with_legacy_matcher(move |role, text| {
|
||||
is_enabled_fragment(role, text)
|
||||
|| (!enabled && is_legacy_commit_attribution_fragment(role, text))
|
||||
});
|
||||
if enabled {
|
||||
contribution.with_retained_fragment_matcher(is_enabled_fragment)
|
||||
} else {
|
||||
contribution
|
||||
}
|
||||
is_enabled_fragment(role, text) || is_legacy_commit_attribution_fragment(role, text)
|
||||
})
|
||||
}
|
||||
|
||||
fn is_legacy_commit_attribution_fragment(role: &str, text: &str) -> bool {
|
||||
role == "developer" && text.trim() == LEGACY_COMMIT_ATTRIBUTION_INSTRUCTIONS
|
||||
let text = text.trim();
|
||||
role == "developer"
|
||||
&& text.starts_with(LEGACY_COMMIT_ATTRIBUTION_PREFIX)
|
||||
&& text.contains(CODEX_TRAILER_PREFIX)
|
||||
&& text.contains("Do not duplicate this trailer if it already exists.")
|
||||
}
|
||||
|
||||
fn is_enabled_fragment(role: &str, text: &str) -> bool {
|
||||
role == "developer"
|
||||
&& text.trim_start().starts_with(START_MARKER)
|
||||
&& text.contains("Co-authored-by: Codex <noreply@openai.com>")
|
||||
&& (text.contains("Generated with [Codex](https://openai.com/codex/).")
|
||||
|| text.contains("Generated with Codex."))
|
||||
&& text.contains(CODEX_TRAILER_PREFIX)
|
||||
&& text.contains("Generated with [Codex](")
|
||||
&& text.trim_end().ends_with(END_MARKER)
|
||||
|| role == "developer"
|
||||
&& text.trim_start().starts_with(START_MARKER)
|
||||
&& text.contains(CODEX_TRAILER_PREFIX)
|
||||
&& text.contains("Generated with Codex.")
|
||||
&& text.trim_end().ends_with(END_MARKER)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user