Elektra  0.9.5
Ensure

Applications want to ensure that some functionality (=global plugin) is present in Elektra.

Integrate kdbEnsure in kdbOpen(Key *errorKey, KeySet *contract) but only allow global plugins.

elektraNotificationOpen will be renamed and only return a contract KeySet:

KeySet * errorKey = keyNew ("/", KEY_END);
KeySet * contract = ksNew (0, KS_END);
elektraNotificationContract (contract, iobinding, errorKey);

The same for gopts:

elektraGOptsContract (contract, argc, argv, environ, errorKey);

Finally, we create KDB with the contracts we got before:

KDB * kdb = kdbOpen (contract, parentKey);

Opening KDB will fail if any of the contracts cannot be ensured.

As the contract gets copied, at any point after kdbOpen the contract can be safely deleted:

ksDel (contract);

The cleanup of the global plugins happens within:

kdbClose (kdb, errorKey);

It is safe to use the contract KeySet also for kdbGet and kdbSet invocations. Contract KeySets only contain Keys below system:/elektra/contract. Therefore, normal KeySets should not interfere.