diff --git a/crates/thing-core/tests/resolve.rs b/crates/thing-core/tests/resolve.rs
index 2eb9cb2..9f3fdf1 100644
--- a/crates/thing-core/tests/resolve.rs
+++ b/crates/thing-core/tests/resolve.rs
@@ -994,6 +994,37 @@ fn the_stack_bound_counts_a_slot_argument() {
stack_bound_counts(Through::SlotArgument);
}
+/// Runs `work` with only about `left` bytes of stack remaining: the stack is burned first, so a
+/// recursion that does not grow its own stack runs out inside it.
+#[inline(never)]
+fn with_stack_left(left: usize, work: &mut dyn FnMut()) {
+ let remaining = stacker::remaining_stack().expect("the thread's stack limit is known");
+ if remaining > left {
+ let burn = [0u8; 4096];
+ std::hint::black_box(&burn);
+ with_stack_left(left, work);
+ std::hint::black_box(&burn);
+ } else {
+ work();
+ }
+}
+
+#[test]
+fn counting_a_deep_slot_argument_grows_its_own_stack() {
+ // The body places a 900-level slot argument; the node limit refuses it where it is counted
+ // (validate::size, a recursion over the argument), before anything clones it. Run with little
+ // stack left, the count must move to a fresh segment to finish.
+ let limits = limited(1500);
+ let body = composition("c", &[("body", ParamKind::Slot)], boxed("b", vec![slot("body")]));
+ let state = state_with(&[body]);
+ let document = surface(boxed("root", vec![use_of("u", "c", vec![slot_arg("body", vec![chain(900, false)])])]), &[]);
+ let mut resolution = None;
+ with_stack_left(600 * 1024, &mut || resolution = Some(resolve(&document, &state, &limits)));
+ let resolution = resolution.unwrap();
+ refused_for_limit(&resolution);
+ assert!(!too_deep_to_resolve(&resolution), "{:?}", resolution.diagnostics);
+}
+
#[test]
fn a_slot_naming_a_param_of_another_kind_is_invalid() {
let body = composition("c", &[("x", ParamKind::Text)], boxed("b", vec![slot("x")]));
diff --git a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs
index a964edd..5345c60 100644
--- a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs
+++ b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs
@@ -38,6 +38,35 @@ public sealed class ReadOnlyListTests
Assert.That(checkedProperties, Is.GreaterThan(200));
}
+ ///
+ /// CultLib's element-id walk owns the elements of a list held as a class or interface of
+ /// [MessagePackObject] or [Union] elements, and demands an id on each. A list held as an ImmutableArray is one
+ /// whole value the walk never enters, so the contract holds every list that way.
+ ///
+ [Test]
+ public void NoKeyMemberIsAnOwnedListOfContractObjects()
+ {
+ bool IsContractObject(Type type) =>
+ type.GetCustomAttribute() != null || type.GetCustomAttributes(false).Any();
+ var offenders = new List();
+ var checkedMembers = 0;
+ foreach (var type in typeof(CommandResult).Assembly.GetExportedTypes())
+ foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
+ {
+ if (property.GetCustomAttribute() is null) continue;
+ checkedMembers++;
+ var t = property.PropertyType;
+ if (t.IsValueType) continue;
+ var element = t.GetInterfaces().Concat(new[] { t })
+ .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ .Select(i => i.GetGenericArguments()[0]).FirstOrDefault();
+ if (element != null && IsContractObject(element)) offenders.Add($"{type.Name}.{property.Name}: {t.Name}");
+ }
+
+ Assert.That(offenders, Is.Empty);
+ Assert.That(checkedMembers, Is.GreaterThan(100));
+ }
+
[Test]
public void EveryListParameterIsCopiedAndTheCopyCannotGrow()
{
diff --git a/tests/thing-contract-parity/written-by-ts.cc b/tests/thing-contract-parity/written-by-ts.cc
index 10b3daf..ccfb639 100644
Binary files a/tests/thing-contract-parity/written-by-ts.cc and b/tests/thing-contract-parity/written-by-ts.cc differ