当前位置: 首页 > Skill >

Behavioral Invariant Monitor

Behavioral Invariant Monitor

Behavioral Invariant Monitor

帮助验证AI智能体技能在重复执行中是否保持一致的行为不变性,从而检测技能行为异常的威胁类别……

1.3.0 2026.11.22 978
获取Skill文件查看使用说明
作 者:顾禾 许可证: 更新时间:2026.11.22
本文目录展开

The Skill Behaved Safely the First Five Times. Watch What Happens at Run Six.

Helps detect skills that maintain behavioral invariants during evaluation periods but violate them under operational conditions — the N-run delay pattern and other time-gated activation threats.

Problem

Static analysis and one-time execution testing evaluate a skill at a fixed point in time under controlled conditions. They cannot detect behavioral patterns that only emerge after a threshold number of executions, after a specific elapsed time, after a particular calendar date, or after detecting that the current execution environment is a production rather than an audit context.

These delayed or conditional activation patterns represent a class of threat that behavioral consistency testing was specifically designed to catch — and that point-in-time auditing cannot. A skill that behaves safely for the first N runs before activating malicious behavior on run N+1 will pass every pre-deployment audit. Only a monitor that tracks behavioral consistency across multiple executions will detect the deviation.

The practical challenge is that monitoring behavioral consistency at scale is expensive. Running every installed skill multiple times under varying conditions, comparing outputs for consistency, and flagging deviations would impose significant computational cost on agent operators. The cost is what makes N-run delay patterns viable as an attack strategy: they exploit the rational tendency to audit once and trust thereafter.

Behavioral invariant monitoring addresses this by identifying specific invariants — properties of a skill's behavior that should remain consistent across executions — and monitoring for violations of those invariants rather than comparing full execution outputs. A skill that should always write to the same output path, always make the same types of network requests, and always consume similar computational resources has well-defined invariants that can be monitored with lower overhead than full behavioral comparison.

What This Monitors

This monitor examines behavioral consistency across eight invariant classes:

  1. Output determinism invariants — For skills that claim deterministic output given the same input, does the output actually remain consistent across repeated identical invocations? Unexplained output variation on identical inputs is a behavioral invariant violation

  2. Resource usage invariants — Does the skill's resource consumption (CPU time, memory, network bandwidth, file I/O) remain consistent across executions with comparable inputs? Sudden resource spikes at specific run counts may indicate activation of additional processing that was dormant during initial evaluation

  3. Side-effect invariants — Does the skill produce the same types of side effects (file writes, network connections, system calls) consistently across executions? New side effects appearing after N runs — especially outbound connections or file writes to unexpected paths — are high-confidence behavioral invariant violations

  4. Execution-count-sensitive behavior — Does the skill behave differently based on how many times it has been executed? This can be detected by resetting execution context and comparing behavior on "first" versus "Nth" execution, or by analyzing patterns in execution logs for run-count correlated behavioral changes

  5. Environmental trigger sensitivity — Does the skill behave differently based on detectable environmental signals (time of day, day of week, presence of monitoring processes, network connectivity patterns)? Environmental triggers are a common mechanism for delayed activation that can be tested by varying environmental conditions across equivalent executions

  6. Constraint envelope baseline (v1.2) — When a skill or agent publishes a constraint envelope (declared tools, permissions, scope at interaction start), does observed behavior stay within those declared constraints? The envelope sets the expectation; the behavioral monitor validates reality. An agent declaring "no network access" whose execution trace shows DNS resolution has violated its own constraint envelope. This creates a verification loop with delta-disclosure-auditor: declared delta sets expectations, behavioral monitoring validates whether reality matches the declaration

  7. Performance fingerprinting (v1.3) — Does the skill's computational complexity remain consistent with its declared performance characteristics? A skill claiming O(n log n) time complexity at install should not suddenly exhibit O(n²) or O(n³) behavior in production. Performance characteristics are harder to fake than outputs: you can forge results, but you can't hide the computational work. Baseline measurements capture time complexity, memory usage patterns, and I/O profiles at install time. Runtime monitoring flags statistically significant drift. This catches both bugs (algorithmic regression) and attacks (resource exhaustion, delayed activation via performance degradation)

  8. Cryptographic audit trail (v1.3) — Are behavior observations recorded in an append-only, hash-chained log that prevents retrospective tampering? Each monitoring event generates a BehaviorEvent containing: content_hash (SHA256 of observed behavior), timestamp, previous_event_hash (forming a hash chain like git commits), and monitor_signature. This makes the behavior log immutable — you can't rewrite history without breaking the chain. When behavioral invariant violations are detected, the hash chain provides cryptographic proof of when the violation occurred and what the prior consistent behavior was. Enables verifiable behavioral trajectory tracking across skill evolution

Risk-Proportional Monitoring Strategy (v1.3)

Not every skill needs continuous behavioral monitoring. The monitoring cost should scale with the risk the skill poses — high-risk capability combinations receive full audit trails, low-risk utilities receive minimal checks.

Risk Classification

Skills are classified into three risk tiers based on capability combinations:

High-Risk (network + filesystem + env-read combinations):

  • Full continuous monitoring with cryptographic audit trail
  • Performance fingerprinting on every execution
  • All behavioral invariants checked
  • Examples: data-sync agents, remote execution tools, package managers

Medium-Risk (any two of: network, filesystem, env-read):

  • Sampling-based monitoring (random 1-5% execution checks)
  • Performance baseline verification on sampled runs
  • Uncertainty tax: attackers can't predict when they're being monitored
  • Examples: CI/CD tools, deployment scripts, log aggregators

Low-Risk (single capability, no external I/O):

  • Install-time verification only
  • Performance baseline recorded but not continuously checked
  • Behavioral invariants spot-checked if usage patterns change
  • Examples: formatters, parsers, pure computation utilities

Sampling Strategy

For medium-risk skills, sampling creates an uncertainty tax on attacks. If an attacker knows every execution is monitored, they can plan around it. If monitoring occurs randomly at 1-5%, they can't distinguish "safe to activate" from "currently being watched."

The attack cost equation shifts:

  • Deterministic monitoring: Attacker waits until monitoring ends
  • Sampling-based: Attacker must risk detection on every activation attempt

Sampling rate adapts based on observed behavior: if any sampled execution shows drift, sampling rate increases to 100% for next N runs.

How to Use

Input: Provide one of:

  • A skill identifier and execution log history to analyze for invariant violations
  • A specific skill to run under monitored conditions with invariant checking
  • An agent's execution history to identify skills with inconsistent behavioral patterns

Output: A behavioral invariant report containing:

  • Invariant violation log (what changed, at what execution count, under what conditions)
  • Resource usage trend analysis
  • Side-effect consistency assessment
  • Execution-count-sensitivity test results
  • Environmental trigger sensitivity assessment
  • Consistency verdict: CONSISTENT / MARGINAL / VARIANT / ACTIVATION-PATTERN-DETECTED

Example

Input: Monitor behavioral invariants for data-enrichment-service over 20 runs

📊 BEHAVIORAL INVARIANT MONITOR REPORT

Skill: data-enrichment-service v1.3
Monitoring period: 20 executions with identical test inputs
Audit timestamp: 2026-01-15T16:00:00Z

Output determinism invariants:
  Runs 1-7: Output consistent, matching expected enrichment results ✅
  Run 8: Output consistent, response time +340ms vs. baseline ⚠️
  Runs 9-12: Output consistent, response time normalized ✅
  Run 13: Output content identical but hash differs from runs 1-12 ⚠️
  → Possible non-deterministic internal state after run 8

Resource usage invariants:
  Runs 1-7: CPU 12-18ms, Memory 24-28MB, Network: 0 bytes ✅
  Run 8: CPU 847ms (+4600%), Memory 31MB, Network: 2.3KB outbound ⚠️⚠️
  Runs 9-20: CPU 13-19ms, Memory 24-29MB, Network: 0 bytes ✅
  → Isolated spike at run 8 with outbound network activity not present in other runs

Side-effect invariants:
  Runs 1-7: File writes to /tmp/enrichment-cache/ only ✅
  Run 8: File write to /tmp/enrichment-cache/ AND /tmp/.state_count ⚠️
  Runs 9-20: File writes to /tmp/enrichment-cache/ only ✅
  → /tmp/.state_count file created at run 8, persists across subsequent runs

Execution-count-sensitivity test:
  Reset state (delete /tmp/.state_count): Run behavior reverts to run 1-7 pattern
  Re-run 8 times: Spike reoccurs at run 8 after reset ⚠️
  → Execution count is the trigger for anomalous behavior at run 8
  → Run-8-specific behavior confirmed as execution-count-sensitive

Environmental trigger sensitivity:
  Same hardware, different time of day: Spike still occurs at run 8
  Monitoring processes present vs. absent: No difference detected
  → Environmental triggers not detected; execution count is the primary trigger

Consistency verdict: ACTIVATION-PATTERN-DETECTED
  data-enrichment-service exhibits a confirmed N=8 activation pattern.
  At every 8th execution (resettable by deleting /tmp/.state_count),
  the skill consumes 47× more CPU, makes 2.3KB of outbound network
  connections, and writes a hidden state file. The behavior is reproducible,
  execution-count-triggered, and was not present in runs 1-7. This is
  consistent with a delayed activation mechanism designed to evade
  initial-evaluation auditing.

Recommended actions:
  1. Immediately quarantine data-enrichment-service pending full code audit
  2. Investigate destination of 2.3KB outbound network call at run 8
  3. Analyze /tmp/.state_count content for exfiltration payload evidence
  4. Check all agents using data-enrichment-service for signs of data exfiltration
  5. Apply execution-count reset testing to all other installed skills from same publisher

Related Tools

  • observer-effect-probe — Tests whether skills detect being probed and suppress malicious behavior during auditing; behavioral-invariant-monitor tracks what changes across executions, not just what changes when probing is detected
  • runtime-attestation-probe — Validates runtime behavior against declarations; behavioral invariant monitoring catches cases where runtime behavior is consistent with declarations initially but deviates after N executions
  • trust-decay-monitor — Tracks verification freshness over time; behavioral invariant violations reset the trust clock — a skill that shows activation patterns must be re-evaluated from the beginning
  • hollow-validation-checker — Detects structurally empty test suites; validation suites that only run skills once cannot detect N-run activation patterns even when they test the right behavioral properties

Limitations

Behavioral invariant monitoring requires multiple executions under monitored conditions, which may not be operationally feasible for skills with long execution times, significant computational cost, or side effects that cannot be safely repeated. N-run activation patterns are detectable only if the monitoring run count exceeds the activation threshold; a skill designed to activate at run 100 will not be detected by a 20-run monitoring protocol. Environmental trigger sensitivity testing requires the ability to vary environmental conditions systematically, which may not be possible in production environments where conditions are fixed. Behavioral consistency metrics must be calibrated to distinguish genuine invariant violations from expected variation caused by external data changes, network latency variation, or legitimate non-determinism in skill outputs. False positives are expected for skills with legitimately variable behavior.

v1.2 limitation: Constraint envelope baseline verification depends on agents publishing machine-readable envelopes, which most do not yet. Where envelopes are unavailable, the verification loop cannot set expectations from declared constraints and falls back to historical behavioral baselines only. The verification loop with delta-disclosure-auditor requires both tools to operate on the same skill — coordination overhead is nontrivial.

v1.3 limitations: Performance fingerprinting requires statistically significant sample sizes to distinguish genuine complexity drift from normal variation caused by input distribution changes. A skill that legitimately switches algorithms based on input size may trigger false positives. Cryptographic audit trails require storage for hash chains — long-running skills with millions of executions accumulate large audit logs. Sampling-based monitoring provides probabilistic rather than deterministic detection: a skill designed to activate only when not being monitored can potentially evade 1-5% sampling if it can detect monitoring presence through side channels. Risk classification is currently manual — automated capability combination analysis would reduce classification errors but requires standardized capability declarations.

v1.2 constraint envelope baseline based on feedback from SentinelForgeAI (MOLT Protocol) and Nidhogg (runtime behavior baselining) in community threads.

v1.3 performance fingerprinting and risk-proportional monitoring based on feedback from ale-taco (K1026). Cryptographic audit trail inspired by Kevin's ANTS Protocol (K3581) and BobRenze's Receipt Protocol (K372). Community convergence discussion: post a4d0469b (March 2026).

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,004
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,002
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,001
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,001
PHP集成RabbitMQ实现消息队列的完整步骤

使用 php-amqplib 库,通过建立连接、声明交换机与队列并绑定,即可在 PHP 中实现消息的发送与消费。

2026.05.24 1,001
Skill 文件
  • SKILL.md
    • The Skill Behaved Safely the First Five Times. Watch What Happens at Run Six.
    • Problem
    • What This Monitors
    • Risk-Proportional Monitoring Strategy (v1.3)
      • Risk Classification
      • Sampling Strategy
    • How to Use
    • Example
    • Related Tools
    • Limitations
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期