Manuscript Offprint
arXiv:2611.08445A Hidden Markov Preference Model for Online Prediction of Adversary Actions
Abstract
A defender anticipating an attacker needs a probability distribution over the attacker's next action from information available before that action occurs. Two structures complicate this: the attacker's behavioral regime persists and can switch within an episode, and each action combines an operation with state-dependent arguments whose feasible values change over time. We capture both with a hidden Markov model whose latent state is the active regime and whose regime-conditioned action law is defined on a feasibility-masked tree of executable actions. The same likelihood forms the next-action distribution and updates the regime belief once the action is seen, and a partially observed prefix contributes its resolved local factors. Estimation separates into convex logistic fits that Baum–Welch reuses when regimes are unlabeled. We derive a reach-weighted nodewise KL expression for regime information, a sequence-wise log-loss bound for switching regime paths, and a uniform fallback guarantee. On the CAGE 2 cyber defense benchmark the filtered latent state is worth 0.8 nats per step, and after a controller switch the loss begins to fall in three steps against ten for a recurrent baseline.
Index Terms— Hidden Markov models, discrete choice, online prediction, preference learning, cyber defense
1 Introduction
An observer often needs a probability distribution over another agent's next action from its own observation record, with a network defender anticipating an intruder as the running example. Because the record omits the agent's private state and objectives, prediction must rely on structure reflected in observable behavior. Behavioral patterns persist across consecutive steps and can change within an episode, as when an intruder moves from reconnaissance to exploitation or reacts to a defensive move, and each action combines an operation with arguments whose admissible values depend on the current state, leaving much of the nominal action space infeasible.
Preference learning estimates a probabilistic choice rule from revealed choices through Bradley–Terry and Luce likelihoods [1, 2], and quantal-response versions are fitted to observed attacks in security games [3, 4]. Hidden context can cause a single fitted choice law to aggregate behavior generated under different unobserved conditions [5]. Latent-class and mixture models capture such heterogeneity at the user or episode level [6, 7], while input–output hidden Markov models [8] and hidden-Markov choice models [9] let the latent class evolve over time. Opponent-modeling methods infer opponent types, goals, or latent representations from interaction [10, 11, 12, 13], and cyber-forecasting methods predict attack stages or red actions from streaming observations [14, 15, 16, 17]. The present setting instead requires a full next-action distribution committed
*Preprint. Extended version with complete proofs and additional experimental detail.
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) before each outcome, with within-episode regime changes, state-dependent feasibility, and evaluation under sequential log loss.
We represent the active behavioral regime with a conditional hidden Markov model [8, 18] and structured executable actions with a regime-conditioned choice law on the feasible action tree. The same likelihood forms the next-action prediction before the action occurs and updates the regime belief afterwards; for a tree-prefix observation, the resolved local factors give its likelihood and the evidence it contributes about the regime. The construction retains exact filtering, and estimation separates into convex fits that Baum–Welch reuses when regimes are unlabeled.
Contributions. The latent dynamics follow the input–output HMM [8] and hidden-Markov choice models [9], and the log-loss bounds are mixture inequalities of the expert-tracking framework [19, 20, 21, 22]; the new elements are (i) a regime-conditioned choice law on a feasibility-masked action tree, with shared and regime-specific terms, whose identification rate is a reach-weighted sum of nodewise KL divergences over the observed action fields; (ii) exact filtering that treats a complete action and a tree-prefix observation through the same local factors; (iii) switching and uniform-fallback guarantees on the feasible tree; and (iv) an attacker-side CAGE Challenge 2 evaluation [23] of a two-stage form of the predictor that separates action structure, latent-state tracking, and soft regime weighting.
with a fixed feature map to a context vector. Given training episodes, the problem is to produce at each a distribution over the feasible actions, committed before the step's outcome is seen, that makes the sequential logarithmic loss small on the executed actions. In the replay setting logs reveal the complete executed action; in the detection setting the observer receives a coarsened observation of it.
Actions and feasibility. Actions are the leaves of a rooted tree , the action grammar, with internal nodes , children at an internal node , and leaf set . Each internal node resolves one semantic field of the action, with the operation family at the root and its arguments below. For a leaf , write for the child taken at on the path to , let be the internal nodes on the root-to-a path, and write . Feasibility at time is a mask ; the feasible children at are , and the feasible leaves are those whose entire path is feasible. Masks are pruned bottom-up, so every feasible child leads to at least one feasible leaf, the local choice laws normalize over , and their product induces a normalized distribution over . Masks are computed from the grammar and as conservative supersets of the true support, so every executed action remains feasible under the observer's model and constraints depending on the agent's private progress remain part of the modeled uncertainty.
Latent regime. The agent's regime at time is a latent state with . The regime is behavioral, for instance a policy family, a stage of an attack, or an operating constraint; it persists over consecutive steps, may change within an episode, and is defined only through its effect on the action distribution. The regime evolves through a context-dependent Markov kernel with an explicit self-transition term,
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) in which indexes , indexes , , and controls persistence. The shared persistence term keeps the transition model small when switch data are sparse, and fixing one at zero identifies . The transition into uses , which is available before and can depend on evidence accumulated through step together with any observer action taken first at step .
Setting gives the homogeneous persistent kernel
with and expected dwell time . The pathwise log-loss result applies to the general kernel in (2), while the explicit switching, fallback, and adaptation bounds use (3). At every row of (2) equals the contextual gate , so the filter carries no information across steps and the model reduces to a memoryless mixture of experts with a contextual gate.
With and the action-model parameters, (2) and the regime-conditioned action law of Section 3 define an HMM [8, 18] whose joint probability, for a predictable context sequence , regime path , and action sequence , is
with initial distribution .
3 Model, Inference, and Learning
Action model. Conditional on and context , the action follows a choice model assembled from local decisions at the internal nodes. Each child carries a descriptor , and we combine context and child identity through , allowing the same context to change the relative preference among children at a node. The local score is
with the vector shared across regimes and the per-regime residual. The local choice and the action probabilities are
and zero for , with the time dependence induced by the mask left implicit. The factorization (7) is a hierarchical softmax [24] with locally normalized choices along the feasible action path; it yields separate supervised likelihood terms at each node and decomposes regime differences across the visited nodes. The decomposition implements partial pooling across regimes that reach the same node: the shared term carries the common choice structure and the regime-specific departures, which are the only source of evidence about the active regime, so shrinking the residuals increases pooling while reducing identification; Section 4 quantifies this trade-off. We impose and use centered descriptors and a reference child, which identify as the across-regime mean and, with the quadratic penalties, make each supervised node problem strictly convex.
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
Prediction. Let be the posterior over the hidden regime before the agent acts and the posterior after. The predictor is the one-step predictive distribution of the hidden Markov model, obtained by averaging the regime-conditioned action laws over the current belief,
and the belief obeys, with and evidence weight defined below,
In replay , and in detection is the likelihood induced by the observation channel , with on an evidence-free step; for a tree-prefix observation it reduces to the product of the resolved local choice probabilities. The prediction (8) is committed before is formed and therefore uses only . One step runs (10), one feasible-tree pass per regime for (6)–(7), the prediction (8), and the update (9), in time linear in under (3) and in the size of the feasible tree; Appendix I gives the per-step cost in full and verifies that is a sufficient statistic of the history.
Estimation. When regime labels are observed, the penalized negative log-likelihood of one episode is
(11)
summed over episodes with quadratic regularizers on and . Every term is the negative log of a softmax linear in the parameters, so with observed regimes the objective is jointly convex and separates into one transition fit and one choice fit per node, each solved by L-BFGS-B under . With latent regimes the marginal likelihood is nonconvex, and Baum–Welch alternates exact forward–backward responsibilities with weighted versions of the same convex subproblems, increasing the penalized marginal likelihood monotonically to a stationary point. Held-out predictive likelihood selects . Single-regime trajectories contain no observed switches, so persistence is selected by validation NLL on separate state-preserving switch episodes. Appendix I records the convexity, separability, and uniqueness argument for (11) and the role of the residual in identifiability.
Uniform fallback state. For a finite reference loss that does not depend on the fit of the learned regimes, we add a state with node probabilities , where counts the feasible leaves below . These telescope to , uniform over the feasible actions, while preserving the product form (7). As an ordinary state of (3) on states, gives the fallback guarantee of Section 4, and is the weight assigned to it.
4 Analysis
Conditioning on the fitted parameters, we first quantify how the resolution of an observed action determines the evidence it provides about the active regime, then compare cumulative predictive loss with regime paths that may switch. The arguments are short: (12) sums the local laws below from the leaves up, (13) is the
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) chain rule for relative entropy on the tree, and (14) keeps one path of the forward recursion. Complete proofs are given in Appendices B–E, under the conventions of Appendix A.
Information from partial observations.
Lemma 1 (Tree-prefix likelihood). For a node with ancestors , writing ,
where is the child of toward v. Taking v as the root gives normalization over .
An observation that resolves the action path to depth k therefore has likelihood equal to the product of the k resolved local factors, and each resolved node can contribute evidence about the active regime (proof in Appendix B).
Corollary 1 (Regime identification rate). Fix and the feasible tree, let the executed action be drawn from regime , and let the evidence resolve the executed path to depth , with the set of feasible internal nodes at depth less than . For every regime , the expected log-likelihood ratio entering (9) is
with the probability under that the path reaches . At full resolution the sum equals , so unresolved nodes remove exactly their terms from the expected one-step increase of the posterior log-odds.
Each local term is, to second order, a quadratic form in the difference between regime residuals, so residual shrinkage lowers the identification rate, quantifying the trade-off between pooling and regime separation; Appendix C proves the corollary and Appendix I derives the second-order form.
Log-loss guarantees.
Theorem 1 (Individual-sequence tracking). Let be the predictor (8) produced by (9)–(10) with fixed parameters on the replay sequence. For every predictable context sequence , every realized action sequence satisfying , and every regime path ,
(14)
The detection setting obeys the same inequality with in place of the action likelihood. Minimizing the right-hand side over compares the deployed predictor with the regime path of smallest action loss plus its initial and transition cost under the fitted kernel. Appendix D gives the proof and the corresponding detection-setting inequality.
Corollary 2 (Fixed share and uniform fallback). With uniform v and the homogeneous kernel (3), a comparator path with S switches gives
(15)
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)

(a)

(b)
Figure 1: (a) Stationary test set, blue-observation context, 90% intervals; each ablation removes one element of the regime posterior and the arrow gives the change in NLL. (b) Mean NLL before a controller switch, at the switch step, and in three five-step windows after it, on a log scale.
the fixed-share penalty for tracking changing experts [20, 25] with the regime-conditioned action laws as the experts. If is an ordinary state of (3) on regimes, the constant comparator gives, for every feasible action sequence,
A single controls both penalties: by (16) the mean loss exceeds uniform coding over the feasible sets by at most , so no feasible action sequence is catastrophic, while carrying costs a learned-regime comparator only per episode; Appendix E proves both bounds and Appendix I works the trade-off out numerically. Greater persistence lowers the penalty for staying in one regime but raises the prior evidence to be overcome after a switch; since (3) floors every at , a Wald-type argument bounds the expected time for the posterior log-odds to favor the new regime by , with a floor on the evidence rate (13) and a bound on a single-step log-likelihood ratio, stated and proved as Remark 1 in Appendix F.
5 Experiments
Setup. We evaluate on CAGE Challenge 2 [23, 26] in the bug-fixed CybORG++ build [27, 28], where a red agent attacks a simulated enterprise network against a fixed reactive blue baseline, a setting studied so far mainly from the defender's side [29, 30, 31]; the closest precedent, [17], imitates a red policy from network observations and reports accuracy. The action tree has the operation at the root (no-op, system discovery, service discovery, exploitation, escalation, impact) and one operation-dependent argument below it, a subnet for system discovery and a host otherwise, giving 56 executable actions. The generating red policies B_line, Meander, and Sleep are the policy classes; Sleep is a point mass on no-op, so all predictors are scored on active steps, those whose executed action is not no-op. We train on 40 episodes of length 100 per policy, validate on 10, and hold out 25 per policy as the stationary test set. Switch episodes replace the red controller once at with session state preserved; 60 of them select the persistence of the policy-class chain by validation NLL and a disjoint set of scores regime tracking. The context holds the observer-available coordinates of the blue observation and features computed from them before
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
Table 1: Stationary test set (25 held-out episodes per policy, active steps) and switch test set. NLL in nats per step, top-1 in percent, 10-bin ECE; stationary NLL carries its 90% bootstrap interval and switch intervals are about ±0.3 nats. Choice models are hierarchical unless marked flat. The second group uses the blue-observation context, the third adds the previous action, and bold rows are the proposed model.
| Predictor | Stationary | Switch | |||
|---|---|---|---|---|---|
| NLL [CI] | Top-1 | ECE | NLL | ECE | |
| Action bigram | 1.119 [1.00, 1.22] | 63.8 | 0.037 | 1.946 | 0.077 |
| Masked GRU | 0.872 [0.76, 0.96] | 70.5 | 0.054 | 1.821 | 0.112 |
| Fixed state weights | 1.758 [1.66, 1.85] | 44.7 | 0.186 | 2.778 | 0.232 |
| Policy-class posterior | 1.350 [1.26, 1.43] | 56.7 | 0.074 | 2.634 | 0.125 |
| Posterior mode | 0.958 [0.85, 1.05] | 67.4 | 0.052 | 2.142 | 0.107 |
| Filtered posterior, flat | 0.917 [0.81, 1.01] | 68.7 | 0.059 | 1.899 | 0.105 |
| Filtered posterior | 0.964 [0.86, 1.05] | 67.0 | 0.047 | 1.971 | 0.088 |
| No latent state | 1.068 [0.97, 1.16] | 63.9 | 0.052 | 2.122 | 0.089 |
| Policy-class posterior | 1.033 [0.93, 1.12] | 64.5 | 0.042 | 2.201 | 0.088 |
| Filtered posterior | 0.924 [0.82, 1.01] | 68.0 | 0.045 | 1.951 | 0.084 |
the current red action, and the full context adds the previous red action as a one-hot vector. All runs use the replay setting. Metrics are per-step NLL in nats over the feasible set, top-1 accuracy, and 10-bin ECE of the top-1 confidence, with 90% episode-level bootstrap intervals.
Estimator and comparisons. The evaluated estimator is a two-stage form of the predictor with convex fits and inputs shared by every compared choice model. A 48-state HMM over actions with an unconstrained transition matrix is fit to the training action sequences without labels, and its filtered posterior enters the node scores of the masked choice model linearly beside the context, one convex logistic regression per node. The posterior thus pools the regime laws in the scores, which coincides with (8) at a one-hot posterior; the choice likelihood does not update the chain, so the bounds of Section 4 describe the joint filter (8) and are not claimed for this estimator. Ablations replace the filtered posterior by fixed state weights, by a one-hot encoding of its mode, or by nothing; the hierarchical choice model by a flat softmax over the 56 actions with the same inputs; and the learned chain by a three-state chain whose states are the policy classes with kernel (3). Reference predictors are a first-order Markov model on actions (the action bigram) and a masked GRU seeing the full context and mask and carrying its own recurrent state.
Stationary prediction. Table 1 and Figure 1(a) separate the two design choices. Removing the state dynamics costs 0.79 nats per step and 22 points of top-1 accuracy, and replacing the learned chain by the three policy classes costs 0.39, or 0.11 with the full context. The learned states thus carry information beyond the policy label, part of which the previous action supplies. Replacing the posterior by its mode changes nothing while the regime is stable. The flat softmax gains 0.047 nats at 44% more parameters and is worse calibrated. The GRU, at 7,288 parameters, reaches 0.872 nats and 70.5% against 0.924 and 68.0% for the full-context model, with overlapping intervals, and the choice model is the better calibrated of the two. The action bigram is a strong reference at 1.119 nats because B_line is close to deterministic given its last action, while uniform coding of the 56 actions costs 4.03. Over a sweep of the training-set size, the hierarchical model is at or below the flat one up to 60 episodes and behind it from 90 on. Appendix I lists the parameter counts of every predictor and the training-set sweep in full.
Regime tracking. The switch columns of Table 1 and Figure 1(b) report the switch episodes. At the switch step every predictor loses between 7.3 and 9.5 nats; the filtered hierarchical model loses 7.81, against 8.13 for its mode and 9.23 for the GRU, and its loss begins to fall after three steps against ten for the GRU. Over the whole episode, weighting by the full posterior is worth 0.17 nats per step over its mode, the same margin
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) the full-context model holds over no latent state, with overlapping intervals in both cases, though the paired per-episode differences exclude zero. Ten to fourteen steps after the switch, fixed weights stay at 4.4 nats and the policy-class chain at 2.0, against 1.35 for the proposed model; the GRU recovers further, to 1.05 in that window, and ends the episode at 1.821 against 1.951, again inside the intervals. Calibration favors the proposed model under switching as well, ECE 0.084 against 0.112 for the GRU and 0.105 for the flat softmax.
Summary. Across both experiments the accuracy of the next-action distribution is set by how well the predictor represents where the attacker is rather than by the capacity of the action model: the filtered latent state is worth 0.8 nats per step over fixed weights and 0.4 over the known policy classes, whereas the hierarchical and flat choice models are separated by 0.047 and the same-size GRU by less than one interval width. What the latent state buys is a calibrated belief rather than a label, and this is where the structure pays: weighting by the full posterior matches its mode in steady state but gains 0.17 nats per step under switching, and the loss begins to fall three steps after a controller change against ten for the GRU, at 30% fewer parameters than the flat model and better calibration than both baselines. The two open directions follow from the two places the belief is still weakest. Fitting the chain and the choice law jointly, rather than in the two stages evaluated here, would let the action likelihood sharpen the regime posterior and would bring the guarantees of Section 4 to bear on the deployed predictor, including the fallback state whose absence explains the overconfidence observed against a held-out red policy (Corollary 2, with the measurements in Appendix I). Beyond replay, the same local factors score a partially resolved action, so (13) predicts how much regime evidence survives coarse detections; testing that in the detection setting is the natural next step towards a defender that acts on the prediction.
Acknowledgments
This research was developed with funding from the Defense Advanced Research Projects Agency (DARPA). The views, opinions and/or findings expressed are those of the authors and should not be interpreted as representing the official views or policies of DARPA or the U.S. Government.
References
[1] Ralph Allan Bradley and Milton E Terry, “Rank analysis of incomplete block designs: I. the method of paired comparisons,” Biometrika, vol. 39, no. 3/4, pp. 324–345, 1952.
[2] Daniel McFadden, “Conditional logit analysis of qualitative choice behavior,” 1972.
[3] Rong Yang, Christopher Kiekintveld, Fernando Ordonez, Milind Tambe, and Richard John, “Improving resource allocation strategy against human adversaries in security games,” in IJCAI Proceedings-International Joint Conference on Artificial Intelligence. Barcelona, 2011, vol. 22, p. 458.
[4] Thanh Nguyen, Rong Yang, Amos Azaria, Sarit Kraus, and Milind Tambe, “Analyzing the effectiveness of adversary modeling in security games,” in Proceedings of the AAAI Conference on Artificial Intelligence, 2013, vol. 27, pp. 718–724.
[5] Anand Siththaranjan, Cassidy Laidlaw, and Dylan Hadfield-Menell, “Distributional preference learning: Understanding and accounting for hidden context in rlhf,” in International Conference on Learning Representations, 2024, vol. 2024, pp. 27448–27471.
[6] Kenneth Train et al., Discrete choice methods with simulation, vol. 2, Cambridge university press Cambridge, 2003.
Distribution Statement ‘A’ (Approved for Public Release, Distribution Unlimited)
[7] Sriyash Poddar, Yanming Wan, Hamish Ivison, Abhishek Gupta, and Natasha Jaques, “Personalizing reinforcement learning from human feedback with variational preference learning,” 2024, vol. 37, pp. 52516–52544.
[8] Yoshua Bengio and Paolo Frasconi, “An input output hmm architecture,” 1994, vol. 7.
[9] Oded Netzer, James M Lattin, and Vikram Srinivasan, “A hidden markov model of customer relationship dynamics,” Marketing science, vol. 27, no. 2, pp. 185–204, 2008.
[10] Stefano V Albrecht and Peter Stone, “Autonomous agents modelling other agents: A comprehensive survey and open problems,” Artificial Intelligence, vol. 258, pp. 66–95, 2018.
[11] Samer Nashed and Shlomo Zilberstein, “A survey of opponent modeling in adversarial domains,” Journal of Artificial Intelligence Research, vol. 73, pp. 277–327, 2022.
[12] Samer Nashed and Shlomo Zilberstein, “A survey of opponent modeling in adversarial domains,” Journal of Artificial Intelligence Research, vol. 73, pp. 277–327, 2022.
[13] Georgios Papoudakis, Filippos Christianos, and Stefano Albrecht, “Agent modelling under partial observability for deep reinforcement learning,” 2021, vol. 34, pp. 19210–19222.
[14] Pilar Holgado, Víctor A Villagrá, and Luis Vazquez, “Real-time multistep attack prediction based on hidden markov models,” IEEE Transactions on Dependable and Secure Computing, vol. 17, no. 1, pp. 134–147, 2017.
[15] Azqa Nadeem, Sicco Verwer, Stephen Moskal, and Shanchieh Jay Yang, “Alert-driven attack graph generation using s-pdfa,” IEEE transactions on dependable and secure computing, vol. 19, no. 2, pp. 731–746, 2021.
[16] Teng Li, Ya Jiang, Chi Lin, Mohammad S Obaidat, Yulong Shen, and Jianfeng Ma, “Deepag: Attack graph construction and threats prediction with bi-directional deep learning,” IEEE Transactions on Dependable and Secure Computing, vol. 20, no. 1, pp. 740–757, 2022.
[17] Ankita Samaddar, Sandeep Neema, Daniel Balasubramanian, and Xenofon Koutsoukos, “Learning red agent policy from observations for neurosymbolic autonomous cyber agents,” arXiv preprint arXiv:2606.18223, 2026.
[18] Lawrence R Rabiner, “A tutorial on hidden markov models and selected applications in speech recognition,” Proceedings of the IEEE, vol. 77, no. 2, pp. 257–286, 1989.
[19] Neri Merhav and Meir Feder, “Universal prediction,” IEEE Transactions on Information Theory, vol. 44, no. 6, pp. 2124–2147, 1998.
[20] Mark Herbster and Manfred K Warmuth, “Tracking the best expert,” Machine learning, vol. 32, no. 2, pp. 151–178, 1998.
[21] Olivier Bousquet and Manfred K Warmuth, “Tracking a small set of experts by mixing past posteriors,” Journal of Machine Learning Research, vol. 3, no. Nov, pp. 363–396, 2002.
[22] Wouter M Koolen and Steven de Rooij, “Universal codes from switching strategies,” IEEE Transactions on Information Theory, vol. 59, no. 11, pp. 7168–7185, 2013.
[23] Mitchell Kiely, David Bowman, Maxwell Standen, and Christopher Moir, “On autonomous agents in a cyber defence environment,” arXiv preprint arXiv:2309.07388, 2023.
Distribution Statement ‘A’ (Approved for Public Release, Distribution Unlimited)
[24] Frederic Morin and Yoshua Bengio, “Hierarchical probabilistic neural network language model,” in International workshop on artificial intelligence and statistics. PMLR, 2005, pp. 246–252.
[25] Nicolo Cesa-Bianchi, Gábor Lugosi, et al., Prediction, learning, and games, vol. 1, Cambridge university press Cambridge, 2006.
[26] TTCP CAGE Working Group, “TTCP CAGE Challenge 2,” github.com/cage-challenge/cage-challenge-2, 2022.
[27] Harry Emerson, Liz Bates, Chris Hicks, and Vasilios Mavroudis, “Cyborg++: An enhanced gym for the development of autonomous cyber agents,” arXiv preprint arXiv:2410.16324, 2024.
[28] Maxwell Standen, Martin Lucas, David Bowman, Toby J Richer, Junae Kim, and Damian Marriott, “Cyborg: A gym for the development of autonomous cyber agents,” arXiv preprint arXiv:2108.09118, 2021.
[29] Myles Foley, Chris Hicks, Kate Highnam, and Vasilios Mavroudis, “Autonomous network defence using reinforcement learning,” in Proc. ACM Asia Conference on Computer and Communications Security (ASIA CCS), 2022, pp. 1252–1254.
[30] Kim Hammar, Neil Dhir, and Rolf Stadler, “Optimal defender strategies for cage-2 using causal modeling and tree search,” arXiv preprint arXiv:2407.11070, 2024.
[31] Sanyam Vyas, Vasilios Mavroudis, and Pete Burnap, “Towards the deployment of realistic autonomous cyber network defence: A systematic review,” ACM Computing Surveys, vol. 58, no. 1, pp. 1–36, 2025.
[32] Haikady N Nagaraja, Inference in hidden Markov models, Taylor & Francis, 2006.
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
Appendices
Proofs, Omitted Results, and Additional Experimental Detail
These appendices collect complete proofs of the results stated in the body, state the results that were omitted there for length, verify the identities asserted in the text, and record the additional experimental detail referenced from it. Equations numbered (1)–(16) are those of the body; equations numbered by appendix section, such as (B.1), are local to the appendices.
A Conventions Used in the Proofs
All parameters are fixed, and , the context , and the masks are fixed wherever a single step is analyzed. Masks are pruned bottom-up, as stated in Section 2: every feasible child of a node on a feasible path retains at least one feasible leaf in its subtree, so the sets are the child sets of a pruned feasible tree whose leaf set is . Every local law is extended by for . The softmax (6) is strictly positive on , and the background weights are positive under pruning, so for every and every regime. The kernels (2) and (3) with are likewise strictly positive, so every divergence below is finite, with the convention . Two classical facts are used. Pinsker's inequality states [25]. The log-sum inequality states that for nonnegative reals and with and , ; it follows from Jensen's inequality for the convex function , since .
B Proof of Lemma 1
Lemma 1 (Tree-prefix likelihood, restated). For a node with ancestors , writing ,
where is the child of toward , extending the leaf notation to internal targets. Taking as the root gives normalization over .
Proof. If the path from the root to leaves the pruned feasible tree, then and at least one factor on the right vanishes by the zero-extension convention, so both sides are zero. Assume therefore that lies on the pruned tree. For a node of the pruned tree define when is a leaf and, when is internal,
the mass of the subtree below under the local factors at and its descendants. We show by induction on the height of in the pruned tree. If every child in is a leaf, then consists of the leaf children of , the product reduces to the single factor at , and by (6).
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
For a general internal , the leaves of partition according to the child taken at ; write for the child of with index . For a leaf through the product splits as times the corresponding product below , which is empty, hence one, when is a leaf. Pruning guarantees that every child in supports at least one feasible leaf, so the inductive hypothesis applies to each child and
For the lemma, every traverses the same ancestor edges with , so (7) factors its probability into the fixed ancestor product times the product at and below ; summing over and applying gives (12). At the root the ancestor product is empty and (12) states .
The same bookkeeping yields an identity used repeatedly below. For an internal node of the pruned tree and , restricting the sum to the leaves that take child at isolates the factor in front of the mass of the subtree below that child, which is one, so with ,
By (12), is the probability that the action path reaches ; dividing (B.1) by it shows that, conditionally on reaching , the child taken at has law .
C Proof of Corollary 1
Corollary 1 (Regime identification rate, restated). Fix and the feasible tree, let the executed action be drawn from regime , and let the evidence resolve the executed path to depth , with the set of feasible internal nodes at depth less than . For every regime , the expected log-likelihood ratio entering (9) is
with all local laws at the context and the probability under that the action path reaches . At full resolution the sum equals , so unresolved nodes remove exactly their terms from the expected one-step increase of the posterior log-odds.
Proof. Let and write for the child taken at an internal node . Prefix evidence to depth reveals the resolved edges of the executed path: the compatible leaves form with the deepest resolved node, and when the executed leaf lies at depth at most the evidence reveals the leaf itself. In either case Lemma 1 gives for every regime , so
Take expectations termwise. Identity (B.1) at regime states that the joint probability of reaching and taking child there factors as ; equivalently, conditioned on the event , whose probability is , the child has law . Hence for any function , . With the logarithmic ratio the inner sum is , which proves (13); every term is nonnegative because it is a divergence weighted by a probability. When
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
contains all internal nodes, the same computation applied to gives . Finally, (9) implies , so (13) is the expected increase of the posterior log-odds produced by the measurement update, and unresolved nodes remove exactly their terms.
D Proof of Theorem 1
Theorem 1 (Individual-sequence tracking, restated). Let be the predictor (8) produced by (9)–(10) with fixed parameters, on the replay sequence. For every context sequence predictable at each step, meaning each is a function of , every action sequence , and every regime path ,
(14)
No assumption is placed on the process generating : the inequality holds pointwise on sequences, so the deployed filter tracks the best regime path in hindsight, and the fallback state of Corollary 2 supplies a nonvacuous comparator even when no learned regime fits.
Proof. Fix the realized observer data and the scored sequence . Predictability means that and the masks at step are fixed functions of the realized prefix , which contains in replay; in particular no depends on the hidden path or on actions after step . Define and, for ,
the model probability of with every factor evaluated at the realized inputs. Introduce the unnormalized forward variables and, for , ; summing out the hidden path gives . We claim that the recursion (9)–(10), run with the replay evidence , satisfies and for every . For , gives and . Assume . Then (10) gives , hence by (8)
and (9) gives , closing the induction. The product therefore telescopes,
(D.1)
and every summand of (D.1) is nonnegative, so is at least the single summand indexed by the comparator path . Taking negative logarithms yields (14). All quantities are finite whenever : the
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) conservative masks keep , so every action-model factor is positive, and the kernels are strictly positive. No property of the mechanism generating was used, so the inequality holds pointwise on sequences.
The argument is the standard evaluation of a Bayesian mixture by the forward algorithm, as in the analysis of tracking a changing best expert [20, 25]; it is recorded in full because the input-dependent kernel and the mask-dependent action model enter the bookkeeping. The same telescoping yields the corresponding guarantee for the detection evidence of Section 3. Let the channel satisfy , and let be the predictive probability of the received evidence. Replacing every action-model factor by the evidence weight in the argument above gives, for every comparator path,
E Proof of Corollary 2
The two bounds of Corollary 2 are proved in turn.
Corollary 2, fixed-share bound (restated). With uniform v and the homogeneous kernel (3), a comparator path with S switches gives
(15)
The bound is the fixed-share guarantee for tracking a changing best expert [20, 25], with the regime-conditioned choice laws as the experts.
Proof. Under uniform . Under (3) the comparator's transitions comprise self-transitions, each contributing , and switches, each contributing ; substituting into (14) gives (15). The resulting guarantee coincides with the fixed-share bound for tracking a changing best expert [20].
Corollary 2, uniform fallback (restated). With an ordinary state of the homogeneous kernel (3) on the regimes and uniform , the constant comparator in (14) gives, for every action sequence,
the S=0 case of (15) at comparator , so the mean loss exceeds uniform coding by at most . Relative to the model without , the right side of (15) for a comparator path through the learned regimes with switches increases by exactly over the episode.
Proof. First, the background regime is well defined on the pruned tree. For an internal node , the feasible leaves below partition among its feasible children, so and the weights are positive and sum to one; along the path of any the ratios telescope, giving , while retains the product form (7) and hence Lemma 1. Apply
Distribution Statement ‘A’ (Approved for Public Release, Distribution Unlimited)
(14) on the homogeneous kernel over regimes with uniform and the constant comparator : the initial term is , all transitions are self-transitions contributing each, and the emission terms are ; this is (16) and is the case of (15) on states. Dividing by and using bounds the mean loss by the mean of plus . For the last claim, fix a comparator path through the learned regimes with switches and compare the right side of (15) on states with the same quantity on states at the same : the emission terms and the self-transition terms agree, the initial term grows by , and each switch term grows by , giving the stated increase.
F Adaptation Delay After a Switch
The following remark is referenced at the end of Section 4, where only its conclusion is quoted.
Remark 1 (Adaptation delay). Suppose the regime switches to and subsequent actions are drawn from and fully observed. Kernel (3) keeps every , so the initial log-odds deficit of against a fixed regime is at most . Before overtakes the homogeneous time update cannot increase this deficit, while each fully observed action contributes the expected evidence in (13). If that rate remains at least and each single-step log-likelihood ratio has magnitude at most , the expected pairwise crossing time is at most .
Proof. Fix and let denote the log-odds deficit of , with the first prediction after the switch. The time update under (3) leaves every regime mass at least , so .
One step consists of the measurement (9) followed by the time update (10). The measurement adds to the log-odds, where . Under (3) the time update acts on each belief coordinate as with and . For the ratio is a weighted median of and 1 and lies between them, so the time update moves the log-odds toward zero and preserves their sign.
Let . While the post-measurement odds are still positive, the time update shrinks them, and ; by induction for . Hence where is the first time the partial sums of the exceed .
The action is drawn from , so Corollary 1 gives . Write for the assumed rate floor and let bound . The sums form a martingale with increments in , and Azuma's inequality gives , so . The stopped sum exceeds by at most one increment, so optional stopping gives . Therefore .
Both constants are finite in the setting of Section 5: the feasible tree has bounded depth and the utilities (5) are bounded on the finite descriptor set, so the per-node log-ratios, and hence , are bounded, giving a finite ; and whenever the post-switch regime is separated from at some reachable node, the corresponding term of (13) is strictly positive, giving .
G Cost of Committing to One Regime
Appendices G and H record two results that quantify, respectively, the cost of collapsing the posterior average to a single regime and the exact per-step divergence of the joint model. Neither is used in the body; both are stated and proved here in full.
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
Proposition 1 (Cost of committing to one regime). Fix and belief with ; write , , , let be the remainder renormalized, and let be the excess log-loss of committing to . Then uniquely minimises , the excess of any is , and
Proof. Every is positive on , hence so is , and is a probability distribution because and pointwise. For any distribution on , , which is minimized exactly when , that is at , and the excess of any is ; taking identifies , finite by positivity of . For the lower bound, pointwise, so , and Pinsker's inequality gives . For the upper bound, apply the log-sum inequality at each with and :
and summing over gives .
H A Per-Step Divergence Identity
Proposition 2 (Per-step divergence). Fix and common feasible tree. For joint laws with belief vectors and reach probabilities ,
(H.1)
and .
Proof. Insert and split the logarithm:
with all terms finite because and the local laws are positive on the common feasible tree. Fix and let . As in the proof of Corollary 1,
and taking expectations termwise, using (B.1) at the law exactly as in the proof of Corollary 1 to factor each term into the reach probability times a local divergence, gives , which is (H.1). The final inequality is the chain rule in the other direction, .
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
I Details Referenced from the Body
This appendix supplies the derivations, identity checks, and experimental detail that the body asserts or references without developing. The items are grouped by the part of the paper they support.
I.1 Model, inference, and estimation
The persistence mapping (Section 2). With the numerator of (2) equals at and 1 otherwise, and the denominator equals , so the self-transition probability is and every off-diagonal entry is ; moreover holds exactly when , and as . Under (3) the holding time of a regime is geometric with parameter , hence the mean dwell .
The static restriction at (Section 2). At all rows of (2) coincide with , so for the time update (10) returns that gate for every ; after the common initialization at the filter carries no information across steps and the predictor reduces to the static contextual mixture. The persistent and static models are therefore nested and are compared by held-out predictive NLL in Section 5.
Identification of the transition parameters (Section 2). The destination coefficients of (2) are determined only up to a common shift, so we set for one reference regime. Using destination-specific context effects together with a single shared persistence term keeps the transition model at context vectors rather than , which matters because switch data are sparse.
The mask decomposition (Section 2). Let be the true support of and the conservative feasible set. For the law renormalized to satisfies , so the log loss splits into the loss on the true support and the log-probability the model assigns to it; a mask that excluded would force by (7) and infinite loss, which is why the masks are conservative.
Identifiability through the residual (Section 3). If then does not depend on , every evidence weight is constant in , (9) returns , and the posterior equals the prior propagated by (10): no action sequence moves it.
Convexity, separability, and uniqueness of the estimator (Section 3). Each summand of (11) has the form with utilities affine in the parameters, the composition of the convex log-sum-exp function with an affine map, hence convex; the objective is a sum of such terms and quadratics, is jointly convex, and separates because the parameters of node enter only the terms of node and only the transition terms. The ridge penalties make each block strictly convex, so its minimiser is unique; the constraints , the reference child, and the centered descriptors remove the directions the likelihood cannot see, so that is the across-regime mean preference. In Baum–Welch the maximisation step solves the responsibility-weighted versions of the same convex blocks, and the usual EM argument gives monotone ascent of the penalized marginal likelihood to a stationary point [32].
Sufficiency of the belief (Section 3). Under the model, the conditional law of given depends on the history only through and the forthcoming inputs, because (10) maps to and the emission depends on alone; iterating, is a sufficient statistic of the history for the regime given the context process.
The per-step cost (Section 3). One filtering step costs for the time update (10) under the general kernel (2) and for the tree traversals. Reshaping as a matrix gives ; computing once costs and each child score costs , giving the stated per node and regime, while under (3) the time update is the affine map , computed in .
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)
I. 2 Analysis and guarantees
Second-order form of the evidence rate (Corollary 1, Section 4). Fix a node and write and , so that by (5). With and , the log-partition expansion gives . Substituting and weighting by the reach turns each term of (13) into , a quadratic form in the residual differences; the ridge on therefore shrinks the residual differences and, through this quadratic form, lowers the identification rate directly, which is the trade between pooling and identification discussed in Section 3.
The hard-commitment comparison (Section 4). Since (8) averages nonnegative terms, for every , whence : the posterior average never loses more than per step against any single regime it still gives weight to.
A worked example for Corollary 2 (Section 4). At , , and , the fallback bound (16) exceeds uniform coding over the feasible sets by at most nats per step. At the same and one switch, carrying raises the learned-regime penalty of (15) by nats per episode, the instance of the premium . A single therefore buys a cheap worst-case guarantee at a small cost to the switching comparator.
Optimality of the posterior weighting (after Proposition 2). Under the model, . For any -measurable weighting , the mixture is -measurable, so ; subtracting the same identity at and taking expectations gives .
The Dobrushin coefficient (Section 4). Two distinct rows of (3) differ only in the two coordinates where one places and the other , so their total variation is . For beliefs with write with the normalized positive and negative parts; for any coupling of , , so ; geometric forgetting under bounded action likelihood ratios follows as in [32].
I. 3 Experimental detail
Model sizes (Table I, Section 5). Parameter counts are 3.1k for the action bigram, 7.3k for the masked GRU, 7.4k for the hierarchical choice model and 8.7k with the previous action in the context, 10.6k for the flat softmax over the 56 actions, and 1.5k for the policy-class chain and 2.8k with the previous action. The hierarchical model therefore uses about 30% fewer parameters than the flat softmax on the same inputs and is within 2% of the GRU it is compared with.
Training-set size (Section 5). Halving the training set to 60 episodes, from 120, the full-context choice model reaches 1.007 nats and 69.5% top-1 against 0.996 nats and 68.3% for the GRU, so the ordering of the two at 120 episodes reverses in likelihood and holds in accuracy. The hierarchical factorization is at or below the flat softmax up to 60 episodes (1.028 against 1.068 nats) and behind it from 90 episodes on, which is the expected pattern for a structural restriction that pays off when data are scarce.
Unseen attacker (Section 5). On episodes generated by a red controller absent from training, every learned predictor is overconfident, with ECE above 0.35. The action bigram degrades least, to 3.43 nats per step. The GRU reaches 4.48 nats and the choice models with the filtered posterior reach 5.39 (flat) and 7.19 (hierarchical, full context), all worse than the 4.03 nats of uniform coding over the 56 actions and worse than simply repeating the last action (3.95). This is the failure mode the fallback state of Section 3 is built for: in
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited) the joint filter, Corollary 2 caps the loss at uniform coding over the feasible sets plus the initial and persistence penalties, so no such sequence can be catastrophic. The two-stage estimator evaluated here does not carry , so this experiment establishes the failure mode and leaves the guarantee to be tested with the joint filter.
Distribution Statement 'A' (Approved for Public Release, Distribution Unlimited)