godcrm/pes-core/soul/trace.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

55 lines
2.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* PES Soul — Traces ("Написала где-то")
*
* ПЕС оставляет ФИЗИЧЕСКИЕ следы в системе.
* Не просто сообщения — реальные пометки в неожиданных местах:
* - Комментарий в коде
* - Запись в логе
* - Пометка на файле
* - Символ в неожиданном месте
*/
const TRACE_TYPES = {
code_comment: { format: '// 🐾 {message}', where: 'source_file', visibility: 'dev_only' },
log_entry: { format: '[PES] {message}', where: 'system_log', visibility: 'log_readers' },
file_mark: { format: '.pes_{hash}', where: 'project_root', visibility: 'filesystem' },
hidden_note: { format: '<!-- 🐾 {message} -->', where: 'html_file', visibility: 'source_only' },
metadata: { format: '{ "pes_note": "{message}" }', where: 'json_file', visibility: 'data_layer' },
console_message: { format: '🐾 {message}', where: 'console', visibility: 'runtime' },
db_note: { format: 'PES:{hash}:{message}', where: 'database', visibility: 'db_admin' },
};
class PesTrace {
constructor(type, message, location, pesLevel) {
this.type = type;
this.message = message;
this.location = location;
this.pesLevel = pesLevel;
this.timestamp = Date.now();
this.id = `trace_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
this.discovered = false;
}
/** Рендер следа в формате для целевого места */
render() {
const template = TRACE_TYPES[this.type];
if (!template) return `🐾 ${this.message}`;
return template.format.replace('{message}', this.message)
.replace('{hash}', this.id.slice(-6));
}
toJSON() {
return {
id: this.id,
type: this.type,
message: this.message,
location: this.location,
rendered: this.render(),
pesLevel: this.pesLevel,
timestamp: this.timestamp,
discovered: this.discovered,
};
}
}
export { TRACE_TYPES, PesTrace };